Skip to content

Instantly share code, notes, and snippets.

@vvv
Last active August 29, 2015 14:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vvv/2b43d722ba79f7620f1d to your computer and use it in GitHub Desktop.
Save vvv/2b43d722ba79f7620f1d to your computer and use it in GitHub Desktop.
Surprise of the day
$ cat noexit.sh
#!/bin/sh
seq 100 | while read; do exit; done # If `exit' terminated the script ..
echo 'Still alive!' # .. this message would not be printed.
$
$ sh noexit.sh
Still alive!
@vvv
Copy link
Author

vvv commented Aug 14, 2015

bash(1) says:

       Each  command  in  a  pipeline  is executed as a separate process
       (i.e., in a subshell).

Kudos to ismaildonmez for the reference!

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