従来のif関数とは少し書き方が違うif関数を自作しようとしています。
これは私が現在持っているものです(おそらく完成にはほど遠いです)
function check
{
if [ "$2" = "=" ]; then
if [ "$1" = "$3" ]; then
// Don't know what to put in here
elif [ "$1" != "$3" ]; then
// Don't know what to put in here
fi
elif [ "$2" = "!=" ]; then
if [ "$1" != "$3" ]; then
// Don't know what to put in here
elif [ "$1" = "$3" ]; then
// Don't know what to put in here
fi
fi
}
完了すると、次のように実行されます。
check $foo != 2
//do this
end
どうすればこれを達成できますか?
インデントされたコードを組み込むにはどうすればよいですか? そして、「終了」ステートメントをどのように組み込むのですか?