bug-bash
[Top][All Lists]
Advanced

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

One cant insert a single quote into a variable with built-in substitutio


From: Damien Nadé
Subject: One cant insert a single quote into a variable with built-in substitution.
Date: Thu, 31 Jul 2008 16:31:55 +0200

        Hello

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 ?

I've tested that on my fedora 9, with a brand new :
GNU bash, version 3.2.33(1)-release (x86_64-redhat-linux-gnu)

But the same behaviour happens on an old old debian sarge with 
GNU bash, version 2.05b.0(1)-release (x86_64-pc-linux-gnu)

        D

-- 
Damien Nadé <address@hidden>
Tel : +33 (0) 4 93 16 88 24
GPG Key ID : 8E279021






reply via email to

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