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

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



On Feb 4, 2015, at 12:42 PM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:

> I'm glad I've been disabused of any notion that consistency is something
> to be expected or even valued.

As others have opined, expecting "consistency" from any echo(1) is a bad
bet, and there are reasons why zsh's echo doesn't work the way you want
it to. Use printf(1).

> 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.

It "works" because the argument is actually a hyphen followed by
a space. That's why echo doesn't treat it specially. Use this to
print a hyphen:

    % echo - -

Or, again, use printf(1) if you're concerned at all about portability.

vq



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