Last active
August 23, 2017 10:48
-
-
Save hraban/3980d73ac78dfdc0f9112b6e6dfd39a2 to your computer and use it in GitHub Desktop.
(bash) Comparing $* and $@
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ /tmp/test.sh | |
$*: [] | |
"$*": [''] | |
$@: [] | |
"$@": [] | |
$ /tmp/test.sh a b "c d" | |
$*: ['a', 'b', 'c', 'd'] | |
"$*": ['a b c d'] | |
$@: ['a', 'b', 'c', 'd'] | |
"$@": ['a', 'b', 'c d'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo -n '$*: '; | |
python -c 'print __import__("sys").argv[1:]' $* | |
echo -n '"$*": '; | |
python -c 'print __import__("sys").argv[1:]' "$*" | |
echo -n '$@: '; | |
python -c 'print __import__("sys").argv[1:]' $@ | |
echo -n '"$@": '; | |
python -c 'print __import__("sys").argv[1:]' "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment