On Tue, Apr 26, 2011 at 12:41:49PM -0400, Steven W. Orr wrote:
> >>It turns out that when I
> >>called getopts, I had set IFS='-'.

I assume you mean "when I called die".

> die()
> {
>     typeset opt
>     typeset opt_s=1
>     typeset opt_i=0
>     typeset err_opts=
>     OPTIND=1
>     while getopts ':is:' opt "$@"
>     do
>         case $opt in
>         i)
>             opt_i=1
>             err_opts='-i'
>             ;;
>         s)
>             opt_s=$OPTARG
>             ;;
>         *)
>             err "Illegal option to die: ${@:((OPTIND-1)):1}"
>             exit 1
>             ;;
>         esac
>     done
>     shift $((OPTIND-1))
>     err $err_opts -- "$@"
>     exit $opt_s
> }

You have an unquoted $err_opts in this function, so IFS will certainly
affect that.

Let's suppose you are trying to end up with:

err_opts='-i'
...
err -i -- "$@"

But:

imadev:~$ IFS=-
imadev:~$ err_opts='-i'
imadev:~$ echo $err_opts
 i

Reply via email to