The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [subshell]

The tag has no usage guidance.

12 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
1answer
45 views

Nested command substitution does not stop a script on a failure even if -e and shopt -s inherit_errexit are set

Suppose you have a following script sandbox.sh. (This looks similar to Command substitution inside a function does not stop the script on a failure even if -e is set, but I believe a bit different ...
2
votes
0answers
42 views

Is job-control really meant to be supported in subshells and scripts?

Small premise I use subshells quite often to perform operations that involve changing the Shell Execution Environment, so as not to affect the main shell. I do it often from an interactive shell, and ...
2
votes
0answers
237 views

Tmux status bar flashes command from #() before displaying result

I currently use the following command to display the current git branch or mercurial bookmark for the pane's working directory. It works correctly as far as I can tell, but just before it computes ...
1
vote
0answers
26 views

How can I create a function that memoizes other commands?

I have created the following function to memoize any command: # zsh (( $+functions[ec] )) || { ec() print -r -- "$@" ecerr() { ec "$@" 1>&2 } ecdbg() ecerr "$@" gq() { ec "${(q+...
1
vote
1answer
95 views

Export vars env to tmux's window/session/pane's env

Is there any way to export/upgrade list of variable env from a file or something to tmux's window/session/pane? Here I have to manually source .bashrc to update new var env to each tmux's pane.
1
vote
2answers
93 views

Is it possible to findout if our command is sourced from a script or manually typed on command line?

We have an implementation to set environment for a particular tool with our custom command. Eg: custom_command tool_name This command logs the invokation time, user and tool_name in a log file. And ...
1
vote
1answer
260 views

Child process - listen for event when parent dies

I have a detached child process. It knows its parent's pid. Is there some way on both MacOS and Linux that I can listen for when the parent process exits, from the child process? I need to make a ...
1
vote
0answers
1k views

Restoring tty correctly with stty

I'm writing a bash script to read some user input (like a password request), and I'd like to capture the result and pass it through its stdout. (I'm working in a GNU/Linux environment, with recent ...
1
vote
0answers
302 views

Start a subshell then run commands

Say I have a script that is always run from an interactive shell. I would like this script to launch an interactive subshell that is a replica of the parent (i.e., all environment variables, etc. ...
0
votes
0answers
37 views

Terminate a subshell background process

I am starting entr as a subshelled background process as described in its man page to listen to changes to some file foo, occuring during interactive use of some program baz, and I would like to ...
0
votes
0answers
20 views

Shell: Open REPL in function

I want to open an interactive REPL in my zsh functions (mainly for debugging purposes); Exactly like IPython.embed(). One way to do something similar is to simply invoke another instance of zsh, but ...
0
votes
0answers
53 views

Run script in background using `&` or `()&`?

If I want to run a script in background, for example a.sh, should I run ./a.sh & or should I put it in a subshell then background it? (./a.sh) & I test both and don't see difference, both ...