|
From: | Chris F.A. Johnson |
Subject: | Re: how to pass arguments with space inside? |
Date: | Sat, 11 Apr 2009 04:49:33 -0400 (EDT) |
User-agent: | Alpine 1.00 (LRH 882 2007-12-20) |
On Fri, 10 Apr 2009, Greg Wooledge wrote:
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 likeSo 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.
No, it is quite easy without arrays, but not *as* simple. If you build the strings with a character that is not in the arguments as a delimiter. The OP doesn't seem able to grasp either arrays or the meaning of top posting.
[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?"
-- Chris F.A. Johnson, webmaster <http://woodbine-gerrard.com> ========= Do not reply to the From: address; use Reply-To: ======== Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
[Prev in Thread] | Current Thread | [Next in Thread] |