ĺéăăăăŁă¨ăăŚăăăŽă§ăĄă˘
ăˇă§ăŤăšăŻăŞăăăăăăăŻé˘ć°ă§ĺźć°ăŤăŻ $1
, $2
, ... ă§ă˘ăŻăťăšă§ăă. $@
ăŤăăă¨ăăăăĺ
¨ăŚăé
ĺă¨ăăŚĺžăăă¨ăă§ăă. é
ĺăĺ㍠echo
ăăăă¨ăăăăă犺ç˝1ă¤ă§çľĺăăćĺĺăĺşĺăăăăŽă§ăĺŻĺ¤ć°ĺźć°ăç°ĄĺăŤćąăăŽăŤäžżĺŠ.
f() { echo $@ }
f 1 2 3
# => 1 2 3
ă¨ăăă§ăăŽäžă ă¨ăf()
ăŽä¸ă§ăŻ echo 1 2 3
ăĺŽčĄăăăŚăă. ă¤ăžă echo
ăłăăłăăŤĺźć°ă3ă¤ć¸Ąăăăă¨ăŤăŞăŁăŚăă.
$@
ă "$@"
ă¨ăăă°ă echo "1 2 3"
ă¨ăŞăŁăŚăĺźć°ă1ă¤ă ă渥ăăă¨ăŤăŞăă¨ćăŁăŚăăăăăăăŻčޤăă ăŁăăăă .
ĺźć°ăŽĺć° ($@
ăŽéˇă) 㯠$#
ă§ăă§ăăŻă§ăă.
f() {
echo "f-args ($#): $@"
}
ng() {
f "$@"
}
ok() {
A="$@"
f "$A"
}
ng a b # => f-args (2): a b
ok a b # => f-args (1): a b
ăăăŤăŻăŞăźăăźăˇă§ăłă§ćŹăŁăŚăăăăă$@
ăŤă˘ăŻăťăšăăă¨ĺćăŤĺąéăăăăăă. ä¸ăŽ ok
ăŻăăăăĺ¤ć°ăŤäťŁĺ
Ľăăăă¨ă§ăf
ăŽĺźć°ă $A
1ĺăŤăăŚă.