-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
print usage and exit with error on invalid arguments
Add also some testing to make sure help, long help and handling of invalid arguments works as expected. Based on pull request #19 originally by Laurent Arnoud (@spk).
- Loading branch information
Showing
2 changed files
with
29 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
|
||
fail=0 | ||
|
||
help_output=$(../src/apk version --help 2>/dev/null) | ||
invalid_option_output="$(../src/apk --invalid-option version 2>/dev/null)" | ||
if [ "$help_output" != "$invalid_option_output" ]; then | ||
echo "FAIL: invalid option does not trigger help" | ||
fail=$((fail+1)) | ||
fi | ||
|
||
if ! ../src/apk --help 2>/dev/null | grep -q "^Use apk --help --verbose for a full command listing."; then | ||
echo "FAIL: brief help gives long help" | ||
fail=$((fail+1)) | ||
fi | ||
|
||
if ../src/apk --help --verbose 2>/dev/null | grep -q "^Use apk --help --verbose for a full command listing."; then | ||
echo "FAIL: long help does not work" | ||
fail=$((fail+1)) | ||
fi | ||
|
||
if [ $fail -eq 0 ]; then | ||
echo "OK: command parsing works" | ||
fi | ||
|
||
exit $fail |