Skip to content

Commit f8c1528

Browse files
committed
build
1 parent ba28e86 commit f8c1528

1 file changed

Lines changed: 15 additions & 22 deletions

File tree

usr/share/usability-misc/dist-installer-cli-standalone

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -136,28 +136,18 @@ fi
136136
## Copyright (C) 2025 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
137137
## See the file COPYING for copying conditions.
138138

139-
## Code duplication. Copied from
140-
## helper-scripts/usr/libexec/helper-scripts/check_runtime.bsh.
141-
##
142-
## Because check_runtime.bsh cannot be sourced here (this will be run when
139+
## check_runtime.bsh cannot be sourced here (this will be run when
143140
## derivative-maker is used, and the build host may not have helper-scripts
144141
## installed).
145-
was_executed() {
146-
local caller_bash_source_zero="${1}"
147-
if [[ "${caller_bash_source_zero}" == "${0}" ]] \
148-
|| [[ "${caller_bash_source_zero}" == "$(command -v "${0}")" ]]; then
149-
return 0
150-
fi
151-
return 1
152-
}
153-
should_run_unit_tests() {
154-
local caller_bash_source_zero="${1}"
155-
if was_executed "${caller_bash_source_zero}" \
156-
&& ! [ "${SKIP_UNIT_TESTS-}" = 'true' ]; then
157-
return 0
158-
fi
159-
return 1
160-
}
142+
## Literal code duplication is bad.
143+
## Confuses shellcheck for dist-installer-cli-standalone.
144+
if test -f /usr/libexec/helper-scripts/check_runtime.bsh; then
145+
## Use 'source_encoded' to avoid
146+
## /usr/share/usability-misc/build-dist-installer-cli
147+
## from in-lining the source code.
148+
source_encoded=source
149+
"$source_encoded" /usr/libexec/helper-scripts/check_runtime.bsh
150+
fi
161151

162152
br_add() {
163153
local in out
@@ -541,8 +531,11 @@ strings_bsh_error_trap() {
541531

542532
## Useful in case this script is copied verbatim into another script such as
543533
## in package 'usability-misc' file 'dist-installer-cli-standalone'.
544-
if should_run_unit_tests "${BASH_SOURCE[0]}"; then
545-
string_bsh_tests
534+
## Another option would be to move the unit testing out of this script.
535+
if declare -F should_run_unit_tests >/dev/null; then
536+
if should_run_unit_tests "${BASH_SOURCE[0]}"; then
537+
string_bsh_tests
538+
fi
546539
fi
547540

548541
#trim_collapse_split " aaa bbb ccc ddd "

0 commit comments

Comments
 (0)