Skip to content

Commit

Permalink
Make '-h' exit immediately after printing help info.
Browse files Browse the repository at this point in the history
Without this, the script continues to execute, and we see this
error:

```
./deploy.sh: line 124: [: =: unary operator expected
Deploy directory '' does not exist. Aborting.
```
  • Loading branch information
Matt Pearson committed Dec 20, 2015
1 parent b91b54e commit dc3959f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ parse_args() {
while : ; do
if [[ $1 = "-h" || $1 = "--help" ]]; then
echo "$help_message"
return 0
exit 0
elif [[ $1 = "-v" || $1 = "--verbose" ]]; then
verbose=true
shift
Expand Down

1 comment on commit dc3959f

@matro
Copy link
Contributor

@matro matro commented on dc3959f Dec 20, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this when checking formatting after completing the sentence I left dangling.

But I noticed that return 1 also seems to work here as well. At least, I don't see the two Bash errors. Spent a little time trying to make a test for this, and haven't had much success.

exit seems safer to me, and I'm pretty sure we don't want a non-zero exit status. Probably doesn't matter much for --help here, still.

Please sign in to comment.