파라미터 중 앞 몇 개를 체크 후 나머지를 전달하고 싶을 때 shift 로 제거 후 $@ 으로 전달하면 된다.

function build() {
    echo "build with $@"
}

echo "Starting args are $@"
cmd=$1
shift

if [ "$cmd" = 'build' ]; then
    build "$@"
fi

출처 : https://stackoverflow.com/questions/12002954/bourne-shell-send-arguments-2-to-n-to-variadic-function

728x90

+ Recent posts