I've got a sticky little problem with a bash script. Please consider the following code:
Code:
#! /bin/bash
processArgs() {
echo "Count = $#"
while [[ $# -ne 0 ]]; do
echo $1
shift
done
}
processArgs $*
If I call this script with
Code:
./script first second third
it'll print each of the argument on a new line - exactly what I would expect. However if I call it with
Code:
./script "Single Argument" "Second-Argument"
it splits the first argument in two using the space as a delimitor.
The problem appears to be the call to processArgs, where $* doesn't honour the quotes around the variables sent to the script.
Any ideas how to get around this?