PLEX86  x86- Virtual Machine (VM) Program
 Plex86  |  CVS  |  Mailing List  |  Download  |  Linux  |  Newsgroups

iterating over bash script params, preserving whitespace 7261


Your Ad Here

Your Ad Here

On Mon, 19 Dec 2005 17:42:34 +0000, Jules hmmm, further to this though, how do I handle pbutting parameters that need to be quoted when calling from another script? say I've got a script ('t.sh') containing the following: #!-bin-sh echo first is $1 echo second is $2 echo third is $3 ... and I call it from a script such as the following: #!-bin-sh params='"1st param" "2nd"' echo ${params} t.sh ${params} ... then I'll see the parameters quoted in the echo statement in the first script, but the second script will see three parameters, split at whitespace, and with the quote characters included as part of the parameter data. (if I just invoke t.sh from the login shell with quotes around the parameters then I see the quoting working as expected) Is there any way for my first script to call t.sh and pbutt the parameters correctly, so that the quotes are treated as parameter boundaries - rather than being treated as literal characters? (unfortunately for what I'm trying to do I need to call t.sh with a variable number of parameters - so I can't quote them at the point that t.sh is called but instead need to build them up into an argument list first)

You may be able to use the 'set' command in sh-bash-ksh to setup the $1, $2, ... ${99} variables, just like command line arguments, then use

Just be careful of the quoting in the set command.

Here is an example from the bash command prompt:

Linux on my DVD player
Mike Matthews It's probably a *very* minimal CPU running the DVD player in conjunction with a DSP chip...

$ set "first" 'second parameter' 'This is third' forth

first second parameter This is third forth

iterating over bash script params, preserving whitespace 7262
On Mon, 19 Dec 2005 23:19:04 +0000, Paul Colquhoun thanks - I'll give that one a try. My other thought is to use some non-space character to indicate space, but escape any legitimate...

first second parameter This is third forth

-- Asking for technical help in newsgroups? Read this first:



Your Ad Here

List | Previous | Next

iterating over bash script params, preserving whitespace 7262

Linux groups from Newsgroups

The #1 Usenet Provider on the Internet

iterating over bash script params, preserving whitespace 7260