Fix spotread exit code aborting scan under pipefail

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-13 14:15:18 +03:30
parent dea851dedc
commit 789a205904
2 changed files with 11 additions and 3 deletions

View File

@@ -96,11 +96,17 @@ check_dependencies() {
# ---------------------------------------------------------------- step 2
wait_for_instrument() {
info "Step 2/5: Waiting for i1Pro 2"
while spotread -? 2>&1 | grep -q '\*\* No ports found \*\*'; do
local ports
while true; do
# spotread -? exits 1 (usage), so capture output rather than piping.
ports="$(spotread -? 2>&1 || true)"
if ! grep -q '\*\* No ports found \*\*' <<<"$ports"; then
break
fi
echo " No instrument detected. Connect the i1Pro 2 via USB."
read -r -p " Press Enter to check again (or Ctrl+C to abort)... "
done
spotread -? 2>&1 | grep -E "^\s+[0-9]+ = " | sed 's/^/ Found:/'
grep -E "^\s+[0-9]+ = " <<<"$ports" | sed 's/^/ Found:/' || true
}
# ---------------------------------------------------------------- step 3+4

View File

@@ -18,7 +18,9 @@ if ! command -v spotread >/dev/null 2>&1; then
fi
echo "Checking for i1Pro..."
if spotread -? 2>&1 | grep -q '\*\* No ports found \*\*'; then
# spotread -? exits 1 (usage), so capture output rather than piping under pipefail.
PORTS="$(spotread -? 2>&1 || true)"
if grep -q '\*\* No ports found \*\*' <<<"$PORTS"; then
echo "Error: No USB instrument detected." >&2
echo " 1. Connect the i1Pro 2 via USB" >&2
echo " 2. Run: sudo ./setup-udev.sh" >&2