shell script的语法检查
时间:2008-07-13 来源:jackylau
sh里的-n参数可以使脚本不被执行,而检查语法。
[root@trffic root]# ls
a anaconda-ks.cfg install.log install.log.syslog test
[root@trffic root]# cat a
#!/bin/sh -n
cp install.log aa
if [ you == you ];then
echo "eco"
ifi
[root@trffic root]# ./a
./a: line 6: syntax error: unexpected end of file
[root@trffic root]# ls
a anaconda-ks.cfg install.log install.log.syslog test
[root@trffic root]# ls
a anaconda-ks.cfg install.log install.log.syslog test
[root@trffic root]# cat a
#!/bin/sh -n
cp install.log aa
if [ you == you ];then
echo "eco"
ifi
[root@trffic root]# ./a
./a: line 6: syntax error: unexpected end of file
[root@trffic root]# ls
a anaconda-ks.cfg install.log install.log.syslog test
相关阅读 更多 +