bug-bash
[Top][All Lists]
Advanced

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

Weird quoting issue with spaces


From: Brian J. Murrell
Subject: Weird quoting issue with spaces
Date: 07 Apr 2004 10:36:27 -0400

Hello,

I am hoping you can help with a weird quoting issue.

I have the following script:

        opt_arg="opt arg"
        opt="--opt \"$opt_arg\""
        
        a_command $opt

What I would like to have happen is that bash executes:

a_command --opt "opt arg"

Which is the command "a_command" with the switch "--opt" and the
argument "opt arg" (with a space in it).  But what actually happens is:

$ bash -x /tmp/foo
+ opt_arg=opt arg
+ opt=--opt "opt arg"
+ a_command --opt '"opt' 'arg"'

Which is really the command "a_command" with the switch "--opt" and two
arguments ""opt" and "arg"".

How do I construct my variable substitution of $opt_arg into $opt so
that the space is preserved in one argument?

Thanx,
b.






reply via email to

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