set有三个选项,可以用于脚本的调试
选项名称 简写 意义
noexecn读取脚本中的命令,进行语法检查,但不执行这些命令
xtracex在执行每个命令之前,将每个命令打印到标准输出(stdout)
无c...从...中读取命令
#!/bin/bash
set -n #或者 set -o noexec
echo "Start executing this script..." #用于判断脚本是否执行
var=0
while :
if [ $var -gt 3 ]
then
break
fi
let "var=var+1"
done
./misskey.sh
./misskey.sh: line 13: syntax error near unexpected token `done'
./misskey.sh: line 13: `done'#直接输出错误信息,而未输出"Start executing this script..."
将set -n 这一行注掉后
./misskey.sh
Start executing this script...
./misskey.sh: line 13: syntax error near unexpected token `done'
./misskey.sh: line 13: `done'
标签:...,shell,sh,set,done,linux,var,misskey
来源: https://www.cnblogs.com/zhudaheng123/p/14654846.html