From 21cf0db6e9024ed5ec3aa2a6b261b0eda9608aaa Mon Sep 17 00:00:00 2001 From: LM Date: Sat, 12 Sep 2026 20:10:41 +0200 Subject: [PATCH] Update shell tests for operand delimiters --- bin/omarchy-setup-security-fingerprint | 2 +- .../fingerprint-driver-migration-test.sh | 24 +++++++++++++++---- test/shell.d/fingerprint-package-test.sh | 11 +++++++-- test/shell.d/menu-guards-test.sh | 6 ++++- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/bin/omarchy-setup-security-fingerprint b/bin/omarchy-setup-security-fingerprint index e46aaed9..a57dea4a 100755 --- a/bin/omarchy-setup-security-fingerprint +++ b/bin/omarchy-setup-security-fingerprint @@ -80,7 +80,7 @@ fi # one transaction, so a failed install leaves the existing driver in place. if omarchy-pkg-missing libfprint-git fprintd usbutils; then echo "Installing required packages..." - sudo pacman -S --needed --noconfirm --ask 4 libfprint-git fprintd usbutils + sudo pacman -S --needed --noconfirm --ask 4 -- libfprint-git fprintd usbutils fi # Enroll first fingerprint diff --git a/test/shell.d/fingerprint-driver-migration-test.sh b/test/shell.d/fingerprint-driver-migration-test.sh index 6b3f523c..3164c2dd 100755 --- a/test/shell.d/fingerprint-driver-migration-test.sh +++ b/test/shell.d/fingerprint-driver-migration-test.sh @@ -24,12 +24,26 @@ STUB cat > "$scratch/bin/pacman" <<'STUB' #!/bin/bash case "$1" in - -Q) grep -qx "$2" <<< "${INSTALLED:-}" || grep -qx "$2" "$INSTALLED_LOG" ;; + -Q) + if [[ $2 == "--" ]]; then + shift 2 + else + shift + fi + if grep -qx -- "$1" <<< "${INSTALLED:-}"; then + : + else + grep -qx -- "$1" "$INSTALLED_LOG" + fi + ;; -S) printf 'pacman %s\n' "$*" >> "$CALL_LOG" - for arg in "$@"; do - [[ $arg == -* ]] || printf '%s\n' "$arg" >> "$INSTALLED_LOG" - done + if [[ $4 == "--" ]]; then + shift 4 + for arg in "$@"; do + printf '%s\n' "$arg" >> "$INSTALLED_LOG" + done + fi ;; *) printf 'pacman %s\n' "$*" >> "$CALL_LOG" ;; esac @@ -44,7 +58,7 @@ run_migration() { } INSTALLED='fprintd' run_migration -grep -qx 'pacman -S --noconfirm --needed libfprint-git' "$CALL_LOG" || fail "fprintd without a library gets libfprint-git" +grep -qx 'pacman -S --noconfirm --needed -- libfprint-git' "$CALL_LOG" || fail "fprintd without a library gets libfprint-git" pass "fprintd without a library gets libfprint-git" INSTALLED=$'libfprint-git\nfprintd' run_migration diff --git a/test/shell.d/fingerprint-package-test.sh b/test/shell.d/fingerprint-package-test.sh index 70329982..efc14fcc 100755 --- a/test/shell.d/fingerprint-package-test.sh +++ b/test/shell.d/fingerprint-package-test.sh @@ -30,7 +30,14 @@ STUB cat > "$scratch/bin/pacman" <<'STUB' #!/bin/bash case "$1" in - -Q) grep -qx "$2" <<< "${INSTALLED:-}" ;; + -Q) + if [[ $2 == "--" ]]; then + shift 2 + else + shift + fi + grep -qx -- "$1" <<< "${INSTALLED:-}" + ;; -S) printf 'pacman %s\n' "$*" >> "$CALL_LOG" exit "${INSTALL_STATUS:-0}" @@ -62,7 +69,7 @@ run_setup() { } assert_installs() { - grep -qx 'pacman -S --needed --noconfirm --ask 4 libfprint-git fprintd usbutils' "$CALL_LOG" || fail "$1" + grep -qx 'pacman -S --needed --noconfirm --ask 4 -- libfprint-git fprintd usbutils' "$CALL_LOG" || fail "$1" (( $(grep -c '^pacman ' "$CALL_LOG") == 1 )) || fail "$1: one pacman transaction" } diff --git a/test/shell.d/menu-guards-test.sh b/test/shell.d/menu-guards-test.sh index 660d77c5..546596ce 100755 --- a/test/shell.d/menu-guards-test.sh +++ b/test/shell.d/menu-guards-test.sh @@ -118,7 +118,11 @@ Version : 9.2-1 INFO ;; -Q) - shift + if [[ $2 == "--" ]]; then + shift 2 + else + shift + fi for want in "$@"; do case "${want%%[<>=]*}" in bash | gvim | sh | vim | xxd) ;; *) exit 1 ;; esac done