私の人生の中では、2番目の機能が動作しない理由を理解できません。 elseとelifを使用しようとしましたが、構文エラーが表示されたり、2番目の関数が表示されません。これは単純なbashスクリプトです。私が間違っていることを知る必要があります。機能以外で動作している場合
function yes() {
echo "Good boy"
}
function no() {
echo "Bad Boy"
}
echo " Did you eat this pillow? [y,n]" ; tput sgr0
read $answer
if [ "$answer" != "y" ];
then
yes
elif [ "$answer" != "n" ];
then
no
else
exit
fi
'read $ answer'を' read answer'に変更します。 – codeforester
'read'のパラメータは変数名でなければなりません。 'read answer'では、「answer」は名前です。 'read $ answer'において、' $ answer'は変数 "answer"の* value *です。 – janos
私はそのような単純なことを逃したと信じていない – Red5tar