Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16644
| From | Eli Schwartz <eschwartz@archlinux.org> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: Bug Report concerning backslash in bash5 |
| Date | 2020-07-28 22:41 -0400 |
| Message-ID | <mailman.230.1595990545.2739.bug-bash@gnu.org> (permalink) |
| References | <87ft9azxwb.fsf@hobgoblin.ariadne.com> <4099319f-bc5e-a2ef-cfe8-6189df5a44b6@archlinux.org> |
[Multipart message — attachments visible in raw view] - view raw
On 7/29/20 1:35 AM, Dale R. Worley wrote: > Ralph Beckmann <rb@rbx.de> writes: >> I found this misbehaviour in Bash 5 (e.g. GNU bash, version >> 5.0.16(1)-release (x86_64-pc-linux-gnu)): >> >> $ BLA="1\.2"; echo 'x/'$BLA'/y/' >> \x/1\.2/\y/ >> >> I don't see any reasonable reason for the generated backslashes here. > > My guess is that you're running into the fact that there are two types > of quoting character. One quotes *any* character that follows it, and > thus it never appears in "the output" unless it was doubled in the > input. The other type *only* quotes characters that are somewhow > special in that particular context. Reading the manual page: > > Enclosing characters in double quotes preserves the literal value of > all characters within the quotes, with the exception of $, `, \, and, > when history expansion is enabled, !. The characters $ and ` retain > their special meaning within double quotes. The backslash retains its > special meaning only when followed by one of the following characters: > $, `, ", \, or <newline>. > > So backslash-inside-double-quotes-in-bash is of the second type, it only > quotes things that would otherwise be special. So the value of $BLA is > 1-\-.-2, whereas if the period was replaced by $, $BLA would only have 3 > characters: > > $ BLA="1\$2"; echo 'x/'$BLA'/y/' > x/1$2/y/ > I'm not sure what point you're trying to make here. Are you arguing that *printing* these backslash escapes is valid behavior here, and the reporter has merely misunderstood the shell rules? -- Eli Schwartz Arch Linux Bug Wrangler and Trusted User
Back to gnu.bash.bug | Previous | Next | Find similar
Re: Bug Report concerning backslash in bash5 Eli Schwartz <eschwartz@archlinux.org> - 2020-07-28 22:41 -0400
csiph-web