yanson694 / shflags

Automatically exported from code.google.com/p/shflags
0 stars 0 forks source link

Running /bin/sh with the -e flag causes shFlags to exit unexpectedly #9

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
the script does not source the library but closes down directly due to an 
error somehow...

well, one problem seems to be related to the "grep" command around this 
lines in shflags:

    232   # TODO(kward): check for validity of the flag name (e.g. dashes)
    233
    234   # check whether the flag name is reserved
    235   echo " ${FLAGS_RESERVED} " |grep " ${_flags_name_} " >/dev/null
    236 if [ $? -eq 0 ]; then
    237 flags_error="flag name (${_flags_name_}) is reserved"
    238 _flags_return_=${FLAGS_ERROR}
    239 fi
    240
If the calling script uses -e, the code finishes in the line 235 because the 
grep returns "1" within the value "$?"
If a -v switch is used, the output is inverted and with the line
if [ $? -eq 1 ]; then

Original issue reported on code.google.com by kate.war...@gtempaccount.com on 19 May 2009 at 10:51

GoogleCodeExporter commented 9 years ago

Original comment by kate.w...@forestent.com on 6 Jan 2013 at 4:38