* Bug related to single-quoting a String
@ 2020-04-08 10:39 Ronald Fischer
2020-04-08 10:45 ` Roman Perepelitsa
2020-04-08 10:45 ` Peter Stephenson
0 siblings, 2 replies; 6+ messages in thread
From: Ronald Fischer @ 2020-04-08 10:39 UTC (permalink / raw)
To: zsh-workers
What I want to report can be a bugh either in the documentaion (man-page) or in the implementation, depending on which one is correct.
I am running Zsh 5.5.1 for Cygwin (which seems to be the most recent one available for this platform).
In the man-page, it says in the chapter about single-quoting a string:
A literal ' character can be included in the string by using the \' escape.
Taken this at face value, the following should work:
echo 'a$b\'c'
However, if I enter this in an interactive shell, Zsh reminds me that a closing single quote would be missing. The behaviour is as if \' can **not** be used to place a single quote inside a string surrounded by single quotes.
Incidentally, this behaviour is consistent with bash and dash, and the bash man-page says explicitly, that \' is not an escape inside a single-quoted string. Hence, the implementation of zsh mimics in this respect to what bash and POSIX shell are doing.
I don't know, whether zsh was intended to behave in this way; if it is the case, the documentation is faulty. If the man page is considered right, the implementation is buggy.
(Crossposting note: I have discussed this issue at https://stackoverflow.com/questions/61095565/having-a-single-quote-inside-a-single-quoted-string?noredirect=1#comment108090871_61095565 - just in case you want to read the comments posted there, or also add something to that thread).
Ronald Fischer
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Bug related to single-quoting a String
2020-04-08 10:39 Bug related to single-quoting a String Ronald Fischer
@ 2020-04-08 10:45 ` Roman Perepelitsa
2020-04-08 10:52 ` Ronald Fischer
2020-04-08 10:45 ` Peter Stephenson
1 sibling, 1 reply; 6+ messages in thread
From: Roman Perepelitsa @ 2020-04-08 10:45 UTC (permalink / raw)
To: Ronald Fischer; +Cc: Zsh hackers list
On Wed, Apr 8, 2020 at 12:40 PM Ronald Fischer <ynnor@mm.st> wrote:
>
> What I want to report can be a bugh either in the documentaion (man-page) or in the implementation, depending on which one is correct.
>
> I am running Zsh 5.5.1 for Cygwin (which seems to be the most recent one available for this platform).
>
> In the man-page, it says in the chapter about single-quoting a string:
>
> A literal ' character can be included in the string by using the \' escape.
Here's the whole paragraph from which this quote is taken:
A string enclosed between '$'' and ''' is processed the same way as the
string arguments of the print builtin, and the resulting string is
considered to be entirely quoted. A literal ''' character can be
included in the string by using the '\'' escape.
It's talking about $'...'. Both the documentation and the
implementation are correct.
Roman.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Bug related to single-quoting a String
2020-04-08 10:39 Bug related to single-quoting a String Ronald Fischer
2020-04-08 10:45 ` Roman Perepelitsa
@ 2020-04-08 10:45 ` Peter Stephenson
2020-04-08 10:55 ` Ronald Fischer
1 sibling, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2020-04-08 10:45 UTC (permalink / raw)
To: Ronald Fischer, zsh-workers
> On 08 April 2020 at 11:39 Ronald Fischer <ynnor@mm.st> wrote:
> What I want to report can be a bugh either in the documentaion
> (man-page) or in the implementation, depending on which one is correct.
>
> I am running Zsh 5.5.1 for Cygwin (which seems to be the most recent one available for this platform).
>
> In the man-page, it says in the chapter about single-quoting a string:
>
> A literal ' character can be included in the string by using the \' escape.
>
> Taken this at face value, the following should work:
>
> echo 'a$b\'c'
I believe you're looking at the documentation for the $'...' style of quoting. So you can do
echo $'a$b\'c'
This style allows a bit more interpolation than ordinary single quotes.
pws
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Bug related to single-quoting a String
2020-04-08 10:45 ` Roman Perepelitsa
@ 2020-04-08 10:52 ` Ronald Fischer
0 siblings, 0 replies; 6+ messages in thread
From: Ronald Fischer @ 2020-04-08 10:52 UTC (permalink / raw)
To: Roman Perepelitsa; +Cc: Zsh hackers list
On Wed, Apr 8, 2020, at 12:45, Roman Perepelitsa wrote:
> On Wed, Apr 8, 2020 at 12:40 PM Ronald Fischer <ynnor@mm.st> wrote:
> >
> > What I want to report can be a bugh either in the documentaion (man-page) or in the implementation, depending on which one is correct.
> >
> > I am running Zsh 5.5.1 for Cygwin (which seems to be the most recent one available for this platform).
> >
> > In the man-page, it says in the chapter about single-quoting a string:
> >
> > A literal ' character can be included in the string by using the \' escape.
>
> Here's the whole paragraph from which this quote is taken:
>
> A string enclosed between '$'' and ''' is processed the same way as the
> string arguments of the print builtin, and the resulting string is
> considered to be entirely quoted. A literal ''' character can be
> included in the string by using the '\'' escape.
>
> It's talking about $'...'. Both the documentation and the
> implementation are correct.
However, if I do a
echo $'a$b\'c'
it does not work either. Same effect!
Ronald
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Bug related to single-quoting a String
2020-04-08 10:45 ` Peter Stephenson
@ 2020-04-08 10:55 ` Ronald Fischer
2020-04-08 11:00 ` Roman Perepelitsa
0 siblings, 1 reply; 6+ messages in thread
From: Ronald Fischer @ 2020-04-08 10:55 UTC (permalink / raw)
To: Peter Stephenson, zsh-workers
> echo $'a$b\'c'
>
> This style allows a bit more interpolation than ordinary single quotes.
My mistake: When I tried this first, it did not work, but I see that I had a typing error. I can get it working now.
Ronald
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Bug related to single-quoting a String
2020-04-08 10:55 ` Ronald Fischer
@ 2020-04-08 11:00 ` Roman Perepelitsa
0 siblings, 0 replies; 6+ messages in thread
From: Roman Perepelitsa @ 2020-04-08 11:00 UTC (permalink / raw)
To: Ronald Fischer; +Cc: Peter Stephenson, Zsh hackers list
On Wed, Apr 8, 2020 at 12:56 PM Ronald Fischer <ynnor@mm.st> wrote:
>
> > echo $'a$b\'c'
> >
> > This style allows a bit more interpolation than ordinary single quotes.
>
> My mistake: When I tried this first, it did not work, but I see that I had a typing error. I can get it working now.
I just tried it on the same system you are using just to be sure there
wasn't a bug back then. Works fine.
zsh -f <<\END
typeset -p ZSH_VERSION
uname -sm
echo $'a$b\'c'
END
Output:
typeset ZSH_VERSION=5.5.1
CYGWIN_NT-10.0 x86_64
a$b'c
This works the same way as in Bash, by the way.
Roman.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-04-08 11:01 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-08 10:39 Bug related to single-quoting a String Ronald Fischer
2020-04-08 10:45 ` Roman Perepelitsa
2020-04-08 10:52 ` Ronald Fischer
2020-04-08 10:45 ` Peter Stephenson
2020-04-08 10:55 ` Ronald Fischer
2020-04-08 11:00 ` Roman Perepelitsa
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).