Open GoogleCodeExporter opened 9 years ago
Fixed in CL# 146.
Original comment by kate.war...@gtempaccount.com
on 28 Jun 2011 at 1:31
Hi, has the fix been tested on Mac OS X?
When I try the example as given on the Wiki, I still get this reported error on
Mac OS X 10.6.8
GoetheMBP-2:~ andreas$ head shflags
# $Id: shflags 147 2011-06-28 13:29:40Z kate.ward@forestent.com $
# vim:et:ft=sh:sts=2:sw=2
#
# Copyright 2008 Kate Ward. All Rights Reserved.
# Released under the LGPL (GNU Lesser General Public License)
#
# shFlags -- Advanced command-line flag library for Unix shell scripts.
# http://code.google.com/p/shflags/
#
# Author: kate.ward@forestent.com (Kate Ward)
GoetheMBP-2:~ andreas$
GoetheMBP-2:~ andreas$
GoetheMBP-2:~ andreas$
GoetheMBP-2:~ andreas$ cat test.sh
#! /bin/sh
source ./shflags
DEFINE_string name 'world' "somebody's name" n
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
echo $FLAGS_name
exit 0
GoetheMBP-2:~ andreas$
GoetheMBP-2:~ andreas$
GoetheMBP-2:~ andreas$ ./test.sh -n Kate
Kate
GoetheMBP-2:~ andreas$ ./test.sh --name Andreas
flags:WARN getopt: illegal option -- -
-n ame -- Andreas
flags:FATAL unable to parse provided options with getopt.
GoetheMBP-2:~ andreas$ which getopt
/usr/bin/getopt
Original comment by andreas....@gmail.com
on 15 Aug 2011 at 6:42
Apparently, my getopt version is not the enhanced one. This seems not to be
recognized by the test in the beginning of shflags (line 136 of CL# 174).
GoetheMBP-2:~ andreas$ echo "\"`getopt --version`\""
" --"
Instead of "-- " as tested for by shflags.
GoetheMBP-2:~ andreas$ if [ "`getopt --version`" = '-- ' ]; then echo "Standard
getopt"; fi
GoetheMBP-2:~ andreas$ if [ "`getopt --version`" = ' --' ]; then echo "Standard
getopt"; fi
Standard getopt
GoetheMBP-2:~ andreas$
Original comment by andreas....@gmail.com
on 15 Aug 2011 at 7:08
Sorry, wrote too soon... shflags sets correctly __FLAGS_GETOPT_VERS to
__FLAGS_GETOPT_VERS_STD (0)
Original comment by andreas....@gmail.com
on 15 Aug 2011 at 7:26
Final comment, for anyone having the same issue on Mac OS X, you can get the
enhanced GNU getopt version via MacPorts (http://www.macports.org/).
$ sudo port install getopt
(after you installed MacPorts, see http://www.macports.org/install.php)
Original comment by andreas....@gmail.com
on 15 Aug 2011 at 7:41
it's not fixed
@andreas: shFlags's plot being "Most shell scripts use getopt for flags
processing, but the different versions of getopt on various OSes make writing
portable shell scripts difficult. shFlags instead provides an API that doesn't
change across shell and OS versions so the script writer can be confident that
the script will work."
I don't see how installing getopt from MacPorts is satisfying. The whole point
of shFlags is to avoid relying on a specific version of getopt...
Original comment by gregory....@gmail.com
on 8 Jan 2012 at 11:01
Opening until there is a reasonable native fix for OS X.
Original comment by kate.w...@forestent.com
on 6 Jan 2013 at 5:15
Any word on this? Yosemite is about to launch and this is still an issue.
Original comment by awelli...@gmail.com
on 7 Oct 2014 at 4:37
Hi, any news here? This still does not work on current MacOS (High Sierra) and it also does not work on my servers (DragonFlyBSD).
I'm using zsh.
@mahono everything seems to work if you run brew install gnu-getopt
and brew link --force gnu-getopt
the default getopt doesn't play nice with long flags and shFlags - something that should be fixed, but installing the better version always works. Not sure the equivalent commands for macports or anything else as I don't use them.
Original issue reported on code.google.com by
gregory....@gmail.com
on 29 Jul 2010 at 1:51