noexec オプション
#!/usr/bin/env bash
set -o noexec実際に実行はしない
構文チェックや DryRun といった振る舞い
構文エラー時は
行 11: 構文エラー: 予期しないファイル終了 (EOF) ですのようなエラー表示
shellcheck
Install
ubuntu
sudo apt-get install shellcheckMac
brew install shellcheckExec shellcheck
source sc.sh
#!/usr/bin/env bash
set -o noexec
if [[ $1 == test ]]; then
param='test'
else
param='not test'
fi
echo "$param"shellcheck sc.shエラーなし
source sc.sh (echo ” を外す)
#!/usr/bin/env bash
set -o noexec
if [[ $1 == test ]]; then
param='test'
else
param='not test'
fi
echo $paramshellcheck sc.sh
In sc.sh line 11:
echo $param
^----^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
echo "$param"
For more information:
https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...エラーを指摘される。エラーの詳細はリンク先で確認
Intellij IDEA ではエディタ上で表示してくれる。
