bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: One cant insert a single quote into a variable with built-in substit


From: Matthew Woehlke
Subject: Re: One cant insert a single quote into a variable with built-in substitution.
Date: Fri, 01 Aug 2008 11:36:19 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.14) Gecko/20080501 Fedora/2.0.0.14-1.fc9 Thunderbird/2.0.0.14 Mnenhy/0.7.5.0

Damien Nadé wrote:
I've tried to insert a single quote into a variable content. With something like this :
bash-3.2$ foo=bar
bash-3.2$ echo "${foo/%/'}"
>
If you look at that, you understand that > is the $PS2, so it means that
bash is interpreting the single quote a special char.

So, naturally, I've told myself : "just escape it". And I've tried
that :

bash-3.2$ foo=bar
bash-3.2$ echo "${foo/%/\'}"
bar\'

But... what the hell ? The backslash belongs to the variable now ?
So, I cant use it "as is", and if I escape it, the command doesnt do
what I want anymore..

Is that some kind of bug in the parser ?

Hmm... that seems to be a good question. Meanwhile, you can do this:
$ foo=bar
$ q="'"
$ echo "${foo/%/$q}"
bar'

--
Matthew
FOSS: Giving people the cage and it's blueprints, gratis. The "L" matters.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]