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

Bug related to single-quoting a String



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



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