Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14358 > unrolled thread
| Started by | Denys Vlasenko <dvlasenk@redhat.com> |
|---|---|
| First post | 2018-07-18 14:25 +0200 |
| Last post | 2018-07-18 14:25 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to gnu.bash.bug
Single quotes in ARG in "${v:+ARG}" are erroneously required to be paired Denys Vlasenko <dvlasenk@redhat.com> - 2018-07-18 14:25 +0200
| From | Denys Vlasenko <dvlasenk@redhat.com> |
|---|---|
| Date | 2018-07-18 14:25 +0200 |
| Subject | Single quotes in ARG in "${v:+ARG}" are erroneously required to be paired |
| Message-ID | <mailman.3754.1531916712.1292.bug-bash@gnu.org> |
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 top | Article view | gnu.bash.bug
csiph-web