I've run into a problem while trying to migrate a ton of Solaris ksh scripts to linux... I have a line like this:
/path/to/script -a $arga -b $argb -c "$arg1 $arg2"
Problem is, for some reason what the second script receives is:
/path/to/script -a $arga -b $argb -c "value_of_arg1" "value_of_arg2"
I've been able to work around it by doing something like this:
newarg="$arg1 $arg2" /path/to/script -a $arga -b $argb -c "$newarg"
Why does this happen? I've tried many combinations of quotes and escaping quotes...this is the only workaround I came up with. Unfortunately I have another script where this is causing an issue and it is not fixable by this same workaround. Can this behavior be turned off somehow?
EDIT I guess I didn't explain it well enough... I'm calling a KSH script from another KSH script. I need an argument to have two parameters. I.E. -c "Parameter1 Parameter2"...so that when I process the arguments the string "Parameter1 Parameter2" is associated with -c
So when I try this line in the first script to call the second script:
/path/to/script -a $arga -b $argb -c "$arg1 $arg2"
It puts quotes around arg1 and 2 for some reason I can't figure out...so essentially the string that calls the second script looks like this...I have verified this with -x:
/path/to/script -a $arga -b $argb -c "$arg1" "$arg2"
This is bad because when I process the arguments only the first arg is associated with -c and arg2 is not.
[link] [6 comments]