Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14358

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

From Denys Vlasenko <dvlasenk@redhat.com>
Newsgroups gnu.bash.bug
Subject Single quotes in ARG in "${v:+ARG}" are erroneously required to be paired
Date 2018-07-18 14:25 +0200
Message-ID <mailman.3754.1531916712.1292.bug-bash@gnu.org> (permalink)

Show all headers | View raw


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.

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Single quotes in ARG in "${v:+ARG}" are erroneously required to be paired Denys Vlasenko <dvlasenk@redhat.com> - 2018-07-18 14:25 +0200

csiph-web