Created
November 13, 2015 23:42
-
-
Save jimjh/db8e72699670b57d207a to your computer and use it in GitHub Desktop.
Using $@ vs $*
This file contains 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 | |
# child.sh | |
# Prints all args. | |
while (( "$#" )); do | |
echo "arg: $1" | |
shift | |
done |
This file contains 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 | |
# parent.sh | |
# Usage: | |
# > ./parent.sh 0 'a b c' d e | |
echo '-- Using $* --' | |
./child.sh $* | |
echo '-- Using "$*" --' | |
./child.sh "$*" | |
echo '-- Using $@ --' | |
./child.sh $@ | |
echo '-- Using "$@" --' | |
./child.sh "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment