aboutsummaryrefslogtreecommitdiff
path: root/source/1.0/src
diff options
context:
space:
mode:
authorkate.ward <kate.ward@forestent.com>2008-11-12 22:37:05 +0000
committerkate.ward <kate.ward@forestent.com>2008-11-12 22:37:05 +0000
commitabae05d8051c23fbca3e0e6c459142815df74a23 (patch)
tree2199e6430a8cb09cb881082fba57b1baec0ebc00 /source/1.0/src
parent1b600c53cdd5ad1b8a487d50ec1d1e9b0992166c (diff)
downloadshflags-abae05d8051c23fbca3e0e6c459142815df74a23.tar.gz
no more warning is thrown when the user defines their own help flag
Diffstat (limited to 'source/1.0/src')
-rw-r--r--source/1.0/src/shflags5
-rwxr-xr-xsource/1.0/src/shflags_test_parsing.sh6
2 files changed, 7 insertions, 4 deletions
diff --git a/source/1.0/src/shflags b/source/1.0/src/shflags
index 221ba51..eb7a9b7 100644
--- a/source/1.0/src/shflags
+++ b/source/1.0/src/shflags
@@ -735,8 +735,9 @@ DEFINE_string() { _flags_define ${__FLAGS_TYPE_STRING} "$@"; }
# integer: success of operation, or error
FLAGS()
{
- # define standard 'help' flag
- DEFINE_boolean 'help' false 'show this help' 'h'
+ # define a standard 'help' flag if one isn't already defined
+ [ -z "${__flags_help_type:-}" ] && \
+ DEFINE_boolean 'help' false 'show this help' 'h'
# parse options
# TODO(kward): look into '-T' option to test the internal getopt() version
diff --git a/source/1.0/src/shflags_test_parsing.sh b/source/1.0/src/shflags_test_parsing.sh
index 40ff4c9..1de19f9 100755
--- a/source/1.0/src/shflags_test_parsing.sh
+++ b/source/1.0/src/shflags_test_parsing.sh
@@ -49,7 +49,8 @@ testValidBooleanShort()
value=${FLAGS_bool:-}
assertTrue "boolean was not true (${value})." "${value}"
assertFalse 'expected no output to STDERR' "[ -s '${stderrF}' ]"
- th_showOutput ${rtrn} "${stdoutF}" "${stderrF}"
+ test ${rtrn} -eq ${FLAGS_TRUE} -a ! -s "${stderrF}"
+ th_showOutput $? "${stdoutF}" "${stderrF}"
# verify that passing the option a second time leaves the flag true
FLAGS -b >"${stdoutF}" 2>"${stderrF}"
@@ -58,7 +59,8 @@ testValidBooleanShort()
value=${FLAGS_bool:-}
assertTrue "repeat: boolean was not true (${value})" ${value}
assertFalse 'repeat: expected no output to STDERR' "[ -s '${stderrF}' ]"
- th_showOutput ${rtrn} "${stdoutF}" "${stderrF}"
+ test ${rtrn} -eq ${FLAGS_TRUE} -a ! -s "${stderrF}"
+ th_showOutput $? "${stdoutF}" "${stderrF}"
}
testValidBooleanLong()