Skip to content

Instantly share code, notes, and snippets.

@unakatsuo
Created January 15, 2015 07:30
Show Gist options
  • Save unakatsuo/766ff76e2d407dee55d4 to your computer and use it in GitHub Desktop.
Save unakatsuo/766ff76e2d407dee55d4 to your computer and use it in GitHub Desktop.
Shell: Check "return" behavior using at top level.

Check "return" behavior using at top level.

Run with ENV1.

% export ENV1=1
% /bin/sh ./test.sh
ENV1 found
a=1, b=2
% echo $?
0

Run without ENV1

% /bin/sh ./test.sh
Skip
% echo $?
1
#!/bin/sh
a=1
b=2
if [[ -z "$ENV1" ]]; then
echo "ENV1 found"
return 0
else
echo "Skip"
fi
exit 1
#!/bin/sh
. ./source.sh
echo "a=$a, b=$b"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment