diff --git a/translated/tech/20161210 How to Perform Syntax Checking Debugging Mode in Shell Scripts.md b/published/20161210 How to Perform Syntax Checking Debugging Mode in Shell Scripts.md similarity index 90% rename from translated/tech/20161210 How to Perform Syntax Checking Debugging Mode in Shell Scripts.md rename to published/20161210 How to Perform Syntax Checking Debugging Mode in Shell Scripts.md index af799f574d..c1c3015465 100644 --- a/translated/tech/20161210 How to Perform Syntax Checking Debugging Mode in Shell Scripts.md +++ b/published/20161210 How to Perform Syntax Checking Debugging Mode in Shell Scripts.md @@ -5,9 +5,9 @@ 写完脚本后,建议在运行脚本之前先检查脚本中的语法,而不是查看它们的输出以确认它们是否正常工作。 -在本系列的这一部分,我们将了解如何使用语法检查调试模式。记住我们之前在本系列的第一部分中解释了不同的调试选项,在这里,我们将使用它们来执行脚本调试。 +在本系列的这一部分,我们将了解如何使用语法检查调试模式。记住我们之前在本系列的[第一部分][1]中解释了不同的调试选项,在这里,我们将使用它们来执行脚本调试。 -#### 启用 verbose 调试模式 +### 启用 verbose 调试模式 在进入本指导的重点之前,让我们简要地探索下 **verbose 模式**。它可以用 `-v` 调试选项来启用,它会告诉 shell 在读取时显示每行。 @@ -42,7 +42,7 @@ $ bash -v script.sh *显示shell脚本中的所有行* -#### 在 Shell 脚本中启用语法检查调试模式 +### 在 Shell 脚本中启用语法检查调试模式 回到我们主题的重点,`-n` 激活语法检查模式。它会让 shell 读取所有的命令,但是不会执行它们,它(shell)只会检查语法。 @@ -79,7 +79,7 @@ $ bash -n script.sh *检查 shell 脚本语法* -从上面的输出中,我们看到我们的脚本中有一个错误,for 循环缺少了一个结束的 `done` 关键字。shell 脚本从头到尾检查文件,一旦没有找到它(**done**),shell 会打印出一个语法错误: +从上面的输出中,我们看到我们的脚本中有一个错误,for 循环缺少了一个结束的 `done` 关键字。shell 脚本从头到尾检查文件,一旦没有找到它(`done`),shell 会打印出一个语法错误: ``` script.sh: line 11: syntax error: unexpected end of file @@ -94,7 +94,7 @@ $ bash -vn script.sh ![Enable Verbose and Syntax Checking in Script](http://www.tecmint.com/wp-content/uploads/2016/12/Enable-Verbose-and-Syntax-Checking-in-Script.png) ][5] -*在脚本中同时启用 verbose 和语法检查* +*在脚本中同时启用 verbose 检查和语法检查* 另外,我们可以通过修改脚本的首行来启用脚本检查,如下面的例子: @@ -156,15 +156,15 @@ Aaron Kili 是一个 Linux 及 F.O.S.S 热衷者,即将是 Linux 系统管理 via: http://www.tecmint.com/check-syntax-in-shell-script/ -作者:[Aaron Kili ][a] +作者:[Aaron Kili][a] 译者:[geekpi](https://github.com/geekpi) 校对:[jasminepeng](https://github.com/jasminepeng) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]:http://www.tecmint.com/author/aaronkili/ -[1]:http://www.tecmint.com/enable-shell-debug-mode-linux/ -[2]:http://www.tecmint.com/linux-image-conversion-tools/ +[1]:https://linux.cn/article-8028-1.html +[2]:https://linux.cn/article-8014-1.html [3]:http://www.tecmint.com/wp-content/uploads/2016/12/Show-Shell-Script-Lines.png [4]:http://www.tecmint.com/wp-content/uploads/2016/12/Check-Syntax-in-Shell-Script.png [5]:http://www.tecmint.com/wp-content/uploads/2016/12/Enable-Verbose-and-Syntax-Checking-in-Script.png