Ifステートメントが期待どおりに評価されない。
ShellCheckを使用してスクリプトをチェックすると(シェルスクリプトのバグが検出されます)、次の提案が得られます。
$ shellcheck myscript
Line 1:
check=$(lynx -source $1 | grep -i $2)
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2086: Double quote to prevent globbing and word splitting.
Line 5:
/usr/local/bin/sendemail -o tls=yes -f ***@gmail.com -t\
^-- SC2035: Use ./*glob* or -- *glob* so names with dashes won't become options.
Line 6:
trigger@recipe.ifttt.com -s smtp.gmail.com:587 -xu ***@gmail.com -xp *** -u\
^-- SC2035: Use ./*glob* or -- *glob* so names with dashes won't become options.
^-- SC2035: Use ./*glob* or -- *glob* so names with dashes won't become options.
Line 7:
$1 -m "contains the word " $2 ".";
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2086: Double quote to prevent globbing and word splitting.
Line 10:
/usr/local/bin/sendemail -o tls=yes -f ***@gmail.com -t\
^-- SC2035: Use ./*glob* or -- *glob* so names with dashes won't become options.
Line 11:
trigger@recipe.ifttt.com -s smtp.gmail.com:587 -xu ***@gmail.com -xp *** -u\
^-- SC2035: Use ./*glob* or -- *glob* so names with dashes won't become options.
^-- SC2035: Use ./*glob* or -- *glob* so names with dashes won't become options.
Line 12:
$1 -m "does not contain the word " $2 ".";
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2086: Double quote to prevent globbing and word splitting.
$
提案の説明については、次のリンクを参照してください。