From a5342b134da82c2cd3327c3ffdf22e948e2988d3 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 10 Nov 2026 19:52:30 -0500 Subject: [PATCH] packaging: use [[ for bash tests (SonarCloud S7688) (#13050) Behaviour-preserving: `[[ ]]` in place of `[ ]` for bash tests (SonarCloud shell:S7688). Every script has a bash shebang; no test uses `-a`/`-o`, escaped parentheses or an unquoted pattern on the right of `=`. `bash -n` passes on each script; the rest is left to CI. - `packaging/linux/apprun-cli-test.sh` (14) --- packaging/linux/apprun-cli-test.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/packaging/linux/apprun-cli-test.sh b/packaging/linux/apprun-cli-test.sh index f6a7ed8af8..966540220c 100755 --- a/packaging/linux/apprun-cli-test.sh +++ b/packaging/linux/apprun-cli-test.sh @@ -41,39 +41,39 @@ fail() { echo "FAIL: $*" >&2; exit 1; } out="$("$app_dir/AppRun" --cli convert 'input file.png' '' '*.psd' --out 'output file.psd')" expected=$'cli\n\n\n<>\n<*.psd>\n<--out>\n' -[ "$out" = "$expected" ] || fail "CLI arguments changed: $out" -[ "$("$app_dir/AppRun" --cli)" = cli ] || fail "empty CLI invocation" +[[ "$out" = "$expected" ]] || fail "CLI arguments changed: $out" +[[ "$("$app_dir/AppRun" --cli)" = cli ]] || fail "empty CLI invocation" # The AppImage runtime exposes the original symlink name through ARGV0. for argv0 in photocraft-cli ./photocraft-cli "$test_dir/with spaces/photocraft-cli"; do out="$(ARGV0="$argv0" "$app_dir/AppRun" --version)" - [ "$out" = $'cli\n<--version>' ] || fail "CLI symlink not selected: $argv0" + [[ "$out" = $'cli\n<--version>' ]] || fail "CLI symlink not selected: $argv0" done out="$(ARGV0=photocraft-cli "$app_dir/AppRun" --cli --version)" -[ "$out" = $'cli\n<--version>' ] || fail "CLI selector not removed with a symlink" +[[ "$out" = $'cli\n<--version>' ]] || fail "CLI selector not removed with a symlink" request='{"jsonrpc":"2.0","id":1,"method":"initialize"}' out="$(printf '%s\n' "$request" | "$app_dir/AppRun" --cli mcp 2>"$test_dir/stderr")" -[ "$out" = "$request" ] || fail "MCP stdin/stdout changed: $out" -[ "$(cat "$test_dir/stderr")" = 'cli stderr' ] || fail "CLI stderr lost" +[[ "$out" = "$request" ]] || fail "MCP stdin/stdout changed: $out" +[[ "$(cat "$test_dir/stderr")" = 'cli stderr' ]] || fail "CLI stderr lost" status=0 "$app_dir/AppRun" --cli --exit-37 || status=$? -[ "$status" = 37 ] || fail "CLI exit status changed: $status" -[ ! -e "$XDG_DATA_HOME" ] || fail "CLI performed desktop integration" +[[ "$status" = 37 ]] || fail "CLI exit status changed: $status" +[[ ! -e "$XDG_DATA_HOME" ]] || fail "CLI performed desktop integration" # GUI invocations still forward all arguments; only a leading --cli is a selector. out="$("$app_dir/AppRun" 'input file.png' --cli)" -[ "$out" = $'gui\n\n<--cli>' ] || fail "GUI arguments changed: $out" -[ -f "$XDG_DATA_HOME/applications/ai.storyteller.photocraft.desktop" ] || fail "GUI integration lost" +[[ "$out" = $'gui\n\n<--cli>' ]] || fail "GUI arguments changed: $out" +[[ -f "$XDG_DATA_HOME/applications/ai.storyteller.photocraft.desktop" ]] || fail "GUI integration lost" out="$(ARGV0=another-photocraft-cli "$app_dir/AppRun" mcp)" -[ "$out" = $'gui\n' ] || fail "an unrelated filename selected CLI" +[[ "$out" = $'gui\n' ]] || fail "an unrelated filename selected CLI" # A broken package must fail visibly, rather than silently opening the GUI. rm "$app_dir/usr/bin/photocraft-cli" status=0 "$app_dir/AppRun" --cli --version >"$test_dir/missing-out" 2>"$test_dir/missing-err" || status=$? -[ "$status" != 0 ] || fail "missing CLI succeeded" -[ ! -s "$test_dir/missing-out" ] || fail "missing CLI launched the GUI" -[ -s "$test_dir/missing-err" ] || fail "missing CLI had no diagnostic" +[[ "$status" != 0 ]] || fail "missing CLI succeeded" +[[ ! -s "$test_dir/missing-out" ]] || fail "missing CLI launched the GUI" +[[ -s "$test_dir/missing-err" ]] || fail "missing CLI had no diagnostic" echo "AppRun CLI selection ok"