Post

shellcheckでシェルスクリプトを静的解析する

インストール

mac

brew install shellcheck

shellcheck を使おう - Qiita

使い方

$ shellcheck hoge.sh

$ shellcheck tweet.sh In tweet.sh line 38: tmp="/tmp/$$" ^-^ SC2034: tmp appears unused. Verify use (or export if used externally). In tweet.sh line 102: if [ "$CONSUMER_KEY" = '' -a \ ^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. In tweet.sh line 103: -f "$work_dir/tweet.client.key" -a \ ^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. In tweet.sh line 107: source "$work_dir/tweet.client.key" ^--------------------------^ SC1090: Can't follow non-constant source. Use a directive to specify location.
緑色で表示される場合はただのコメントなので無視しても問題はないもの、黄色・赤で表示される場合は直した方がいいものですね。
This post is licensed under CC BY 4.0 by the author.