[PLUG] BASHing my head on the keys.

Brian Beattie beattie at beattie-home.net
Thu Jan 22 06:12:01 UTC 2004


On Thu, 2004-01-22 at 08:46, Jeme A Brelin wrote:
> Stupid freakin' bash question that I'm too tired to answer for myself at
> the moment:
> 
> How do I call a variable that may have oogy characters in it so that it is
> passed as a single argument to my calling program without going through
> and specially escaping all the spaces and ticks and stuff?
> 
> `command $filename` substitutes first and then runs the command so your
> spaces seem to separate arguments and so on.  That's very clear and
> obvious... but `command "$filename" doesn't seem to do what I want,
> either, though to my mind it should (and the when I just echo the command
> instead of running it, I get what I'd like to see).
> 
> Gaaaah.

Double quotes, i.e. ", they prevent special character expansion, but not
variable expansion (yeah I know there is a contradiction there)


# foo="bing bar"
# `cat "$foo"`
cat: bing bar: No such file or directory
# `cat $foo`
cat: bing: No such file or directory
cat: bar: No such file or directory


> 
> J.
-- 
Brian Beattie            | Experienced kernel hacker/embedded systems
beattie at beattie-home.net | programmer, direct or contract, short or
www.beattie-home.net     | long term, available immediately.

"Honor isn't about making the right choices.
It's about dealing with the consequences." -- Midori Koto






More information about the PLUG mailing list