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

Re: The "-" and "--" options (was Re: ${var:1:1:=y})



On 02/04/2015 09:10 AM, Bart Schaefer wrote:
On Feb 3, 10:44pm, Eric Cook wrote:
} Subject: Re: ${var:1:1:=y}
}
} On 02/03/2015 10:25 PM, Bart Schaefer wrote:
} >   All builtin commands other than precommand modifiers, even those that
} >   have no options, can be given the argument `--' to terminate option
} >   processing.  [...]  For historical reasons,
} >   most builtin commands also recognize a single `-' in a separate word
} printf , test/[, set -A and maybe a few others are exceptions to those
} rules.

Also "echo" does NOT accept "--" in this way, it ONLY acceps a solitary
"-".  I forget why that is.

printf : accepts -- but not -
test : accepts neither
set : the -A itself ends option processing, and "--" has added semantics

I'm glad I've been disabused of any notion that consistency is something
to be expected or even valued.  Anyway it seems that this makes it
difficult to echo a dash.  I'd have guessed that single quoting the
dash would work, but no luck, however:

    $ echo '- '

works, so that will do.




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