LoginSignup
8
8

More than 5 years have passed since last update.

$@ と "$@" の違い

Last updated at Posted at 2013-05-30

個人見解: 大半は "$@" にしておけば、期待する動作となる

#!/bin/bash
#
# $ dump-vars.sh [args]
#

function dump_vars() {
  while [[ "$1" ]]; do
    echo "'$1'"
    shift
  done
}

echo '#1'; dump_vars $@
echo
echo '#2'; dump_vars "$@"
$ ./dump-vars.sh a b c d
#1
'a'
'b'
'c'
'd'

#2
'a'
'b'
'c'
'd'
$ ./dump-vars.sh "a b" "c d"
#1
'a'
'b'
'c'
'd'

#2
'a b'
'c d'
8
8
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8