Bookmarks with shell glob patterns fail — spawnShellCommand uses /bin/sh instead of user's shell
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- javascript, node.js, shell
- Domain
- cli
Research direction
Start in index.js at spawnShellCommand around lines 53–54, then reproduce the bookmark examples from the issue with the :or and :brace render modes. Done means those commands execute with the appropriate user shell and retain the documented fallback when $SHELL is unset.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- JavaScript
- Stars
- 13
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from danieldelcore/scriptpal
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
danieldelcore/scriptpal#33 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
danieldelcore/scriptpal#21 ·
-
Workspace mode Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
danieldelcore/scriptpal#38 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
danieldelcore/scriptpal#34 ·
-
help wanted
Difficulty 3/5 1-2 days Newbie friendliness 35/100
danieldelcore/scriptpal#5 · 2 comments ·
All issues in danieldelcore/scriptpal
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·