Re: bash variables
On Sun, Feb 27, 2011 at 12:45:27PM -0600, Boyd Stephen Smith Jr. wrote:
> In <[🔎] 20110225222127.GA1996@playground>, Mike McClain wrote:
> >This only bites me once in a while but when it does it can be very
> >frustrating so any hints / tips are welcome.
>
> FOO="stuff 'with' qu\"otes"
> echo $FOO
> echo stuff 'with' qu\"otes
>
> Yes, quote removal happens after parameter expansion, but it only removes
> quotes that existed before expansion. So, your find and grep are choking on
> quotes.
Yes, I'm afraid you're right, they do choke on quotes,
too many it appears.
root@/deb40a:~> set -x
root@/deb40a:~> VAR='boo "*"'; echo $VAR
+ VAR=boo "*"
+ echo boo '"*"'
boo "*"
root@/deb40a:~> VAR="boo '*'"; echo $VAR
+ VAR=boo '*'
+ echo boo ''\''*'\'''
boo '*'
root@/deb40a:~> FIND='-name "*"'; echo $FIND; find /root/bin/ $FIND
+ FIND=-name "*"
+ echo -name '"*"'
-name "*"
+ find -name '"*"'
/root/bin/"foo"
root@/deb40a:~> find /root/bin/ -name "*"
+ find /root/bin/ -name '*'
and a list of 28 files follows including /root/bin/"foo"
Any idea why bash would put extra quotes around a quoted term
in a variable upon expansion?
Or under what circumstances it might be useful?
Thanks,
Mike
--
Satisfied user of Linux since 1997.
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
Reply to: