From: Peter Stephenson <pws@csr.com>
To: zsh-users@sunsite.dk (Zsh users list)
Subject: Re: POSIX compliance of shells - where to ask/talk about it?
Date: Tue, 30 Jul 2002 12:17:22 +0100 [thread overview]
Message-ID: <10526.1028027842@csr.com> (raw)
In-Reply-To: "Ian Lynagh"'s message of "Thu, 25 Jul 2002 21:17:13 BST." <20020725201713.GA17071@stu163.keble.ox.ac.uk>
Sorry for the late reply... we've been implementing scatternets :-/ and
it's been too hot to stay at home and stare at a computer at the weekend.
(Yes, it's now raining again. Oh, and the power's just gone down, so
everybody else has gone for lunch, so I might as well finish this...)
Here is Your Handy Cut-Out-'N'-Keep Guide To Backslashing In Zsh.
Ian Lynagh wrote:
> Hi all,
>
> Where should one ask/talk about POSIX shell compliance (looking for a
> mailing list probably)?
You're probably not going to find anything better than one of the Open
Group mailing lists, if you want the people that define the spec. The
Austin Group is the one responsible for tinkering with Posix and other
associated standards, including the shell specification.
> printf "%s\n" `echo '\\\\\\\\\\\\\\\\'`
> printf "%s\n" "`echo '\\\\\\\\\\\\\\\\'`"
>
> ...
>
> Using shells/zsh [invoked as sh]:
> \\\\
> \\\\\\\\
There are various things going on here; in particular, both of the
options BSD_ECHO and SH_GLOB are set for Bourne shell emulation.
Here is standard zsh as a baseline:
\\\\
\\\\
The number of backslashes has been halved twice, once by the original
parsing of the backquoted expression, once by `echo' (not by the printf
"%s", of course). The former happens because inside backquotes you can
quote backquotes, so backslashes are active. Compare with:
% printf "%s\n" $(echo '\\\\\\\\\\\\\\\\\')
\\\\\\\\\
Since $(...) is terminated by a parenthesis, and the parenthesis is a
standard terminator character in the shell (compare subshells with
`(...)'), no backslash-stripping happens inside; the only layer of
stripping is due to the echo. This distinction appears to be in bash,
too.
BSD_ECHO turns off the feature that the echo builtin (but not the print
or printf builtins) interpret backslashes. This doubles the number you
get back from the original commands:
\\\\\\\\
\\\\\\\\
I think this is probably responsible for the other differences you saw,
between bash and ash; it's certainly the difference between bash and
the Solaris 8 system here's sh, since I've just tried
echo '\\\\\\\\\\\\\\\\'
on both and only sh halves the backquotes. This makes sense since the
sh in this case is presumably of AT&T SYSV ancestry (the Solaris people
can correct me if I'm wrong), hence doesn't have a BSD-like echo;
/bin/echo is similar.
The option SH_GLOB makes characters which are substituted by a parameter
or command substitution elegible for further interpretation, providing
the substitution was not quoted. In zsh, that means the number of \'s
returned when the `...` is not quoted is halved, but inside double
quotes it isn't. This gives what you observed, viz.
\\\\
\\\\\\\\
This is definitely all a bit of a mess. I suspect the last feature can
be regarded as a bug. The unfortunate fact that other shells think it's
a good idea for text from parameter and command substitutions to be
processed further as patterns etc. has given no end of trouble in zsh,
and the SH_GLOB and SH_WORD_SPLIT options still don't emulate that
behaviour (which, as far as I can tell, none of the current bunch of
developers really like) properly.
Maybe that :-/ should have been :-\.
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 392070
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
next prev parent reply other threads:[~2002-07-30 11:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-25 20:17 Ian Lynagh
2002-07-26 18:12 ` Andreas Schwab
2002-07-30 11:17 ` Peter Stephenson [this message]
2002-07-30 12:06 ` Oliver Kiddle
2002-07-30 12:48 ` Peter Stephenson
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=10526.1028027842@csr.com \
--to=pws@csr.com \
--cc=zsh-users@sunsite.dk \
/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).