启动脚本 testyon.sh 后:
#!/bin/sh
function yon {
while true; do
echo "Start proc?[Y/n]: "
read -r "[Y/n]: " yn
case $yn in
[Yy]*) echo "Starting" ; return 0 ;;
[Nn]*) echo "Stopped" ; return 1 ;;
esac
done }
我收到此错误:
$ sh testyon.sh testyon.sh: 2: testyon.sh: function: not found testyon.sh: 7: testyon.sh: Syntax error: newline unexpected (expecting ")") $
如何解决这个问题?