Skip to content

Commit 7522821

Browse files
jcfrthewtex
authored andcommitted
macpython-install-python: Fix SC2155 warnings
This commit fixes warning like this one: ``` In ./macpython-install-python.sh line 178: local py_mm=$(get_py_mm) ^-- SC2155: Declare and assign separately to avoid masking return values. ``` In the original code, the return value of mycmd is ignored, and export will instead always return true. This may prevent conditionals, set -e and traps from working correctly. See https://github.com/koalaman/shellcheck/wiki/SC2155
1 parent 62d1214 commit 7522821

2 files changed

Lines changed: 22 additions & 12 deletions

File tree

‎scripts/internal/shellcheck-run.sh‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ for f in $(find . -type f -not -iwholename '*.git*' | sort -u); do
2222
-e SC1090 \
2323
-e SC2046 \
2424
-e SC2086 \
25-
-e SC2155 \
2625
"$f" \
2726
&& echo "[OK]: successfully linted $f" || echo "[FAILED]: found issues linting $f"
2827
current_exit_code=$?

‎scripts/macpython-install-python.sh‎

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ function fill_pyver {
8686
# Hence:
8787
# 2 -> 2.7.11 (depending on LATEST_27 value)
8888
# 2.7 -> 2.7.11 (depending on LATEST_27 value)
89-
local ver=$1
89+
local ver
90+
ver=$1
9091
check_var $ver
9192
if [[ $ver =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
9293
# Major.minor.micro format already
@@ -111,10 +112,12 @@ function pyinst_ext_for_version {
111112
# $py_version (python version in major.minor.extra format)
112113
#
113114
# Earlier Python installers are .dmg, later are .pkg.
114-
local py_version=$1
115+
local py_version
116+
py_version=$1
115117
check_var $py_version
116118
py_version=$(fill_pyver $py_version)
117-
local py_0=${py_version:0:1}
119+
local py_0
120+
py_0=${py_version:0:1}
118121
if [ $py_0 -eq 2 ]; then
119122
if [ "$(lex_ver $py_version)" -ge "$(lex_ver 2.7.9)" ]; then
120123
echo "pkg"
@@ -136,20 +139,27 @@ function install_macpython {
136139
# Version given in major or major.minor or major.minor.micro e.g
137140
# "3" or "3.4" or "3.4.1".
138141
# sets $PYTHON_EXE variable to python executable
139-
local py_version=$(fill_pyver $1)
140-
local py_stripped=$(strip_ver_suffix $py_version)
141-
local inst_ext=$(pyinst_ext_for_version $py_version)
142-
local py_inst=python-$py_version-macosx10.6.$inst_ext
143-
local inst_path=$DOWNLOADS_SDIR/$py_inst
142+
local py_version
143+
py_version=$(fill_pyver $1)
144+
local py_stripped
145+
py_stripped=$(strip_ver_suffix $py_version)
146+
local inst_ext
147+
inst_ext=$(pyinst_ext_for_version $py_version)
148+
local py_inst
149+
py_inst=python-$py_version-macosx10.6.$inst_ext
150+
local inst_path
151+
inst_path=$DOWNLOADS_SDIR/$py_inst
144152
mkdir -p $DOWNLOADS_SDIR
145153
curl $MACPYTHON_URL/$py_stripped/${py_inst} > $inst_path
146154
if [ "$inst_ext" == "dmg" ]; then
147155
hdiutil attach $inst_path -mountpoint /Volumes/Python
148156
inst_path=/Volumes/Python/Python.mpkg
149157
fi
150158
sudo installer -pkg $inst_path -target /
151-
local py_mm=${py_version:0:3}
152-
local py_m=${py_version:0:1}
159+
local py_mm
160+
py_mm=${py_version:0:3}
161+
local py_m
162+
py_m=${py_version:0:1}
153163
PYTHON_EXE=$MACPYTHON_PY_PREFIX/$py_mm/bin/python$py_m
154164
export PYTHON_EXE
155165
}
@@ -165,7 +175,8 @@ function install_pip {
165175
# Travis VMS now install pip for system python by default - force install
166176
# even if installed already
167177
sudo $PYTHON_EXE $DOWNLOADS_SDIR/get-pip.py --ignore-installed
168-
local py_mm=$(get_py_mm)
178+
local py_mm
179+
py_mm=$(get_py_mm)
169180
PIP_CMD="sudo $(dirname $PYTHON_EXE)/pip$py_mm"
170181
export PIP_CMD
171182
}

0 commit comments

Comments
 (0)