3
シェル:ifでパラメーター付きの関数を使用する
以下のコードを実行しようとしていますが、ifステートメントで関数を使用しようとすると、-bash: [: too many argumentsエラーが発生します。なぜそれが起こっているのですか? 前もって感謝します! notContainsElement () { local e match="$1" shift for e; do [[ "$e" == "$match" ]] && return 1; done return 0 } list=( "pears" "apples" "bananas" "oranges" ) blacklist=( "oranges" "apples" ) docheck=1 for fruit in "${list[@]}" do if [ notContainsElement "$fruit" "${blacklist[@]}" -a …