Skip to content

Commit 04e2b95

Browse files
committed
Fix shellcheck issues in install-binary-functions
1 parent c777a79 commit 04e2b95

File tree

6 files changed

+34
-29
lines changed

6 files changed

+34
-29
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Build the Open Fortran Parser parse table
2+
# shellcheck disable=SC2154
23
function build_parse_table()
34
{
45
info "Building parse table"
5-
pushd ${install_path}/ofp-sdf/fortran/syntax
6+
pushd "${install_path}/ofp-sdf/fortran/syntax"
67
info "Build command: make SDF2_PATH=\"${SDF2_PATH}\" ST_PATH=\"${ST_PATH}\" DYLD_LIBRARY_PATH=\"${DYLD_LIBRARY_PATH}\""
78
make SDF2_PATH="${SDF2_PATH}" ST_PATH="${ST_PATH}" DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}"
89
popd
9-
pushd ${install_path}/ofp-sdf/fortran/trans
10+
pushd "${install_path}/ofp-sdf/fortran/trans"
1011
make
1112
popd
1213
}

prerequisites/install-binary-functions/move_binaries_to_install_path.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ install_or_skip()
44
install_path="${2}"
55
package_to_install="${3}"
66
download_path="${4}"
7-
if [[ -d "${install_path}/${package_to_install}" ]]; then
7+
if [[ -d "${install_path}/${package_to_install}" ]]; then
88
info "The following installation path exists:"
99
info "${install_path}/${package_to_install}"
1010
info "If you want to replace it, please remove it and restart this script."
@@ -13,13 +13,13 @@ install_or_skip()
1313
info "Installing ${package_to_install} with the following command:"
1414
info "${SUDO} mv ${download_path}/${package_to_install} ${install_path}"
1515
${SUDO:-} mv "${download_path}/${package_to_install}" "${install_path}"
16-
if [[ -x "${install_path}/${package_to_install}" ]]; then
16+
if [[ -x "${install_path}/${package_to_install}" ]]; then
1717
info "Installation complete for ${package_to_install} in the following location:"
18-
info "${install_path}/${package_to_install}"
18+
info "${install_path}/${package_to_install}"
1919
else
2020
info "Something went wrong. Either ${package_to_install} is not in the following expected location"
2121
info "or the user lacks executable permissions for the directory:"
22-
emergency "${install_path}/${package_to_install}"
22+
emergency "${install_path}/${package_to_install}"
2323
fi
2424
fi
2525
}
@@ -29,16 +29,16 @@ function move_binaries_to_install_path()
2929
info "Installation package names: ${install_names}"
3030
package_to_install="${install_names%%,*}" # remove longest back-end match for ,*
3131
remaining_packages="${install_names#*,}" # remove shortest front-end match for *,
32-
if [[ ! -d "${install_path}" ]]; then
32+
if [[ ! -d "${install_path}" ]]; then
3333
${SUDO:-} mkdir -p "${install_path}"
3434
fi
3535
while [[ "${package_to_install}" != "${remaining_packages}" ]]; do
3636
install_or_skip "${SUDO:-}" "${install_path}" "${package_to_install}" "${download_path}"
3737
info "Remaining installation package names: ${remaining_packages}"
3838
install_names="${remaining_packages}"
39-
package_to_install="${install_names%%,*}" # remove longest back-end match for ,*
39+
package_to_install="${install_names%%,*}" # remove longest back-end match for ,*
4040
remaining_packages="${install_names#*,}" # remove shortest front-end for *,
4141
info "Installing ${package_to_install} binary with the following command:"
42-
done
42+
done
4343
install_or_skip "${SUDO:-}" "${install_path}" "${package_to_install}" "${download_path}"
4444
}

prerequisites/install-binary-functions/set_or_print_csv_binary_names.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# If -p, -P, -U, or -V specifies a package, set fetch variable
22
# If -D specifies a package, print "${fetch}" and exit with normal status
33
# If -l is present, list all packages and versions and exit with normal status
4+
# shellcheck disable=SC2154
45
set_or_print_csv_binary_names()
56
{
6-
# Verify requirements
7+
# Verify requirements
78
[ "${arg_N:-}" == "${__flag_present}" ] && [ ! -z "${arg_D:-${arg_p:-${arg_P:-${arg_U:-${arg_V}}}}}" ] &&
89
emergency "Please pass only one of {-D, -N, -p, -P, -U, -V} or a longer equivalent (multiple detected)."
910

@@ -19,8 +20,8 @@ set_or_print_csv_binary_names()
1920
if [[ "${package_name}" == "${KEY}" ]]; then
2021
# We recognize the package name so we set the download mechanism:
2122
install_names=${VALUE}
22-
# If a printout of the download mechanism was requested, then print it and exit with normal status
23-
[[ "${arg_N:-}" == "${__flag_present}" ]] && printf "${install_names}\n" && exit 0
23+
# If a printout of the download mechanism was requested, then print it and exit with normal status
24+
[[ "${arg_N:-}" == "${__flag_present}" ]] && printf "%s\n" "${install_names}" && exit 0
2425
break # exit the for loop
2526
fi
2627
done

prerequisites/install-binary-functions/set_or_print_default_version.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# If -p, -D, -P, or -U specifies a package, set default_version
22
# If -V specifies a package, print the default_version and exit with normal status
33
# If -l is present, list all packages and versions and exit with normal status
4+
# shellcheck disable=SC2154
45
set_or_print_default_version()
56
{
6-
# Verify requirements
7-
if [[ "${arg_l}" == "${__flag_present}" ]]; then
7+
# Verify requirements
8+
if [[ "${arg_l}" == "${__flag_present}" ]]; then
89
if [[ "${arg_N:-}" == "${__flag_present}" || ! -z "${arg_D:-${arg_p:-${arg_P:-${arg_U:-${arg_V}}}}}" ]]; then
910
emergency "Please pass only one of {-l, -D, -N, -p, -P, -U, -V} or a longer equivalent (multiple detected)."
10-
fi
11-
fi
11+
fi
12+
fi
1213

13-
if [[ "${arg_l}" == "${__flag_present}" ]]; then
14+
if [[ "${arg_l}" == "${__flag_present}" ]]; then
1415
echo "This script can install the following packages:"
1516
fi
1617
# Get package name from argument passed with -p, -V, -D, or -U
@@ -30,8 +31,8 @@ set_or_print_default_version()
3031
elif [[ "${package_name}" == "${KEY}" ]]; then
3132
# We recognize the package name so we set the default version:
3233
default_version=${VALUE}
33-
# If a printout of the default version number was requested, then print it and exit with normal status
34-
[[ ! -z "${arg_V}" ]] && printf "${default_version}\n" && exit 0
34+
# If a printout of the default version number was requested, then print it and exit with normal status
35+
[[ ! -z "${arg_V}" ]] && printf "%s\n" "${default_version}" && exit 0
3536
break # exit the for loop
3637
fi
3738
done

prerequisites/install-binary-functions/set_or_print_downloader.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# If -p, -P, -U, or -V specifies a package, set fetch variable
22
# If -D specifies a package, print "${fetch}" and exit with normal status
33
# If -l is present, list all packages and versions and exit with normal status
4+
# shellcheck disable=SC2154
45
set_or_print_downloader()
56
{
6-
# Verify requirements
7-
if [[ ! -z "${arg_D}" ]]; then
7+
# Verify requirements
8+
if [[ ! -z "${arg_D}" ]]; then
89
if [[ "${arg_N:-}" == "${__flag_present}" || ! -z "${arg_p:-${arg_P:-${arg_U:-${arg_V}}}}" ]]; then
910
emergency "Please pass only one of {-D, -N, -p, -P, -U, -V} or a longer equivalent (multiple detected)."
1011
fi
@@ -22,8 +23,8 @@ set_or_print_downloader()
2223
if [[ "${package_name}" == "${KEY}" ]]; then
2324
# We recognize the package name so we set the download mechanism:
2425
fetch=${VALUE}
25-
# If a printout of the download mechanism was requested, then print it and exit with normal status
26-
[[ ! -z "${arg_D}" ]] && printf "${fetch}\n" && exit 0
26+
# If a printout of the download mechanism was requested, then print it and exit with normal status
27+
[[ ! -z "${arg_D}" ]] && printf "%s\n" "${fetch}" && exit 0
2728
break # exit the for loop
2829
fi
2930
done

prerequisites/install-binary-functions/set_or_print_url.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# If -p, -D, -P, or -V specifies a package, set package_url
22
# If -U specifies a package, print the package_url and exit with normal status
3+
# shellcheck disable=SC2154
34
set_or_print_url()
45
{
5-
# Verify requirements
6-
if [[ ! -z "${arg_U}" ]]; then
7-
if [[ "${arg_N:-}" == "${__flag_present}" || ! -z "${arg_D:-${arg_p:-${arg_P:-${arg_V}}}}" ]]; then
6+
# Verify requirements
7+
if [[ ! -z "${arg_U}" ]]; then
8+
if [[ "${arg_N:-}" == "${__flag_present}" || ! -z "${arg_D:-${arg_p:-${arg_P:-${arg_V}}}}" ]]; then
89
emergency "Please pass only one of {-D, -N, -p, -P, -U, -V} or a longer equivalent (multiple detected)."
910
fi
1011
fi
@@ -43,9 +44,9 @@ set_or_print_url()
4344

4445
package_url="${url_head}""${url_tail}"
4546

46-
# If a printout of the package URL was requested, then print it and exit with normal status
47-
if [[ ! -z "${arg_U:-}" ]]; then
48-
printf "${package_url}\n"
47+
# If a printout of the package URL was requested, then print it and exit with normal status
48+
if [[ ! -z "${arg_U:-}" ]]; then
49+
printf "%s\n" "${package_url}"
4950
exit 0
5051
fi
5152
}

0 commit comments

Comments
 (0)