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


Groups > gnu.bash.bug > #16643

Re: Bug Report concerning backslash in bash5

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From worley@alum.mit.edu (Dale R. Worley)
Newsgroups gnu.bash.bug
Subject Re: Bug Report concerning backslash in bash5
Date Wed, 29 Jul 2020 01:35:32 -0400
Lines 32
Approved bug-bash@gnu.org
Message-ID <mailman.227.1595986568.2739.bug-bash@gnu.org> (permalink)
References <15dff7a7b42bf7192b57066215723128@rbx.de> <87ft9azxwb.fsf@hobgoblin.ariadne.com>
NNTP-Posting-Host lists.gnu.org
X-Trace usenet.stanford.edu 1595986569 14319 209.51.188.17 (29 Jul 2020 01:36:09 GMT)
X-Complaints-To action@cs.stanford.edu
Cc bug-bash@gnu.org
To Ralph.Beckmann@rbx.de
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcastmailservice.net; s=20180828_2048; t=1595986559; bh=XS6rFxunqC8IbSles1fvOGOoc+CPJL+cPxOEXzSqwmk=; h=Received:Received:Received:Received:From:To:Subject:Date: Message-ID; b=HadR70Xqn+5LfpmdlVx5Z6NeVGqHO9jD+6+u4evArcXDCoa4r7eAgZpNAi3p+yA9P Cs/KdRaa5/IBIuM7Ivh5amkPuzGUjxcMj0GQSazbkc6Ikrp/O3R1DDHuH7rzlGb+zm mRXTjEFdYhlQ5u+z2pGttfy2QkoBd4C+wvmf0XGiOqrEMV9YY1IZtW76JBEL87dzDs Zn97+kQl8hkrd5cPMn5qz5dCEvRe+bkjLoJbi12fnZhPv4piMYCjtCfUz7erNZ9DmZ 8mbQt3gOyPq8EhSm5ENR7y5yUHQZyo3s0qJUL+OmSEkO6Cc75wmoG+/4A4WkQkrFqp nh9PVKa2E5LsQ==
X-Xfinity-VMeta sc=0.00;st=legit
X-Authentication-Warning hobgoblin.ariadne.com: worley set sender to worley@alum.mit.edu using -f
In-Reply-To <15dff7a7b42bf7192b57066215723128@rbx.de>
Received-SPF softfail client-ip=2001:558:fe21:29:69:252:207:41; envelope-from=worley@alum.mit.edu; helo=resqmta-ch2-09v.sys.comcast.net
X-detected-operating-system by eggs.gnu.org: First seen = 2020/07/28 21:35:59
X-ACL-Warn Detected OS = ???
X-Spam_score_int -11
X-Spam_score -1.2
X-Spam_bar -
X-Spam_report (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665, URIBL_BLOCKED=0.001 autolearn=no autolearn_force=no
X-Spam_action no action
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <87ft9azxwb.fsf@hobgoblin.ariadne.com>
Xref csiph.com gnu.bash.bug:16643

Show key headers only | View raw


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/

Dale

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


Thread

Re: Bug Report concerning backslash in bash5 worley@alum.mit.edu (Dale R. Worley) - 2020-07-29 01:35 -0400

csiph-web