diff options
author | Kate Ward <kate.ward@forestent.com> | 2017-10-21 19:45:29 +0200 |
---|---|---|
committer | Kate Ward <kate.ward@forestent.com> | 2017-10-21 19:45:29 +0200 |
commit | 16e8d0d3a58dfe8ccc0423b2cfbdf8119e7a86d7 (patch) | |
tree | 86a192b9423cc648c53523b6a3ca296405b7be71 | |
parent | 78740ed6347816adcd7e863b0eb32099464a40a7 (diff) | |
download | shflags-16e8d0d3a58dfe8ccc0423b2cfbdf8119e7a86d7.tar.gz |
Fixed #47. A call for help should return a non-zero exit code.
-rw-r--r-- | shflags | 2 | ||||
-rwxr-xr-x | shflags_issue_28_test.sh | 10 | ||||
-rwxr-xr-x | shflags_public_test.sh | 16 |
3 files changed, 13 insertions, 15 deletions
@@ -892,7 +892,7 @@ _flags_parseGetopt() { if [ "${FLAGS_help}" -eq ${FLAGS_TRUE} ]; then flags_help flags_error='help requested' - flags_return=${FLAGS_TRUE} + flags_return=${FLAGS_FALSE} break fi fi diff --git a/shflags_issue_28_test.sh b/shflags_issue_28_test.sh index 02c3803..fbb17d9 100755 --- a/shflags_issue_28_test.sh +++ b/shflags_issue_28_test.sh @@ -37,8 +37,8 @@ _testHelp() { FLAGS "${flag}" >"${stdoutF}" 2>"${stderrF}" echo $? >"${returnF}" ) - assertTrue \ - 'short help request should have returned a true exit code.' \ + assertFalse \ + 'short help request should have returned a false exit code.' \ "$(th_queryReturn)" grep 'show this help' "${stderrF}" >/dev/null grepped=$? @@ -93,9 +93,6 @@ EOF FLAGS_HELP=${help}; FLAGS -h >"${stdoutF}" 2>"${stderrF}" ) - r3turn=$? - assertTrue "FLAGS -h return: want ${FLAGS_TRUE}, got ${r3turn}" ${r3turn} - diff "${expectedF}" "${stderrF}" >/dev/null r3turn=$? assertTrue 'unexpected help output' ${r3turn} @@ -120,9 +117,6 @@ EOF FLAGS_HELP=${help}; FLAGS -h >"${stdoutF}" 2>"${stderrF}" ) - r3turn=$? - assertTrue 'a call for help should not return an error' ${r3turn} - diff "${expectedF}" "${stderrF}" >/dev/null differed=$? assertTrue 'unexpected help output' ${differed} diff --git a/shflags_public_test.sh b/shflags_public_test.sh index e615ffc..41eacba 100755 --- a/shflags_public_test.sh +++ b/shflags_public_test.sh @@ -37,8 +37,8 @@ _testHelp() { FLAGS "${flag}" >"${stdoutF}" 2>"${stderrF}" echo $? >"${returnF}" ) - assertTrue \ - 'short help request should have returned a true exit code.' \ + assertFalse \ + 'a call for help should return a non-zero exit code.' \ "$(th_queryReturn)" grep 'show this help' "${stderrF}" >/dev/null grepped=$? @@ -102,9 +102,11 @@ EOF _flags_columns() { mock_flags_columns; } FLAGS_HELP=${help}; FLAGS -h >"${stdoutF}" 2>"${stderrF}" + echo $? >"${returnF}" ) - r3turn=$? - assertTrue 'a call for help should not return an error' ${r3turn} + assertFalse \ + 'a call for help should return a non-zero exit code.' \ + "$(th_queryReturn)" diff "${expectedF}" "${stderrF}" >/dev/null r3turn=$? @@ -142,9 +144,11 @@ EOF # shellcheck disable=SC2034 FLAGS_HELP=${help}; FLAGS -h >"${stdoutF}" 2>"${stderrF}" + echo $? >"${returnF}" ) - r3turn=$? - assertTrue 'a call for help should not return an error' ${r3turn} + assertFalse \ + 'a call for help should return a non-zero exit code.' \ + "$(th_queryReturn)" diff "${expectedF}" "${stderrF}" >/dev/null differed=$? |