Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions ops/platform-acceptance/macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ mkdir -p "$DATA_ROOT"
printf '%s\n' server >"$DATA_ROOT/desktop-mode"
open -n "$installed" --args --1helm-background
for _ in {1..180}; do
PORT="$(lsof -nP -a -c 1Helm -iTCP -sTCP:LISTEN 2>/dev/null | awk '/127\.0\.0\.1:/ {split($9,a,":"); print a[length(a)]; exit}')"
PORT="$(lsof -nP -a -u "$(id -un)" -c 1Helm -iTCP -sTCP:LISTEN 2>/dev/null | awk '/127\.0\.0\.1:/ {split($9,a,":"); print a[length(a)]; exit}')"
[[ "$PORT" =~ ^[0-9]+$ ]] && curl -fsS "http://127.0.0.1:$PORT/api/setup/status" >"$work/clean-health.json" && break
sleep 1
done
[[ -s "$work/clean-health.json" ]]
osascript -e 'tell application id "com.gitcommit90.1helm" to quit' || true
for _ in {1..30}; do pgrep -x 1Helm >/dev/null || break; sleep 1; done
! pgrep -x 1Helm >/dev/null
for _ in {1..30}; do pgrep -x -U "$(id -u)" 1Helm >/dev/null || break; sleep 1; done
! pgrep -x -U "$(id -u)" 1Helm >/dev/null
Comment on lines +78 to +79

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu

file="ops/platform-acceptance/macos.sh"
printf '%s\n' '--- target file ---'
sed -n '1,180p' "$file"

printf '%s\n' '--- pgrep usage ---'
rg -n -C 4 'pgrep|1Helm' "$file"

printf '%s\n' '--- repository references ---'
rg -n -C 3 'shutdown|platform-acceptance|macos\.sh|pgrep -x -U' . --glob '!node_modules' --glob '!dist' --glob '!build' | head -300

Repository: gitcommit90/1Helm

Length of output: 40067


🏁 Script executed:

#!/bin/bash
set -eu

file="ops/platform-acceptance/macos.sh"
sed -n '1,180p' "$file"
rg -n -C 4 'pgrep|1Helm' "$file"

Repository: gitcommit90/1Helm

Length of output: 16362


🏁 Script executed:

#!/bin/bash
set -eu

python3 - <<'PY'
from pathlib import Path
text = Path("ops/platform-acceptance/macos.sh").read_text()
gates = []
lines = text.splitlines()
for i, line in enumerate(lines, 1):
    if 'for _ in {1..30}; do pgrep -x -U' in line:
        gates.append((i, i + 1, lines[i-1:i+1]))
print("shutdown_gates=", len(gates))
for start, end, block in gates:
    print(f"{start}-{end}:")
    print("\n".join(block))
PY

tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT

cat >"$tmp/pgrep" <<'SH'
#!/bin/sh
case "${FAKE_PGREP_STATUS:-1}" in
  0) exit 0 ;;
  1) exit 1 ;;
  2) printf '%s\n' 'synthetic pgrep failure' >&2; exit 2 ;;
  *) exit "$FAKE_PGREP_STATUS" ;;
esac
SH
chmod +x "$tmp/pgrep"

cat >"$tmp/probe.sh" <<'SH'
#!/usr/bin/env bash
set -euo pipefail
for _ in {1..1}; do pgrep -x -U "$(id -u)" 1Helm >/dev/null || break; sleep 1; done
! pgrep -x -U "$(id -u)" 1Helm >/dev/null
printf '%s\n' "completed"
SH
chmod +x "$tmp/probe.sh"

for status in 0 1 2; do
  printf 'existing_status=%s: ' "$status"
  if PATH="$tmp:$PATH" FAKE_PGREP_STATUS="$status" "$tmp/probe.sh" >/tmp/probe.out 2>/tmp/probe.err; then
    printf 'exit=0 '
  else
    printf 'exit=%s ' "$?"
  fi
  printf 'stdout=%s stderr=%s\n' "$(tr '\n' '|' </tmp/probe.out)" "$(tr '\n' '|' </tmp/probe.err)"
done

cat >"$tmp/strict_probe.sh" <<'SH'
#!/usr/bin/env bash
set -euo pipefail
for _ in {1..1}; do
  if pgrep -x -U "$(id -u)" 1Helm >/dev/null; then
    sleep 0
  else
    status=$?
    case "$status" in
      1) break ;;
      *) exit "$status" ;;
    esac
  fi
done
if pgrep -x -U "$(id -u)" 1Helm >/dev/null; then
  exit 1
else
  status=$?
  case "$status" in
    1) ;;
    *) exit "$status" ;;
  esac
fi
printf '%s\n' "completed"
SH
chmod +x "$tmp/strict_probe.sh"

for status in 0 1 2; do
  printf 'strict_status=%s: ' "$status"
  if PATH="$tmp:$PATH" FAKE_PGREP_STATUS="$status" "$tmp/strict_probe.sh" >/tmp/strict.out 2>/tmp/strict.err; then
    printf 'exit=0 '
  else
    printf 'exit=%s ' "$?"
  fi
  printf 'stdout=%s stderr=%s\n' "$(tr '\n' '|' </tmp/strict.out)" "$(tr '\n' '|' </tmp/strict.err)"
done

Repository: gitcommit90/1Helm

Length of output: 937


🌐 Web query:

macOS pgrep man page exit status 0 1 2 3

💡 Result:

On macOS, the pgrep utility uses the following exit status codes [1][2]: 0: One or more processes were matched [1][2]. 1: No processes were matched [1][2]. 2: Invalid options were specified on the command line [1][2]. 3: An internal error occurred [1][2]. These codes are consistent with the BSD implementation of pgrep found on macOS [1][3][2]. While Linux implementations of pgrep (part of procps) often use the same exit codes for the same conditions, they may include additional context in their documentation regarding pkill (e.g., specifying that a signal must be successfully sent) [4][5]. On macOS, pgrep's exit status is commonly used in shell scripts to control flow, such as checking if a process is running before executing a command [6].

Citations:


🏁 Script executed:

#!/bin/bash
set -eu

tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT

cat >"$tmp/pgrep" <<'SH'
#!/bin/sh
exit "${FAKE_PGREP_STATUS:-1}"
SH
chmod +x "$tmp/pgrep"

cat >"$tmp/probe.sh" <<'SH'
#!/usr/bin/env bash
set -euo pipefail
for _ in {1..1}; do
  pgrep -x -U "$(id -u)" 1Helm >/dev/null || break
  sleep 1
done
! pgrep -x -U "$(id -u)" 1Helm >/dev/null
printf '%s\n' completed
SH
chmod +x "$tmp/probe.sh"

for status in 0 1 2 3; do
  if PATH="$tmp:$PATH" FAKE_PGREP_STATUS="$status" "$tmp/probe.sh" >/tmp/probe.out 2>/tmp/probe.err; then
    result=0
  else
    result=$?
  fi
  printf 'status=%s exit=%s output=%s\n' "$status" "$result" "$(tr '\n' '|' </tmp/probe.out)"
done

Repository: gitcommit90/1Helm

Length of output: 291


Fail closed on pgrep errors.

Treat only status 1 as “1Helm is absent”. Propagate all other non-zero statuses from the wait loops and final checks. Apply this to lines 78–79, 132–133, and 147–148.

🧰 Tools
🪛 Shellcheck (0.11.0)

[info] 79-79: This ! is not on a condition and skips errexit. Use && exit 1 instead, or make sure $? is checked.

(SC2251)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ops/platform-acceptance/macos.sh` around lines 78 - 79, Update the process
checks in the wait loops and final checks at the three indicated locations to
treat only pgrep exit status 1 as “1Helm” absent; propagate every other non-zero
status, including errors, instead of converting them to success or failure based
solely on command negation.

Source: Linters/SAST tools


# Reset the dedicated account, install the latest immutable prior Stable DMG,
# then apply the exact candidate updater ZIP while Application Support remains.
Expand Down Expand Up @@ -123,29 +123,29 @@ printf '%s\n' "phase4-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" >"$DATA_ROOT/phase4-ac
STATE_BEFORE="$(shasum -a 256 "$DATA_ROOT/phase4-acceptance-state" | awk '{print $1}')"
open -n "$installed" --args --1helm-background
for _ in {1..180}; do
PORT="$(lsof -nP -a -c 1Helm -iTCP -sTCP:LISTEN 2>/dev/null | awk '/127\.0\.0\.1:/ {split($9,a,":"); print a[length(a)]; exit}')"
PORT="$(lsof -nP -a -u "$(id -un)" -c 1Helm -iTCP -sTCP:LISTEN 2>/dev/null | awk '/127\.0\.0\.1:/ {split($9,a,":"); print a[length(a)]; exit}')"
[[ "$PORT" =~ ^[0-9]+$ ]] && curl -fsS "http://127.0.0.1:$PORT/api/setup/status" >"$work/prior-health.json" && break
sleep 1
done
[[ -s "$work/prior-health.json" ]]
osascript -e 'tell application id "com.gitcommit90.1helm" to quit' || true
for _ in {1..30}; do pgrep -x 1Helm >/dev/null || break; sleep 1; done
! pgrep -x 1Helm >/dev/null
for _ in {1..30}; do pgrep -x -U "$(id -u)" 1Helm >/dev/null || break; sleep 1; done
! pgrep -x -U "$(id -u)" 1Helm >/dev/null
rm -rf -- "$installed"
ditto "$work/update/1Helm.app" "$installed"
[[ "$(defaults read "$installed/Contents/Info" CFBundleShortVersionString)" == "$VERSION" ]]
open -n "$installed" --args --1helm-background
for _ in {1..180}; do
PORT="$(lsof -nP -a -c 1Helm -iTCP -sTCP:LISTEN 2>/dev/null | awk '/127\.0\.0\.1:/ {split($9,a,":"); print a[length(a)]; exit}')"
PORT="$(lsof -nP -a -u "$(id -un)" -c 1Helm -iTCP -sTCP:LISTEN 2>/dev/null | awk '/127\.0\.0\.1:/ {split($9,a,":"); print a[length(a)]; exit}')"
[[ "$PORT" =~ ^[0-9]+$ ]] && curl -fsS "http://127.0.0.1:$PORT/api/setup/status" >"$work/update-health.json" && break
sleep 1
done
[[ -s "$work/update-health.json" ]]
STATE_AFTER="$(shasum -a 256 "$DATA_ROOT/phase4-acceptance-state" | awk '{print $1}')"
[[ "$STATE_BEFORE" == "$STATE_AFTER" ]]
osascript -e 'tell application id "com.gitcommit90.1helm" to quit' || true
for _ in {1..30}; do pgrep -x 1Helm >/dev/null || break; sleep 1; done
! pgrep -x 1Helm >/dev/null
for _ in {1..30}; do pgrep -x -U "$(id -u)" 1Helm >/dev/null || break; sleep 1; done
! pgrep -x -U "$(id -u)" 1Helm >/dev/null

export HELM_STATE_BEFORE_SHA256="$STATE_BEFORE" HELM_STATE_AFTER_SHA256="$STATE_AFTER"
export HELM_PREVIOUS_VERSION="$PREVIOUS_VERSION"
Expand Down
Loading