Bash Script除錯與檢測


shell script可以用內建的-n 參數檢測語法
-x顯示每一個指令執行前的內容
-v在script執行前將整份script輸出, 一般比較少用, 除非是有寫template script用sed之類的函數及時替換內容

Ubuntu安裝方式
sudo apt-get install shellcheck

檢測Script的方式
shellcheck {your-shell-script-path}


Shellcheck官方github
https://github.com/koalaman/shellcheck


Sublime裏面可以安裝shellcheck的plugin - SublimeLinter
https://github.com/SublimeLinter/SublimeLinter-shellcheck

Sublime package manager的sublimelinter套件頁
https://packagecontrol.io/packages/SublimeLinter-shellcheck

安裝方法可以參考
http://ephrain.pixnet.net/blog/post/59641837-%5Bmac%5D-%E5%9C%A8-sublime-text-3-%E4%B8%AD%E5%AE%89%E8%A3%9D-shellcheck-plugin




參考資料
http://www.tecmint.com/shellcheck-shell-script-code-analyzer-for-linux/?utm_content=buffer3a176&utm_medium=social&utm_source=facebook.com&utm_campaign=buffer

留言