Hi,
The bashdb script seems to have a bug that prevents it from running on OS X; specifically my system information is
>bash-3.2$ uname -a
>Darwin dawson1.hosted.ats.ucla.edu 7.9.0 Darwin Kernel Version 7.9.0: Wed Mar 30 20:11:17 PST 2005; root:xnu/xnu-517.12.7.obj~1/RELEASE_PPC Power Macintosh powerpc
I am using bashdb-3.1-0.09 and bash-3.2.
It appears to be a problem with the BSD version of getopt: with liberal use of echo commands (it would have been helpful to have a script debugger...), I found out that
line 118 TEMP=`getopt -o testing t 2>/dev/null`
leaves gives an exit code (and hence $?) of 0, although BSD getopt definitely doesn't do what you want it to do (see below); so the if statement on the next line
line 119 if [ 1 = 1 ] && [ 0 = $? ] ; then
evaluates to true.
Then, with $0 = './bashdb', $1 = '-h' in this case, and all other positional parameters empty, the real getopt command
line 124 TEMP=`getopt -o Bc:hL:nqt:T::x:XYV \
line 125 --long basename,command:,debugger,help,library:,no-init,quiet,tempdir:,terminal:,trace,tty,version \
line 126 -n 'bashdb' -- "$@"`
sets $TEMP to the comically incorrect ' -- Bc:hL:nqt:T::x:XYV --long basename,command:,debugger,help,library:,no-init,quiet,tempdir:,terminal:,trace,tty,version -n bashdb -- -h' .
With this value for $TEMP, the set command
line 134 eval set -- "$TEMP"
then sets the positional variables to: $0 is ./bashdb , $1 is -- , $2 is Bc:hL:nqt:T::x:XYV , $3 is --long , $4 is basename,command:,debugger,help,library:,no-init,quiet,tempdir:,terminal:,trace,tty,version , $5 is -n , $6 is bashdb , $7 is -- , $8 is -h , and $9 is empty.
And at the end of the day, the output of the script is the not totally helpful:
>bash-3.2$ ./bashdb -h
>Bourne-Again Shell Debugger, release bash-3.1-0.09
>Copyright 2002, 2003, 2004, 2006, 2007 Rocky Bernstein
>This is free software, covered by the GNU General Public License, and you are
>welcome to change it and/or distribute copies of it under certain conditions.
>
>bashdb: cannot read program to debug: Bc:hL:nqt:T::x:XYV.
I hope that's helpful. I'm afraid I don't know the right way to do what you want to do on OS X; I just set the if statement to "if false" -- probably not the best long term solution. If I've left anything important out please email me at joshmay _at_ You Sea El Eh? _dot_ edu
Many thanks,
Josh May
p.s. Also, as a side note, on line 197 you have
line 197 echo "Use --help for option help. Terminating..."
Since that's inside of the short options only section, do you really want to suggest the user use --help?
Logged In: YES
user_id=158581
Originator: NO
One way to disable long getopt is to use --disable-getopt. I've committed a change to fix the incorrect way to get help when short-options are in effect.
Down the line I'll consider a better configure test in seeing if log getopts work properly.
Sorry to take so long to reply.
Logged In: YES
user_id=158581
Originator: NO
I've put in a configure test that should cover BSD-style getopt failures. Please try out what's in CVS and let me know if this addresses the problem(s).
Thanks for reporting the problem and your detailed investigation.