Reputation: 367
I'm having a little issue with a script I'm writing... let's say I have 2 functions :
function foo1 {
while [ $# -gt 0 ]; do
echo $1
shift
done
}
function foo2 {
foo1 $@
}
My problem is the following. If I do foo1 -o "file with space.txt"
output is
-o
file with space.txt
But with foo2 -o "file with space.txt"
or foo2 -o file\ with\ space.txt
, I get
-o
file
with
space.txt
Is there any way that foo1 receives "file with space.txt" from foo2 ?
Upvotes: 0
Views: 69
Reputation: 241748
In function foo2, use double quotes:
foo1 "$@"
See man bash
for details:
When the expansion occurs within double quotes, each parameter expands to a separate word. That is, "$@" is equivalent to "$1" "$2"
Upvotes: 5