Commit 212f64c
PLN-228: harden install.sh with bash guard, jq hard prereq, idempotent state detection, and BSD-portable stderr sanitizer
Builds on the earlier error-surfacing work to cover the remaining PLN-228
acceptance criteria and fix three bugs uncovered during end-to-end
verification on macOS.
Scope covered:
- AC-001, AC-006: marketplace idempotency via `claude plugin marketplace
list --json`; re-run prints "Marketplace already registered: <name>"
instead of re-running `add`.
- AC-007, AC-010: pre/post snapshots via `claude plugin list --json`
classify each plugin as Installed / Updated / Already up to date, so
the three states are distinguishable without parsing CLI stdout.
- AC-008: summary line now reports all three counts separately while
preserving the failed count.
- AC-011: POSIX-portable `BASH_VERSION` guard at script top exits cleanly
under dash/ash before any bash-only syntax runs. `sh install.sh` on
macOS still passes because `/bin/sh` is bash in POSIX mode — documented
as a known limitation in the script comments.
- AC-012: `jq` promoted from soft warn to hard prereq, with brew/apt
install instructions printed before any marketplace or plugin ops.
- Per-run `${TMPDIR:-/tmp}/closedloop-install.XXXXXX` work dir cleaned up
via EXIT trap for stderr capture and snapshot files.
Bugs fixed during verification:
- snapshot_version: add `|| true` so an empty grep match in the
classification command substitution no longer trips `set -e`. Without
this, a fresh install successfully installed all 6 plugins but
errexited before printing any per-plugin status or the summary.
- UP_TO_DATE branch: emit `info "Already up to date: <plugin>"` so
AC-007's third distinct message is actually visible on re-runs; the
counter alone didn't satisfy the AC.
- sanitize_stderr: replace GNU-sed-only `\x1b` / `\x00-\x08` escapes
with a literal ESC via bash ANSI-C quoting plus `tr` octal ranges so
the function works under BSD sed (macOS). Previously it errored with
"RE error: invalid character range" and silently swallowed the very
CLI error AC-002/AC-004/AC-005 require to be shown.
Verified end-to-end on macOS (bash 3.2):
- Fresh install: 6× "Installed: <plugin>"; summary "6 installed, 0
updated, 0 already up to date".
- Idempotent re-run: "Marketplace already registered: closedloop-ai",
6× "Already up to date: <plugin>", summary "0 installed, 0 updated,
6 already up to date".
- Bogus MARKETPLACE_SOURCE: underlying `claude` CLI error surfaced via
sanitize_stderr (AC-005).
- `dash install.sh`: guard fires, exits 1 with the guidance message.
- `jq` hidden from PATH: preflight exits 1 with brew/apt instructions
before any marketplace/plugin ops.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 351093b commit 212f64c
1 file changed
Lines changed: 88 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
13 | 24 | | |
14 | 25 | | |
15 | 26 | | |
| |||
20 | 31 | | |
21 | 32 | | |
22 | 33 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
28 | 46 | | |
29 | 47 | | |
30 | 48 | | |
31 | 49 | | |
32 | 50 | | |
33 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
34 | 58 | | |
35 | 59 | | |
36 | 60 | | |
| |||
50 | 74 | | |
51 | 75 | | |
52 | 76 | | |
53 | | - | |
54 | | - | |
| 77 | + | |
| 78 | + | |
55 | 79 | | |
56 | 80 | | |
57 | 81 | | |
| |||
62 | 86 | | |
63 | 87 | | |
64 | 88 | | |
65 | | - | |
66 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
67 | 94 | | |
68 | | - | |
69 | | - | |
| 95 | + | |
70 | 96 | | |
71 | 97 | | |
72 | 98 | | |
73 | 99 | | |
74 | 100 | | |
75 | 101 | | |
76 | 102 | | |
77 | | - | |
78 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
79 | 107 | | |
80 | | - | |
81 | | - | |
82 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
83 | 111 | | |
84 | | - | |
| 112 | + | |
| 113 | + | |
85 | 114 | | |
86 | 115 | | |
87 | 116 | | |
| |||
91 | 120 | | |
92 | 121 | | |
93 | 122 | | |
| 123 | + | |
| 124 | + | |
94 | 125 | | |
95 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
96 | 137 | | |
97 | | - | |
98 | | - | |
99 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
100 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
101 | 164 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
| 165 | + | |
| 166 | + | |
114 | 167 | | |
115 | 168 | | |
116 | 169 | | |
117 | 170 | | |
118 | 171 | | |
119 | 172 | | |
| 173 | + | |
120 | 174 | | |
121 | 175 | | |
122 | | - | |
| 176 | + | |
123 | 177 | | |
124 | | - | |
| 178 | + | |
125 | 179 | | |
126 | 180 | | |
127 | 181 | | |
| |||
0 commit comments