Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16005
| From | Robert Elz <kre@munnari.OZ.AU> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: Assign Default Value expansion inserts ASCII DEL for empty 'word' |
| Date | 2020-03-10 12:16 +0700 |
| Message-ID | <mailman.2377.1583817423.2412.bug-bash@gnu.org> (permalink) |
| References | <5ad25080-7c13-9b9c-cff6-12ffee7afeb8@uni-bremen.de> <7846.1583817393@jinx.noi.kre.to> |
Date: Mon, 9 Mar 2020 20:28:30 +0059.55
From: Martin Castillo <castilma@uni-bremen.de>
Message-ID: <5ad25080-7c13-9b9c-cff6-12ffee7afeb8@uni-bremen.de>
| Repeat-By:
| $ unset foo bar
| $ echo "${foo:=}/baz:${foo}/bat"|xxd
| 00000000: 7f2f 6261 7a3a 2f62 6174 0a ./baz:/bat.
| $ echo "${foo:=$bar}/baz:${foo}/bat"|xxd
| 00000000: 7f2f 6261 7a3a 2f62 6174 0a ./baz:/bat.
Your tests are overly complex, and arguably stretch into unspecified
behaviour (not that that should have any bearing on this).
The problem occurs to happen when (and only when) a empty "default"
value is assigned to a variable which is (within the same quoted string)
concatenated with some non-empty text (before or after).
So
"${foo:=}y"
or
"x${foo:=}"
or
"x${foo:=}y"
but not for any of
"${foo:=}"
x"${foo:=}"
"${foo:=}"y
x${foo:=}
(etc). It is irrelevant whether the x & y here are literals, or the
results of expansions, provided that there is actual data, that is
x= ; echo "${x}${foo:=}"
works
x=x ; echo ${x}${foo:=}"
inserts the DEL as the value of ${foo:=}
kre
Back to gnu.bash.bug | Previous | Next | Find similar
Re: Assign Default Value expansion inserts ASCII DEL for empty 'word' Robert Elz <kre@munnari.OZ.AU> - 2020-03-10 12:16 +0700
csiph-web