源代码:
#Program
# This is a program shows the uer's choice
#History:
#2014/08/10 ttop first release
PATH=/bin:/sbin:/user/bin:/user/sbin:/user/local/bin:/user/local/sbin:~/bin
export PATH
[ "$yn" = "Y" -o "$yn" = "y" ] && echo "OK, continue!" && exit 0
[ "$yn" = "N" -o "$yn" = "n" ] && echo "Oh, interrupt!" && exit 0
echo "I don't know what your choice is" && exit 0
运行老是有错误:
ttop@ttop-Lenovo:~/桌面/my scripts$ sh sh06.sh
Please input (Y/N): Y
sh06.sh: 10: [: missing ]
sh06.sh: 11: [: missing ]
I don't know what your choice is
sh06.sh: 12: sh06.sh: b: not found
解决方法就是:
(1) :sudo dpkg-reconfigure dash 选NO
将ubuntu 默认的shell 链接的dash 改成传统的 bash
lrwxrwxrwx 1 root root 4 8月 11 09:53 /bin/sh -> dash (为修改之前)
lrwxrwxrwx 1 root root 4 8月 11 09:53 /bin/sh -> bash
由于dash 和bash 不兼容才导致了此类问题的发生。。
(2):将==改成= :因为在dash 中默认的 判断语句是=。。
对于具体的dash 和bash 都可以使用man 查到。。