我正在尝试制作自己的 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
我如何实现这一目标?
如何合并缩进代码?以及如何合并“结束”语句?