[rg-bugs]
> rosegarden-lilypondview: allow any order of command line arguments
> [...]
> +for x in $*; do

I suggest GNU getopt instead.  That's how it really should have been done in 
the first place (mea culpa).  It's more verbose, but it makes for more 
trustworthy parsing and more reliable handling of things like quoted 
arguments, as well as support for long option names.

Actually, I'm amazed that none of our helper scripts uses it.  I must be 
lazier than I thought.

Generic fragment:


myname=`basename $0` # just a name to print out
getopt -T 2>/dev/null # test for GNU enhanced getopt, returns 4 if present
if [ "$?" -ne 4 ]; then
    echo "$myname: enhanced GNU getopt required" # or equivalent response
    exit 1
fi
# parse our example opts: -c or --conftest, and -P <printername> or --printer
options=`getopt -n "$myname" -o cP: -l conftest,printer: -- "$@"`
[ "$?" -eq 0 ] || exit 1 # bad options: getopt will already have printed error

conftest=""
printername=""

eval set -- "$options" # read tidied $options back in to arg array
while true; do
    case "$1" in
        -c|--conftest)   conftest=1; shift;;
        -P|--printer)    printername="$2"; shift 2;;
        --) shift; break;;
        *) echo "$myname: Internal error: option \"$1\" read"; exit 1;;
    esac
done

if [ -n "$conftest" ]; then do_conftest; fi
# etc


If not using getopt, then at least do

for x in "$@"; do

instead of $*.


Chris

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Rosegarden-devel mailing list
[email protected] - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Reply via email to