Skip to content

Commit 1ed64ae

Browse files
committed
Ensure no undefined variables are de-referenced
1 parent 5d86c36 commit 1ed64ae

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

prerequisites/install-functions/build_opencoarrays.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build_opencoarrays()
88
find_or_install cmake
99
mkdir -p "$build_path"
1010
pushd "$build_path"
11-
if [[ -z "$MPICC" || -z "$MPIFC" || -z "$CMAKE" ]]; then
11+
if [[ -z "${MPICC:-}" || -z "${MPIFC:-}" || -z "${CMAKE:-}" ]]; then
1212
emergency "Empty MPICC=$MPICC or MPIFC=$MPIFC or CMAKE=$CMAKE [exit 90]"
1313
else
1414
info "Configuring OpenCoarrays in ${PWD} with the command:"

prerequisites/install-functions/find_or_install.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ find_or_install()
182182
export CC=$package_install_path/bin/gcc
183183
export CXX=$package_install_path/bin/g++
184184
gfortran_lib_paths="$package_install_path/lib64/:$package_install_path/lib"
185-
if [[ -z "$LD_LIBRARY_PATH" ]]; then
185+
if [[ -z "${LD_LIBRARY_PATH:-}" ]]; then
186186
echo "$this_script: export LD_LIBRARY_PATH=\"$gfortran_lib_paths\""
187187
export LD_LIBRARY_PATH="$gfortran_lib_paths"
188188
else
@@ -421,7 +421,7 @@ find_or_install()
421421
fi
422422

423423
else
424-
if [[ -z "$package" ]]; then
424+
if [[ -z "${package:-}" ]]; then
425425
echo -e "$this_script: empty package name passed to find_or_install function. [exit 50]\n"
426426
exit 50
427427
else
@@ -489,7 +489,7 @@ find_or_install()
489489
exit 75
490490
fi
491491
# Otherwise, if no CC has been defined yet, use the gcc in the user's PATH
492-
elif [[ -z "$CC" ]]; then
492+
elif [[ -z "${CC:-}" ]]; then
493493
CC=gcc
494494
fi
495495

@@ -503,12 +503,12 @@ find_or_install()
503503
exit 76
504504
fi
505505
# Otherwise, if no CXX has been defined yet, use the g++ in the user's PATH
506-
elif [[ -z "$CXX" ]]; then
506+
elif [[ -z "${CXX:-}" ]]; then
507507
CXX=g++
508508
fi
509509

510510
# If no FC has been defined yet, use the gfortran in the user's PATH
511-
if [[ -z "$FC" ]]; then
511+
if [[ -z "${FC:-}" ]]; then
512512
FC=gfortran
513513
fi
514514

@@ -544,7 +544,7 @@ find_or_install()
544544
echo "$this_script: export CXX=$package_install_path/bin/g++"
545545
export CXX="$package_install_path/bin/g++"
546546
gfortran_lib_paths="$package_install_path/lib64/:$package_install_path/lib"
547-
if [[ -z "$LD_LIBRARY_PATH" ]]; then
547+
if [[ -z "${LD_LIBRARY_PATH:-}" ]]; then
548548
export LD_LIBRARY_PATH="$gfortran_lib_paths"
549549
else
550550
export LD_LIBRARY_PATH="$gfortran_lib_paths:$LD_LIBRARY_PATH"
@@ -562,7 +562,7 @@ find_or_install()
562562
echo -e "$this_script: could prevent a complete build of OpenCoarrays. Please report this\n"
563563
echo -e "$this_script: issue at https://github.com/sourceryinstitute/opencoarrays/issues\n"
564564
fi
565-
if [[ -z "$PATH" ]]; then
565+
if [[ -z "${PATH:-}" ]]; then
566566
export PATH="$package_install_path/bin"
567567
else
568568
export PATH="$package_install_path/bin:$PATH"

prerequisites/stack.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ function stack_exists
227227
: "${1?'Missing stack name'}"
228228

229229
eval '_i=$'"{_stack_$1_i:-}"
230-
if [[ -z "$_i" ]]
230+
if [[ -z "${_i:-}" ]]
231231
then
232232
return 1
233233
else

0 commit comments

Comments
 (0)