bug-bash
[Top][All Lists]
Advanced

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

Re: how to pass arguments with space inside?


From: Greg Wooledge
Subject: Re: how to pass arguments with space inside?
Date: Fri, 10 Apr 2009 10:22:51 -0400
User-agent: Mutt/1.4.2.2i

On Fri, Apr 10, 2009 at 12:02:56AM -0700, lehe wrote:
> The reason why I don't use "$@" is that the arguments to the bash script is
> not completely those for the executable. Some of them are just arguments
> only to the bash script. So actually the script is like

So you need to build up an *array* of your parameters, not a string.
What you are trying to do does not, and cannot, work.

> [code]
> #!/bin/bash
> ...
> ${DEBUGGER} my_executable ${ARG_OPTS}
> [/code]

You have built up a string.  There is no way to delimit individual
parameters inside a string other than whitespace, and when you need
whitespace *inside* one of those parameters, you're stuck.  You need
an array instead, as others have already told you.

[code]
#!/bin/bash
...
$DEBUGGER my_executable "${MY_ARRAY[@]}"
[/code]

See also:

http://mywiki.wooledge.org/BashFAQ/050 

  "I'm trying to put a command in a variable, but the complex cases 
  always fail!"

http://mywiki.wooledge.org/BashFAQ/005

  "How can I use array variables?"




reply via email to

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