From fab18a312bed07bec965f6b199c230c4378a25f1 Mon Sep 17 00:00:00 2001 From: Sandor Semsey Date: Tue, 11 Nov 2025 00:00:06 +0100 Subject: [PATCH 1/3] shell: use correct parameter expansion for unset argument error message --- bin/benchmark | 8 ++++---- bin/generate-moduli | 4 ++-- bin/pass-man | 4 ++-- bin/sign-kernel-modules | 6 +++--- bin/test-dd-write | 4 ++-- lib/certificate.sh | 42 ++++++++++++++++++++--------------------- lib/dev.sh | 12 ++++++------ lib/git.sh | 10 +++++----- lib/github.sh | 42 ++++++++++++++++++++--------------------- lib/network.sh | 4 ++-- lib/process.sh | 6 +++--- lib/ssh.sh | 30 ++++++++++++++--------------- 12 files changed, 86 insertions(+), 86 deletions(-) diff --git a/bin/benchmark b/bin/benchmark index 1219989..40e1413 100755 --- a/bin/benchmark +++ b/bin/benchmark @@ -18,7 +18,7 @@ ############ # Version -version=1.2.4 +version=1.2.5 # Individual benchmark time limit (seconds) # Quick benchmark test_run_time_quick=6 @@ -168,7 +168,7 @@ _cpu-app-test() { ## @param $@ Params for benchmark ##################################### _run-benchmark() { - local type="${1?:Benchmark type missing}" + local type="${1:?Benchmark type missing}" local params=("--time=${test_run_time}") # Compile params @@ -200,8 +200,8 @@ _run-benchmark() { ## @param $2 Raw results ####################################### _filter-results() { - local type="${1?:Benchmark type missing}" - local raw="${2?:Raw results missing}" + local type="${1:?Benchmark type missing}" + local raw="${2:?Raw results missing}" local filter case "${type}" in diff --git a/bin/generate-moduli b/bin/generate-moduli index 4ba4bc0..bf651fe 100755 --- a/bin/generate-moduli +++ b/bin/generate-moduli @@ -16,8 +16,8 @@ ## @param $2 Output file path ######################################### _generate-DH-primes() { - local bit="${1?:Bit missing}" - local output_file="${2?:Output file name missing}" + local bit="${1:?Bit missing}" + local output_file="${2:?Output file name missing}" local candidates candidates=$(mktemp --tmpdir DH_candidates.XXXXXXXX) diff --git a/bin/pass-man b/bin/pass-man index 5a30894..8204ed8 100755 --- a/bin/pass-man +++ b/bin/pass-man @@ -15,7 +15,7 @@ _usage() { cat </dev/null 2>&1 } diff --git a/lib/ssh.sh b/lib/ssh.sh index 2295c39..ee6f883 100644 --- a/lib/ssh.sh +++ b/lib/ssh.sh @@ -13,8 +13,8 @@ ## @default 12 hours ################################# unlock-key() { - local key="${1?:Path to SSH key missing}" - local pass_path="${2?:Path to password missing}" + local key="${1:?Path to SSH key missing}" + local pass_path="${2:?Path to password missing}" local cache_time="${3:-12h}" local password public_key current_identities @@ -74,8 +74,8 @@ ssh-tunnel-close() { ## @param $2 Local port ############################ socks5-tunnel-open() { - local remote="${1?:Remote missing}" - local port="${2?:Local port missing}" + local remote="${1:?Remote missing}" + local port="${2:?Local port missing}" ssh-tunnel-open -fqN -D "${port}" "${remote}" } @@ -85,8 +85,8 @@ socks5-tunnel-open() { ## @param $2 Local port ############################ socks5-tunnel-close() { - local remote="${1?:Remote missing}" - local port="${2?:Local port missing}" + local remote="${1:?Remote missing}" + local port="${2:?Local port missing}" ssh-tunnel-close -fqN -D "${port}" "${remote}" } @@ -96,8 +96,8 @@ socks5-tunnel-close() { ## @param $2 Comment for key ################################ ssh-create-key() { - local key_name="${1?:Key name missing}" - local comment="${2?:Key comment missing}" + local key_name="${1:?Key name missing}" + local comment="${2:?Key comment missing}" shift 2 ssh-keygen \ -t ed25519 \ @@ -117,12 +117,12 @@ ssh-create-key() { ## @param $6 Path to user public key - this will be signed ############################################################## ssh-sign-user() { - local validity="${1?:Validity interval missing}" - local ca_key_path="${2?:Path to CA key missing}" - local identity="${3?:Key identity missing}" - local principals="${4?:Principals missing}" - local serial="${5?:Serial number missing}" - local pubkey_path="${6?:User public key path missing}" + local validity="${1:?Validity interval missing}" + local ca_key_path="${2:?Path to CA key missing}" + local identity="${3:?Key identity missing}" + local principals="${4:?Principals missing}" + local serial="${5:?Serial number missing}" + local pubkey_path="${6:?User public key path missing}" shift 6 ssh-keygen \ -V "${validity}" \ @@ -138,7 +138,7 @@ ssh-sign-user() { ## @param $1 Path to certificate #################################### ssh-view-cert() { - local cert="${1?:Certificate path missing}" + local cert="${1:?Certificate path missing}" shift ssh-keygen -L -f "${cert}" "${@}" } From 80dcc64715ed598d046143524313e55d9064709a Mon Sep 17 00:00:00 2001 From: Sandor Semsey Date: Tue, 11 Nov 2025 01:15:01 +0100 Subject: [PATCH 2/3] shell: remove unneeded quotes inside parameter expansion --- lib/text.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/text.sh b/lib/text.sh index c12854f..5c0e11e 100644 --- a/lib/text.sh +++ b/lib/text.sh @@ -63,7 +63,7 @@ urlencode() { ## @param $1 String to decode ################################ urldecode() { - local encoded="${1:?"URL-encoded string missing"}" + local encoded="${1:?URL-encoded string missing}" # Change + to space encoded="${encoded//+/ }" From d3006d286d9aadd2965dd542c12a182f925cbfbb Mon Sep 17 00:00:00 2001 From: Sandor Semsey Date: Mon, 17 Nov 2025 14:15:15 +0100 Subject: [PATCH 3/3] beautysh: ignore switch cases --- bin/backup | 3 +++ bin/benchmark | 3 +++ bin/clean | 3 +++ bin/pass-man | 3 +++ 4 files changed, 12 insertions(+) diff --git a/bin/backup b/bin/backup index a051c36..0a71fbe 100755 --- a/bin/backup +++ b/bin/backup @@ -86,6 +86,8 @@ expire_date= archive_prefix= quiet=() +# @formatter:off +# TEMP: remove when https://github.com/lovesegfault/beautysh/issues/265 is fixed while :; do case "${1:-}" in -s | --source) @@ -170,6 +172,7 @@ while :; do esac shift done +# @formatter:on check-root diff --git a/bin/benchmark b/bin/benchmark index 40e1413..52ebb40 100755 --- a/bin/benchmark +++ b/bin/benchmark @@ -362,6 +362,8 @@ report_file_prefix= sys_check= benchmark_depth= params_file= +# @formatter:off +# TEMP: remove when https://github.com/lovesegfault/beautysh/issues/265 is fixed while :; do case "${1:-}" in -r | --report) create_report=1 ;; @@ -399,6 +401,7 @@ while :; do esac shift done +# @formatter:on if [[ -z "${sys_check}" && -z "${benchmark_depth}" ]]; then echo "Benchmark depth missing (quick or full)" >&2 diff --git a/bin/clean b/bin/clean index 4b3162c..25aabe5 100755 --- a/bin/clean +++ b/bin/clean @@ -64,6 +64,8 @@ journal_retention=2w quiet=() redirection=/dev/stdout +# @formatter:off +# TEMP: remove when https://github.com/lovesegfault/beautysh/issues/265 is fixed while :; do case "${1:-}" in -j | --journal) @@ -92,6 +94,7 @@ while :; do esac shift done +# @formatter:on uid=$(id -u) if [[ "${uid}" -ne 0 ]]; then diff --git a/bin/pass-man b/bin/pass-man index 8204ed8..f73159c 100755 --- a/bin/pass-man +++ b/bin/pass-man @@ -97,6 +97,8 @@ action="${1:-}" [[ -n "${action}" ]] && shift # Switch action +# @formatter:off +# TEMP: remove when https://github.com/lovesegfault/beautysh/issues/265 is fixed case "${action}" in open) _vault-open "${@}" ;; close) _vault-close "${@}" ;; @@ -114,5 +116,6 @@ case "${action}" in "") print-error Action missing && _usage ;; *) print-error Invalid action && _usage ;; esac +# @formatter:on exit 0