aboutsummaryrefslogtreecommitdiff
path: root/source/1.0
diff options
context:
space:
mode:
authorkate.ward <kate.ward@forestent.com>2008-11-13 00:42:43 +0000
committerkate.ward <kate.ward@forestent.com>2008-11-13 00:42:43 +0000
commit5b48fc1ae0b7dc7d8edeaa8bb544f321794d9681 (patch)
treeef0c28e500546b6ae47919fb65353c7ef757bb4e /source/1.0
parente556cbf61eb41fdf96d70da51d38982d9c71af4f (diff)
downloadshflags-5b48fc1ae0b7dc7d8edeaa8bb544f321794d9681.tar.gz
issue# 2 : --nohelp flag no longer produces help output
Diffstat (limited to 'source/1.0')
-rw-r--r--source/1.0/doc/CHANGES-1.0.txt6
-rw-r--r--source/1.0/src/shflags21
-rwxr-xr-xsource/1.0/src/shflags_test_public.sh11
3 files changed, 26 insertions, 12 deletions
diff --git a/source/1.0/doc/CHANGES-1.0.txt b/source/1.0/doc/CHANGES-1.0.txt
index fb80a64..3e5c921 100644
--- a/source/1.0/doc/CHANGES-1.0.txt
+++ b/source/1.0/doc/CHANGES-1.0.txt
@@ -25,8 +25,10 @@ gen_test_results.sh to make releases easier.
Copied the coding standards from shUnit2, but haven't fully implemented them
in shFlags yet.
-When a user defines their own --help flag, no more warning is thrown when
-FLAGS() is called stating that the help flag already defined.
+Issue# 1: When a user defines their own --help flag, no more warning is thrown
+when FLAGS() is called stating that the help flag already defined.
+
+Issue# 2: Passing the --nohelp option no longer gives help output.
Changes with 1.0.1
diff --git a/source/1.0/src/shflags b/source/1.0/src/shflags
index 1b93072..f51bb91 100644
--- a/source/1.0/src/shflags
+++ b/source/1.0/src/shflags
@@ -227,8 +227,7 @@ _flags_define()
-a ${__FLAGS_GETOPT_VERS} -ne ${__FLAGS_GETOPT_VERS_ENH} \
-a "${_flags_short_}" = "${__FLAGS_NULL}" ]
then
- flags_error="getopt on this platform supports only short flags. Please \
-declare one for the (${_flags_name_}) flag."
+ flags_error="short flag required for (${_flags_name_}) on this platform"
_flags_return_=${FLAGS_ERROR}
fi
@@ -630,14 +629,6 @@ _flags_parseGetopt()
break
fi
- # handle special case help flag
- if [ "${_flags_name_}" = 'help' ]; then
- flags_help
- flags_error='help requested'
- flags_return=${FLAGS_FALSE}
- break
- fi
-
# set new flag value
[ ${_flags_type_} -eq ${__FLAGS_TYPE_NONE} ] && \
_flags_type_=`_flags_getFlagInfo \
@@ -687,6 +678,16 @@ _flags_parseGetopt()
;;
esac
+ # handle special case help flag
+ if [ "${_flags_name_}" = 'help' ]; then
+ if [ ${FLAGS_help} -eq ${FLAGS_TRUE} ]; then
+ flags_help
+ flags_error='help requested'
+ flags_return=${FLAGS_FALSE}
+ break
+ fi
+ fi
+
# shift the option out
shift
FLAGS_ARGC=`expr ${FLAGS_ARGC} + 1`
diff --git a/source/1.0/src/shflags_test_public.sh b/source/1.0/src/shflags_test_public.sh
index ea16bb0..f44c275 100755
--- a/source/1.0/src/shflags_test_public.sh
+++ b/source/1.0/src/shflags_test_public.sh
@@ -117,6 +117,17 @@ EOF
&& cat "${stderrF}"
}
+testNoHelp()
+{
+ flags_getoptIsEnh || startSkipping
+
+ ( FLAGS --nohelp >"${stdoutF}" 2>"${stderrF}" )
+ rtrn=$?
+ assertTrue "FLAGS returned a non-zero result (${rtrn})" ${rtrn}
+ assertFalse 'expected no output to STDOUT' "[ -s '${stdoutF}' ]"
+ assertFalse 'expected no output to STDERR' "[ -s '${stderrF}' ]"
+}
+
#------------------------------------------------------------------------------
# suite functions
#