Skip to content

Commit 6354a9d

Browse files
committed
Cleanup & fix shellcheck and white space errors
1 parent 67fd636 commit 6354a9d

12 files changed

+62
-54
lines changed

install.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ source $opencoarrays_src_dir/prerequisites/install-functions/report_results.sh
240240
if [[ "${arg_v}" == "${__flag_present}" || "${arg_V}" == "opencoarrays" ]]; then
241241

242242
# Print script copyright if invoked with -v, -V, or --version argument
243-
cmake_project_line=$(grep project ${opencoarrays_src_dir}/CMakeLists.txt | grep VERSION)
243+
cmake_project_line="$(grep project "${opencoarrays_src_dir}/CMakeLists.txt" | grep VERSION)"
244244
text_after_version_keyword="${cmake_project_line##*VERSION}"
245245
text_before_language_keyword="${text_after_version_keyword%%LANGUAGES*}"
246246
opencoarrays_version=$text_before_language_keyword
@@ -310,8 +310,8 @@ elif [[ "${arg_p:-}" == "ofp" ]]; then
310310
elif [[ ! -z "${arg_p:-}" ]]; then
311311

312312
info "Invoking build script with the following command:"
313-
info "\"${opencoarrays_src_dir}\"/prerequisites/build.sh ${@:-}"
314-
"${opencoarrays_src_dir}"/prerequisites/build.sh ${@:-}
313+
info "\"${opencoarrays_src_dir}\"/prerequisites/build.sh ${*:-}"
314+
"${opencoarrays_src_dir}"/prerequisites/build.sh "${@:-}"
315315

316316
fi
317317
# ____________________________________ End of Main Body ____________________________________________

prerequisites/build-functions/download_if_necessary.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# shellcheck shell=bash disable=SC2148
12
# shellcheck source=./ftp-url.sh
23
source "${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/ftp-url.sh"
34
# shellcheck source=./set_SUDO_if_needed_to_write_to_directory.sh
@@ -49,9 +50,9 @@ download_if_necessary()
4950
args="clone"
5051
elif [[ "${fetch}" == "curl" ]]; then
5152
first_three_characters=$(echo "${package_url}" | cut -c1-3)
52-
if [[ "${first_three_characters}" == "ftp" ]]; then
53+
if [[ "${first_three_characters}" == "ftp" ]]; then
5354
args="-LO -u anonymous:"
54-
elif [[ "${first_three_characters}" == "htt" ]]; then
55+
elif [[ "${first_three_characters}" == "htt" ]]; then
5556
args="-LO"
5657
else
5758
emergency "download_if_necessary.sh: Unrecognized URL."
@@ -68,7 +69,8 @@ download_if_necessary()
6869
info "Download command: \"${fetch}\" ${args:-} ${package_url}"
6970
info "Depending on the file size and network bandwidth, this could take several minutes or longer."
7071
pushd "${download_path}"
71-
"${fetch}" ${args:-} ${package_url}
72+
# args should be an array. Then "${args[@]:-}" will prevent shellcheck from complaining
73+
"${fetch}" ${args:-} "${package_url}"
7274
popd
7375
if [[ ! -z "${arg_B:-}" ]]; then
7476
return

prerequisites/build-functions/set_or_print_default_version.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# shellcheck shell=bash disable=SC2148
12
# If -p, -D, -P, or -U specifies a package, set default_version
23
# If -V specifies a package, print the default_version and exit with normal status
34
# If -l is present, list all packages and versions and exit with normal status
@@ -15,11 +16,11 @@ set_or_print_default_version()
1516
package_name="${arg_p:-${arg_D:-${arg_P:-${arg_U:-${arg_V}}}}}" # not needed for -l
1617

1718
if [[ "${package_name}" == "ofp" ]]; then
18-
${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh "${@}"
19+
"${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh" "${@}"
1920
exit 0
20-
fi
21+
fi
2122

22-
[ "${package_name}" == "opencoarrays" ] &&
23+
[ "${package_name}" == "opencoarrays" ] &&
2324
emergency "Please use this script with a previously downloaded opencoarrays source archive. This script does not download opencoarrays "
2425
# This is a bash 3 hack standing in for a bash 4 hash (bash 3 is the lowest common
2526
# denominator because, for licensing reasons, OS X only has bash 3 by default.)

prerequisites/build-functions/set_or_print_downloader.sh

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# shellcheck shell=bash disable=SC2148
12
# If -p, -P, -U, or -V specifies a package, set fetch variable
23
# If -D specifies a package, print "${fetch}" and exit with normal status
34
# If -l is present, list all packages and versions and exit with normal status
@@ -11,20 +12,20 @@ set_or_print_downloader()
1112
package_name="${arg_p:-${arg_D:-${arg_P:-${arg_U:-${arg_V:-${arg_B}}}}}}"
1213

1314
if [[ "${package_name}" == "ofp" ]]; then
14-
${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh "${@}"
15+
"${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh" "${@}"
1516
exit 0
16-
fi
17+
fi
1718

18-
# Choose the first available download mechanism, prioritizing first any absolute requirement
19+
# Choose the first available download mechanism, prioritizing first any absolute requirement
1920
# (svn for gcc development branches) and second robustness:
2021
info "Checking available download mechanisms: ftp, wget, and curl."
2122
info "\${package_name}=${package_name} \${arg_b:-\${arg_B:-}}=${arg_b:-${arg_B:-}}"
22-
23+
2324
if [[ "${package_name}" == "gcc" && ! -z "${arg_b:-${arg_B:-}}" ]]; then
2425

2526
if type svn &> /dev/null; then
26-
fetch=svn
27-
else
27+
fetch=svn
28+
else
2829
tried="svn"
2930
fi
3031

@@ -39,19 +40,19 @@ set_or_print_downloader()
3940
fi
4041
else
4142
tried="curl, wget, and ftp"
42-
fi
43+
fi
4344

4445
if [[ -z "${fetch:-}" ]]; then
4546
if [[ -z "${arg_B:-}" ]]; then
46-
warning "No available download mechanism. Options tried: ${tried}"
47-
else
48-
emergency "No available download mechanism. Option tried: ${tried}"
47+
warning "No available download mechanism. Options tried: ${tried}"
48+
else
49+
emergency "No available download mechanism. Option tried: ${tried}"
4950
fi
5051
fi
5152

5253
# If a printout of the download mechanism was requested, then print it and exit with normal status
53-
if [[ ! -z "${arg_D}" ]]; then
54-
printf "%s\n" "${fetch}"
54+
if [[ ! -z "${arg_D}" ]]; then
55+
printf "%s\n" "${fetch}"
5556
exit 0
5657
fi
5758
}

prerequisites/build.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ trap cleanup_before_exit EXIT # The signal is specified here. Could be SIGINT, S
5959
export __flag_present=1
6060

6161
# shellcheck disable=SC2154
62-
if [[ "${arg_l}" != "${__flag_present}" &&
63-
"${arg_v}" != "${__flag_present}" &&
62+
if [[ "${arg_l}" != "${__flag_present}" &&
63+
"${arg_v}" != "${__flag_present}" &&
6464
"${arg_h}" != "${__flag_present}" &&
6565
-z "${arg_D:-${arg_p:-${arg_P:-${arg_U:-${arg_V:-${arg_B}}}}}}" ]]; then
6666
help "${__base}: Insufficient arguments. Please pass either -B, -D, -h, -l, -L, -p, -P, -U, -v, -V, or a longer equivalent."
@@ -116,12 +116,14 @@ info "-y (--yes-to-all): ${arg_y} "
116116
if [[ -z "${arg_B}" ]]; then
117117
# shellcheck source=./build-functions/set_or_print_default_version.sh
118118
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_default_version.sh"
119+
# shellcheck disable=SC2119
119120
set_or_print_default_version
120121
export version_to_build="${arg_I:-${arg_b:-${default_version}}}"
121122
fi
122123

123124
# shellcheck source=./build-functions/set_or_print_downloader.sh
124125
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_downloader.sh"
126+
# shellcheck disable=SC2119
125127
set_or_print_downloader
126128

127129
# shellcheck source=./build-functions/set_or_print_url.sh
@@ -143,11 +145,11 @@ if [[ -z "${arg_B}" ]]; then
143145
# shellcheck source=./build-functions/unpack_if_necessary.sh
144146
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/unpack_if_necessary.sh"
145147
unpack_if_necessary
146-
148+
147149
# shellcheck source=./build-functions/set_compilers.sh
148150
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_compilers.sh"
149151
set_compilers
150-
152+
151153
# shellcheck source=./build-functions/build_and_install.sh
152154
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/build_and_install.sh"
153155
build_and_install

prerequisites/install-binary.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ if [[ ! -f "${B3B_USE_CASE:-}/bootstrap.sh" ]]; then
4444
echo "Please set B3B_USE_CASE to the bash3boilerplate use-case directory path."
4545
exit 2
4646
else
47-
# shellcheck source=./prerequisites/use-case/bootstrap.sh
47+
# shellcheck source=./use-case/bootstrap.sh
4848
source "${B3B_USE_CASE}/bootstrap.sh" "$@"
4949
fi
5050
### End of boilerplate -- start user edits below #########################

prerequisites/install-functions/find_or_install.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# shellcheck disable=SC2154,SC2034
1+
# shellcheck shell=bash disable=SC2154,SC2034,SC2148
22
find_or_install()
33
{
44
package="$1"
@@ -28,9 +28,9 @@ find_or_install()
2828
done
2929

3030
if [[ "$package" == "$executable" ]]; then
31-
printf "$this_script: Checking whether $executable is in the PATH..."
31+
printf "%s: Checking whether %s is in the PATH..." "$this_script" "$executable"
3232
else
33-
printf "$this_script: Checking whether $package executable $executable is in the PATH..."
33+
printf "%s: Checking whether %s executable $executable is in the PATH..." "$this_script" "$package"
3434
fi
3535
if type "$executable" >& /dev/null; then
3636
printf "yes.\n"
@@ -43,7 +43,7 @@ find_or_install()
4343

4444
package_install_path=$(./build.sh -P "$package")
4545

46-
printf "Checking whether $executable is in $package_install_path..."
46+
printf "Checking whether %s is in %s..." "$executable" "$package_install_path"
4747
if [[ -x "$package_install_path/bin/$executable" ]]; then
4848
printf "yes.\n"
4949
script_installed_package=true
@@ -110,7 +110,7 @@ find_or_install()
110110
# Every branch that discovers an acceptable pre-existing installation must set the
111111
# MPIFC, MPICC, and MPICXX environment variables. Every branch must also manage the
112112
# dependency stack.
113-
113+
114114
# If the user specified a Fortran compiler, verify that mpif90 wraps the specified compiler
115115
if [[ ! -z "${arg_M:-}" ]]; then
116116

@@ -159,33 +159,33 @@ find_or_install()
159159
printf "yes.\n"
160160

161161
if [[ ! -z "${arg_f:-}" ]]; then
162-
162+
163163
info "-f (or --with-fortran) argument detected with value ${arg_f}"
164-
printf "yes.\n $this_script: Using the specified $executable.\n"
164+
printf "yes.\n %s: Using the specified %s.\n" "$this_script" "$executable"
165165
export MPIFC=mpif90
166166
export MPICC=mpicc
167167
export MPICXX=mpicxx
168-
168+
169169
# Halt the recursion
170170
stack_push dependency_pkg "none"
171171
stack_push dependency_exe "none"
172172
stack_push dependency_path "none"
173173

174174
else
175175

176-
echo -e "$this_script: Checking whether $executable in PATH wraps gfortran version `./build.sh -V gcc` or later... "
176+
echo -e "$this_script: Checking whether $executable in PATH wraps gfortran version $(./build.sh -V gcc) or later... "
177177
$executable acceptable_compiler.f90 -o acceptable_compiler
178178
$executable print_true.f90 -o print_true
179179
acceptable=$(./acceptable_compiler)
180180
is_true=$(./print_true)
181181
rm acceptable_compiler print_true
182-
182+
183183
if [[ "$acceptable" == "$is_true" ]]; then
184-
printf "yes.\n $this_script: Using the $executable found in the PATH.\n"
184+
printf "yes.\n %s: Using the $executable found in the PATH.\n" "$this_script"
185185
export MPIFC=mpif90
186186
export MPICC=mpicc
187187
export MPICXX=mpicxx
188-
188+
189189
# Halt the recursion
190190
stack_push dependency_pkg "none"
191191
stack_push dependency_exe "none"
@@ -261,7 +261,7 @@ find_or_install()
261261
stack_push dependency_path "none"
262262

263263
elif [[ "$package_in_path" == "true" ]]; then
264-
echo -e "$this_script: Checking whether $executable in PATH is version `./build.sh -V gcc` or later..."
264+
echo -e "$this_script: Checking whether $executable in PATH is version $(./build.sh -V gcc) or later..."
265265
$executable -o acceptable_compiler acceptable_compiler.f90
266266
$executable -o print_true print_true.f90
267267
is_true=$(./print_true)
@@ -576,8 +576,8 @@ find_or_install()
576576

577577

578578
# Strip trailing package name and version number, if present, from installation path
579-
default_package_version=$(./build.sh -V ${package})
580-
package_install_prefix="${package_install_path%${package}/${arg_I:-${default_package_version}}*}"
579+
default_package_version=$(./build.sh -V "${package}")
580+
package_install_prefix="${package_install_path%${package}/${arg_I:-${default_package_version}}*}"
581581

582582
echo -e "$this_script: Downloading, building, and installing $package \n"
583583
echo "$this_script: Build command: FC=$FC CC=$CC CXX=$CXX ./build.sh -p $package -i $package_install_prefix -j $num_threads"

prerequisites/install-functions/print_header.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# shellcheck disable=SC2154
1+
# shellcheck shell=bash disable=SC2154,SC2148
22
print_header()
33
{
44
clear
@@ -23,7 +23,7 @@ print_header()
2323
fi
2424
popd > /dev/null
2525
echo ""
26-
printf "${arg_p} will be installed in ${install_path}\n"
26+
printf "%s will be installed in %s\n" "${arg_p}" "${install_path}"
2727
echo ""
2828
if [[ "${arg_y}" == "${__flag_present}" ]]; then
2929
info "-y or --yes-to-all flag present. Proceeding with non-interactive build."

prerequisites/install-functions/report_results.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# shellcheck disable=SC2154,SC2129
1+
# shellcheck shell=bash disable=SC2154,SC2129,SC2148
22
report_results()
33
{
44
# Report installation success or failure:
@@ -36,7 +36,7 @@ report_results()
3636
echo "else " >> setup.sh
3737
echo " export PATH=\"$gcc_install_path/bin:\$PATH\" " >> setup.sh
3838
echo "fi " >> setup.sh
39-
echo "set path = (\"$gcc_install_path\"/bin "\$path") " >> setup.csh
39+
echo "set path = (\"$gcc_install_path\"/bin \"\$path\") " >> setup.csh
4040
fi
4141
if [[ -d "$gcc_install_path/lib" || -d "$gcc_install_path/lib64" ]]; then
4242
gfortran_lib_paths="$gcc_install_path/lib64/:$gcc_install_path/lib"
@@ -45,7 +45,7 @@ report_results()
4545
echo "else " >> setup.sh
4646
echo " export LD_LIBRARY_PATH=\"$gfortran_lib_paths:\$LD_LIBRARY_PATH\" " >> setup.sh
4747
echo "fi " >> setup.sh
48-
echo "set LD_LIBRARY_PATH = (\"$gfortran_lib_paths\"/bin "\$LD_LIBRARY_PATH") " >> setup.csh
48+
echo "set LD_LIBRARY_PATH = (\"$gfortran_lib_paths\"/bin \"\$LD_LIBRARY_PATH\") " >> setup.csh
4949
fi
5050
echo " " >> setup.sh
5151
mpich_install_path=$("${build_script}" -P mpich)
@@ -55,7 +55,7 @@ report_results()
5555
echo "else " >> setup.sh
5656
echo " export PATH=\"$mpich_install_path/bin\":\$PATH " >> setup.sh
5757
echo "fi " >> setup.sh
58-
echo "set path = (\"$mpich_install_path\"/bin "\$path") " >> setup.csh
58+
echo "set path = (\"$mpich_install_path\"/bin \"\$path\") " >> setup.csh
5959
fi
6060
cmake_install_path=$("${build_script}" -P cmake)
6161
if [[ -x "$cmake_install_path/bin/cmake" ]]; then
@@ -64,15 +64,15 @@ report_results()
6464
echo "else " >> setup.sh
6565
echo " export PATH=\"$cmake_install_path/bin\":\$PATH " >> setup.sh
6666
echo "fi " >> setup.sh
67-
echo "set path = (\"$cmake_install_path\"/bin "\$path") " >> setup.csh
67+
echo "set path = (\"$cmake_install_path\"/bin \"\$path\") " >> setup.csh
6868
fi
6969
flex_install_path=$("${build_script}" -P flex)
7070
if [[ -x "$flex_install_path/bin/flex" ]]; then
7171
echo "if [[ -z \"\$PATH\" ]]; then " >> setup.sh
7272
echo " export PATH=\"$flex_install_path/bin\" " >> setup.sh
7373
echo "else " >> setup.sh
7474
echo " export PATH=\"$flex_install_path/bin\":\$PATH " >> setup.sh
75-
echo "set path = (\"$flex_install_path\"/bin "\$path") " >> setup.csh
75+
echo "set path = (\"$flex_install_path\"/bin \"\$path\") " >> setup.csh
7676
echo "fi " >> setup.sh
7777
fi
7878
bison_install_path=$("${build_script}" -P bison)
@@ -82,7 +82,7 @@ report_results()
8282
echo "else " >> setup.sh
8383
echo " export PATH=\"$bison_install_path/bin\":\$PATH " >> setup.sh
8484
echo "fi " >> setup.sh
85-
echo "set path = (\"$bison_install_path\"/bin "\$path") " >> setup.csh
85+
echo "set path = (\"$bison_install_path\"/bin \"\$path\") " >> setup.csh
8686
fi
8787
m4_install_path=$("${build_script}" -P m4)
8888
if [[ -x "$m4_install_path/bin/m4" ]]; then
@@ -91,7 +91,7 @@ report_results()
9191
echo "else " >> setup.sh
9292
echo " export PATH=\"$m4_install_path/bin\":\$PATH " >> setup.sh
9393
echo "fi " >> setup.sh
94-
echo "set path = (\"$m4_install_path\"/bin "\$path") " >> setup.csh
94+
echo "set path = (\"$m4_install_path\"/bin \"\$path\") " >> setup.csh
9595
fi
9696
opencoarrays_install_path="${install_path}"
9797
if [[ -x "$opencoarrays_install_path/bin/caf" ]]; then
@@ -100,7 +100,7 @@ report_results()
100100
echo "else " >> setup.sh
101101
echo " export PATH=\"$opencoarrays_install_path/bin\":\$PATH " >> setup.sh
102102
echo "fi " >> setup.sh
103-
echo "set path = (\"$opencoarrays_install_path\"/bin "\$path") " >> setup.csh
103+
echo "set path = (\"$opencoarrays_install_path\"/bin \"\$path\") " >> setup.csh
104104
fi
105105
if ${SUDO:-} mv setup.sh "$opencoarrays_install_path"; then
106106
setup_sh_location=$opencoarrays_install_path

prerequisites/install-ofp.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ fi
8484

8585
# If -P is passed, print the default installation paths for OFP and its prerequisites.
8686
# Then exit with normal status.
87+
# shellcheck disable=SC2154
8788
install_path="${arg_i}"
88-
strategoxt_superbundle_install_path=`${OPENCOARRAYS_SRC_DIR}/prerequisites/install-binary.sh -P strategoxt-superbundle`
89+
strategoxt_superbundle_install_path=$("${OPENCOARRAYS_SRC_DIR}/prerequisites/install-binary.sh" -P strategoxt-superbundle)
8990
# shellcheck disable=SC2154
9091
if [[ "${arg_P}" == "${__flag_present}" ]]; then
9192
echo "strategoxt-superbundle default installation path: ${strategoxt_superbundle_install_path}"

0 commit comments

Comments
 (0)