|| @iamidly
-- a blog about sham, unix and software design. also i rant.

exit

exit makes exit on a subshell with an exit code and an optional message.

#!/usr/bin/env sham
( exit 1
  echo i will not happen
) 2>&1
echo after subshell
@iamidly> sham /tmp/EXAMPLE_CODE_0_
/tmp/EXAMPLE_CODE_0_:2 early exit with status EPERM 
after subshell

note the difference between a subshell and a normal grouping. this exit will exit the main instance of sham.

#!/usr/bin/env sham
{ exit 1
  echo i will not happen
} 2>&1
echo after subshell
@iamidly> sham /tmp/EXAMPLE_CODE_1_
/tmp/EXAMPLE_CODE_1_:2 early exit with status EPERM 

when we supply an error message:

#!/usr/bin/env sham
( exit 1 'we exited with error' ) 2>&1
@iamidly> sham /tmp/EXAMPLE_CODE_2_
/tmp/EXAMPLE_CODE_2_:2 early exit with status EPERM [we exited with error]

and we can use empty string to supress error message.

#!/usr/bin/env sham
( exit 1 '' ) 2>&1
@iamidly> sham /tmp/EXAMPLE_CODE_3_
|| come join me at #sham on irc.snoonet.net
</post>