Ticket #36278

\" within backquotes within double-quotes treated differently from other shells

Open Date: 2016-04-24 13:52 Last Update: 2016-07-24 11:04

Reporter:
Owner:
Type:
Status:
Closed
Component:
MileStone:
(None)
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
Fixed
File:
None
Vote
Score: 0
No votes
0.0% (0/0)
0.0% (0/0)

Details

Yash produces @"abc"@ for the command:

echo "@` echo \"abc\" `@"

but many other shells (bash, ksh, mksh, dash, zsh as sh) produce @abc@.

I suppose POSIX 2013 is rather ambiguous whether such backslashes should be treated as an escaping character.

XCU 2.2.3 says:

The <backslash> shall retain its special meaning as an escape character only when followed by one of the following characters when considered special: <dollar> <backquote> <double-quote> <backslash> <newline>

while XCU 2.6.3 says:

Within the backquoted style of command substitution, <backslash> shall retain its literal meaning, except when followed by: <dollar>, <backquote>, or <backslash>.

Which should be applied in this case?

Ticket History (3/4 Histories)

2016-04-24 13:52 Updated by: magicant
  • New Ticket "\" within backquotes within double-quotes treated differently from other shells" created
2016-07-16 22:52 Updated by: magicant
Comment
echo @` echo "abc" `@
echo @` echo \"abc\" `@
echo "@` echo "abc" `@"
echo "@` echo \"abc\" `@" # !!!
echo @` echo 'abc' `@
echo @` echo \'abc\' `@
echo "@` echo 'abc' `@"
echo "@` echo \'abc\' `@"

Yash's output differs from other shells for the 4th line only.

2016-07-17 00:53 Updated by: magicant
Comment

Other shells' behavior suggests XCU 2.6.3 to be applied to backquotes not enclosed in double quotes while XCU 2.2.3 applies to backquotes in double quotes.

XCU 2.6.3 implies that line continuations in backquotes not enclosed in double quotes are not handled when the command substitution is parsed. They should be handled when the command is parsed while the command substitution is evaluated. However, existing shells (including yash) handle the line continuations when the command substitution is parsed...

echo `echo 'a\
b'`
2016-07-24 11:04 Updated by: magicant
  • Resolution Update from None to Fixed
  • Status Update from Open to Closed
  • Ticket Close date is changed to 2016-07-24 11:04
Comment

Fixed in r3639 for the backslash/double quote pair. Line continuation is still processed following the behavior of other shells.

Attachment File List

No attachments

Edit

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Login