According to http://tldp.org/LDP/abs/html/quotingvar.html
Use double quotation marks to prevent word breaks. The argument enclosed in double quotation marks is a single word, even if it contains space delimiters.
However i have
0> /bin/bash --version
GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
[...]
1> cat inspect.sh
#!/bin/bash
echo "first argument is $1"
echo "second argument is $2"
2> cat test.sh
#!/bin/bash
set -x
./inspect.sh "hello $@"
3> ./test.sh alice bob
+ ./inspect.sh 'hello alice' bob
first argument is hello alice
second argument is bob
4> ./test.sh "alice bob"
+ ./inspect.sh 'hello alice bob'
first argument is hello alice bob
second argument is
I am wondering why 3> and 4> have different results? How to change test.sh so that 3> have the same result as 4>?
source
share