zsh-users
 help / color / mirror / code / Atom feed
From: Kurtis Rader <krader@skepticism.us>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: "Lawrence Velázquez" <vq@larryv.me>, "Zsh Users" <zsh-users@zsh.org>
Subject: Re: The "-" and "--" options (was Re: ${var:1:1:=y})
Date: Wed, 4 Feb 2015 17:52:50 -0800	[thread overview]
Message-ID: <CABx2=D_iJPpNbpj1N4CfpxVMm6ouaQDdAyK2=CpwD-m760ay=A@mail.gmail.com> (raw)
In-Reply-To: <54D2C805.9020906@eastlink.ca>

[-- Attachment #1: Type: text/plain, Size: 1471 bytes --]

On Wed, Feb 4, 2015 at 5:31 PM, Ray Andrews <rayandrews@eastlink.ca> wrote:

> On 02/04/2015 03:47 PM, Lawrence Velázquez wrote:
>
>> % echo - -
>>
> Ok, the first hyphen gets eaten, and the next one is literal. Still,
> shouldn't
> single quotes make anything inside them literal?
>

The single-quotes simply inhibit the shell from performing any
substitutions (e.g., of $var references) inside the quoted string. The
quotes also inhibit splitting the string on $IFS boundaries; i.e., the
shell will pass the resulting string as a single argument to the command.
The echo command simply gets a hyphen whether or not you quoted it. The
echo command has no way of knowing that it was originally enclosed in
single-quotes.

Ignore for the moment that echo might be a shell builtin. Assume it isn't
and the shell has to search $PATH and invoke the first external command of
that name it finds. You certainly don't want the shell to pass '-' to
/bin/echo. If that was done then every external command would need to
implement the same string parsing that the shell already does. And that way
lie madness. In fact, Microsoft Windows works that way. Or at least it did
back in the MS-DOS through Win98  releases. External commands got a single
string representing all the arguments and it was up to the command to split
the string into tokens and handle any quoting. Ugh!


-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

  reply	other threads:[~2015-02-05  1:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-03 23:12 ${var:1:1:=y} Ray Andrews
2015-02-04  0:18 ` ${var:1:1:=y} Lawrence Velázquez
2015-02-04  0:39   ` ${var:1:1:=y} Ray Andrews
2015-02-04  1:30     ` ${var:1:1:=y} Lawrence Velázquez
2015-02-04  3:25       ` ${var:1:1:=y} Bart Schaefer
2015-02-04  3:44         ` ${var:1:1:=y} Eric Cook
2015-02-04 17:10           ` The "-" and "--" options (was Re: ${var:1:1:=y}) Bart Schaefer
2015-02-04 17:42             ` Ray Andrews
2015-02-04 23:47               ` Lawrence Velázquez
2015-02-05  1:31                 ` Ray Andrews
2015-02-05  1:52                   ` Kurtis Rader [this message]
2015-02-05  2:03                     ` Ray Andrews
2015-02-05  2:24               ` Bart Schaefer
2015-02-04 19:02             ` Peter Stephenson
2015-02-04 19:53               ` ZyX
2015-02-04  5:16         ` ${var:1:1:=y} Ray Andrews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABx2=D_iJPpNbpj1N4CfpxVMm6ouaQDdAyK2=CpwD-m760ay=A@mail.gmail.com' \
    --to=krader@skepticism.us \
    --cc=rayandrews@eastlink.ca \
    --cc=vq@larryv.me \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).