mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
feat(tools): Add shellcheck for shell scripts to CI
- shellcheck fixes in shell scripts
This commit is contained in:
parent
c50dfa2374
commit
37c7c5b58d
@ -208,3 +208,14 @@ repos:
|
|||||||
- id: astyle_py
|
- id: astyle_py
|
||||||
# If you are modifying astyle version, update tools/format.sh as well
|
# If you are modifying astyle version, update tools/format.sh as well
|
||||||
args: ['--astyle-version=3.4.7', '--rules=tools/ci/astyle-rules.yml']
|
args: ['--astyle-version=3.4.7', '--rules=tools/ci/astyle-rules.yml']
|
||||||
|
- repo: https://github.com/shellcheck-py/shellcheck-py
|
||||||
|
rev: v0.9.0.5
|
||||||
|
hooks:
|
||||||
|
- id: shellcheck
|
||||||
|
name: shellcheck bash
|
||||||
|
args: ['--shell', 'bash', '-x']
|
||||||
|
files: 'install.sh|export.sh'
|
||||||
|
- id: shellcheck
|
||||||
|
name: shellcheck dash (export.sh)
|
||||||
|
args: ['--shell', 'dash', '-x']
|
||||||
|
files: 'export.sh'
|
||||||
|
5
.shellcheckrc
Normal file
5
.shellcheckrc
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# This is shellcheck config file
|
||||||
|
# Files that are checked: install.sh, export.sh
|
||||||
|
|
||||||
|
# Do not complain about variables determined at runtime (IDF_PATH)
|
||||||
|
disable=SC1090
|
@ -65,6 +65,7 @@ __main() {
|
|||||||
self_path="${BASH_SOURCE}"
|
self_path="${BASH_SOURCE}"
|
||||||
elif [ -n "${ZSH_VERSION-}" ]
|
elif [ -n "${ZSH_VERSION-}" ]
|
||||||
then
|
then
|
||||||
|
# shellcheck disable=SC2296 # ignore parameter starts with '{' because it's zsh
|
||||||
self_path="${(%):-%x}"
|
self_path="${(%):-%x}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -138,7 +139,7 @@ __main() {
|
|||||||
|
|
||||||
if [ -n "$BASH" ]
|
if [ -n "$BASH" ]
|
||||||
then
|
then
|
||||||
path_prefix=${PATH%%${old_path}}
|
path_prefix="${PATH%%"${old_path}"}"
|
||||||
# shellcheck disable=SC2169,SC2039 # unreachable with 'dash'
|
# shellcheck disable=SC2169,SC2039 # unreachable with 'dash'
|
||||||
if [ -n "${path_prefix}" ]; then
|
if [ -n "${path_prefix}" ]; then
|
||||||
__verbose "Added the following directories to PATH:"
|
__verbose "Added the following directories to PATH:"
|
||||||
@ -201,7 +202,7 @@ __cleanup() {
|
|||||||
# Not unsetting IDF_PYTHON_ENV_PATH, it can be used by IDF build system
|
# Not unsetting IDF_PYTHON_ENV_PATH, it can be used by IDF build system
|
||||||
# to check whether we are using a private Python environment
|
# to check whether we are using a private Python environment
|
||||||
|
|
||||||
return $1
|
return "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -222,7 +223,7 @@ __enable_autocomplete() {
|
|||||||
elif [ -n "${BASH_SOURCE-}" ]
|
elif [ -n "${BASH_SOURCE-}" ]
|
||||||
then
|
then
|
||||||
WARNING_MSG="WARNING: Failed to load shell autocompletion for bash version: $BASH_VERSION!"
|
WARNING_MSG="WARNING: Failed to load shell autocompletion for bash version: $BASH_VERSION!"
|
||||||
# shellcheck disable=SC3028,SC3054,SC2086 # code block for 'bash' only
|
# shellcheck disable=SC3028,SC3054,SC2086,SC2169 # code block for 'bash' only
|
||||||
[ ${BASH_VERSINFO[0]} -lt 4 ] && { echo "$WARNING_MSG"; return; }
|
[ ${BASH_VERSINFO[0]} -lt 4 ] && { echo "$WARNING_MSG"; return; }
|
||||||
eval "$(env LANG=en _IDF.PY_COMPLETE=$SOURCE_BASH idf.py)" || echo "$WARNING_MSG"
|
eval "$(env LANG=en _IDF.PY_COMPLETE=$SOURCE_BASH idf.py)" || echo "$WARNING_MSG"
|
||||||
fi
|
fi
|
||||||
|
10
install.sh
10
install.sh
@ -18,18 +18,20 @@ while getopts ":h" option; do
|
|||||||
h)
|
h)
|
||||||
"${ESP_PYTHON}" "${IDF_PATH}/tools/install_util.py" print_help sh
|
"${ESP_PYTHON}" "${IDF_PATH}/tools/install_util.py" print_help sh
|
||||||
exit;;
|
exit;;
|
||||||
|
\?)
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
TARGETS=`"${ESP_PYTHON}" "${IDF_PATH}/tools/install_util.py" extract targets "$@"`
|
TARGETS=$("${ESP_PYTHON}" "${IDF_PATH}/tools/install_util.py" extract targets "$@")
|
||||||
|
|
||||||
echo "Installing ESP-IDF tools"
|
echo "Installing ESP-IDF tools"
|
||||||
"${ESP_PYTHON}" "${IDF_PATH}/tools/idf_tools.py" install --targets=${TARGETS}
|
"${ESP_PYTHON}" "${IDF_PATH}/tools/idf_tools.py" install --targets="${TARGETS}"
|
||||||
|
|
||||||
FEATURES=`"${ESP_PYTHON}" "${IDF_PATH}/tools/install_util.py" extract features "$@"`
|
FEATURES=$("${ESP_PYTHON}" "${IDF_PATH}/tools/install_util.py" extract features "$@")
|
||||||
|
|
||||||
echo "Installing Python environment and packages"
|
echo "Installing Python environment and packages"
|
||||||
"${ESP_PYTHON}" "${IDF_PATH}/tools/idf_tools.py" install-python-env --features=${FEATURES}
|
"${ESP_PYTHON}" "${IDF_PATH}/tools/idf_tools.py" install-python-env --features="${FEATURES}"
|
||||||
|
|
||||||
echo "All done! You can now run:"
|
echo "All done! You can now run:"
|
||||||
echo ""
|
echo ""
|
||||||
|
Loading…
Reference in New Issue
Block a user