bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Single quotes in ARG in "${v:+ARG}" are erroneously required to be paire


From: Denys Vlasenko
Subject: Single quotes in ARG in "${v:+ARG}" are erroneously required to be paired
Date: Wed, 18 Jul 2018 14:25:03 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

Unquoted ${v:+ARG} operator allows single-quoted strings
in ARG:

$ x=a; echo ${x:+'b c'}
b c

In this case, obviously single quotes must be paired.

If ${v:+ARG} is in double-quoted string, single quotes lose their special 
status:

$ x=a; echo "${x:+'b c'}"
'b c'

IOW: they work similarly to ordinary dquoted strings: echo "It's sunny"
treats single quote as ordinary char.

However, bash errors out if they are not paired:

$ x=a; echo "${x:+'b c}"
         <------------- bash thinks 'str' did not end yet

Most other shells - dash, mksh, busybox ash, posh, bosh -
do not require paired single quotes in this case:

$ dash
$ x=a; echo "${x:+'b c}"
'b c

From all tested shells, only yash behaves like bash.

I think it's a bug.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]