ash syntax error in nested case ... esac
Paul Fox
pgf at brightstareng.com
Sun Oct 7 15:49:28 UTC 2007
>
> Is there something wrong with the 'while' loop?
the problem is in your echo statements. see below.
>
> #!/bin/sh
>
> GETOPT=$(getopt -o ab:c:: -l a-long,b-long:,c-long:: -n 'example.busybox' -- "$@")
> [ $? == 0 ] || exit 1
> eval set -- "$GETOPT"
> while true ; do
> case $1 in
> -a|--a-long) echo "Option a" ; shift ;;
> -b|--b-long) echo "Option b, argument `$2'" ; shift 2 ;;
------------------------------------------------------^
the ` character starts a shell inline expansion. change it to '
> -c|--c-long)
> case "$2" in
> "") echo "Option c, no argument"; shift 2 ;;
> *) echo "Option c, argument `$2'" ; shift 2 ;;
same here----------------------------------------------------^
> esac ;;
> --) shift ; break ;;
> *) echo "Internal error!" ; exit 1 ;;
> esac
> done
[ btw, this is an excellent example of a place where debugging
was greatly sped up by using an editor with shell syntax
coloring. the odd colors in your script were immediately
apparent. (i use vile. i assume vim and emacs would be helpful
as well.) ]
paul
=---------------------
paul fox, pgf at brightstareng.com
More information about the busybox
mailing list