Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: getopts behaviour on `-'



Peter Stephenson <pws@xxxxxxx> wrote:
>It seems a little strange that getopts doesn't treat a `-' argument the
>same way as `--', which is what builtins do.

I know you already found that the current behaviour is consistant with
other shells, but you might want a bit more explaination as why it shouldn't
be ignored.

Note the behavior of certain commands when a lone dash is used as an
argument.  As a useless example, try:

    uname -a | cat -n /etc/resolv.conf - /etc/zshenv
    uname -a | cat -n - /etc/resolv.conf /etc/zshenv

And see the output.  '-' is traditionally synonymous with STDIN.  Since
getopts exists to enable consistant option parsing, you need to be able to
use getopts to work with the same option sets you might use in the more
traditional commands.


-philip

-- 
Philip Kizer, Senior Lead Systems Engineer, Texas A&M University
Texas A&M CIS Operating Systems Group, Unix   <pckizer@xxxxxxxx>



Messages sorted by: Reverse Date, Date, Thread, Author