danieldelcore / danieldelcore/scriptpal
Bookmarks with shell glob patterns fail — spawnShellCommand uses /bin/sh instead of user's shell
- Vorherrschende Sprache
- JavaScript
- Sterne
- 13
- Forks
- 0
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Bookmark commands that contain shell-specific glob or expansion syntax fail at runtime because spawnShellCommand uses /bin/sh (POSIX sh) via Node.js spawnSync(..., { shell: true }).
POSIX sh doesn't support:
Extended glob alternation: (a|b|c) (zsh)
Brace expansion: {a,b,c} (bash/zsh)
This means the :or and :brace array render modes in wildcards produce output that can never actually execute successfully.
Repro
```
scriptpal bookmark add demo 'echo packages/(foo|bar|baz)'
scriptpal bookmark run demo
# /bin/sh: -c: line 0: syntax error near unexpected token `|'
```
Or using the :or wildcard renderer:
```
scriptpal bookmark add typecheck 'yarn typecheck:package packages/${pkg:array:or}'
scriptpal bookmark run typecheck pkg=foo,bar
# /bin/sh: -c: line 0: syntax error near unexpected token `|'
```
Root cause
```
// index.js line 53-54
function spawnShellCommand(command) {
const result = spawnSync(command, { stdio: "inherit", shell: true });
```
When shell: true, Node.js defaults to /bin/sh on Unix. /bin/sh is POSIX-only and rejects the syntax that :or and :brace renderers produce.
Proposed fix
Use the user's login shell ($SHELL) instead of the default:
```
function spawnShellCommand(command) {
const result = spawnSync(command, {
stdio: "inherit",
shell: process.env.SHELL || true,
});
```
When the shell option is a string, Node.js uses that binary. This means:
zsh users get (a|b) extended glob support
bash users get {a,b} brace expansion support
Falls back to the default /bin/sh if $SHELL is unset
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne in index.js bei spawnShellCommand um die Zeilen 53–54 und reproduziere dann die Bookmark-Beispiele aus dem Issue mit den Render-Modi :or und :brace. Fertig ist die Aufgabe, wenn diese Befehle mit der entsprechenden Shell des Benutzers ausgeführt werden und das dokumentierte Fallback beibehalten wird, wenn $SHELL nicht gesetzt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, node.js, shell
- Bereich
- cli
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Ruhig
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 76/100