Skip to content

Instantly share code, notes, and snippets.

@ninjudd
Created August 30, 2012 20:44
Show Gist options
  • Save ninjudd/3540448 to your computer and use it in GitHub Desktop.
Save ninjudd/3540448 to your computer and use it in GitHub Desktop.
Command substitution hangs if the command starts a process in the background.
foo=$(./foo.sh)
echo "foo is '$foo'"
yes > /dev/null &
disown %-
echo "yes started"
@ninjudd
Copy link
Author

ninjudd commented Aug 30, 2012

Only works if we redirect yes to /dev/null. This is obvious in the case of yes since it spews a bunch of output, but not so obvious for commands that may not output anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment