ReviewOS

also looking at this

craft-native/craft

fix(shell): actually pass spawn its arguments

#77
Merged glennmichael123 wants to merge fix/shell-spawn-args into main
4 files +284 -11
packages/zig/src/js/craft-bridge.jsmodified+14-1
Changes to packages/zig/src/js/craft-bridge.js
@@ -633,9 +633,22 @@
633633 openExternal: function (url) { return _send('shell', 'openUrl', _stringify({ url: String(url) })) },
634634 openPath: function (path) { return _send('shell', 'openPath', _stringify({ path: String(path) })) },
635635 showInFinder: function (path) { return _send('shell', 'showInFinder', _stringify({ path: String(path) })) },
636 // spawn(id, command, args, opts)
637 //
638 // `command` is a program and `args` are its arguments — no shell is
639 // involved, so a `;` or `|` inside an argument reaches the program as a
640 // plain character rather than as syntax. Native used to run
641 // `sh -c command` and drop `args` on the floor entirely, so
642 // `spawn('p', 'git', ['status'])` ran `git` bare and reported success.
643 //
644 // `opts.shell = true` runs `command` as a command line through the
645 // platform shell instead. Arguments cannot be passed that way — a shell
646 // takes one string — so passing both is refused rather than half-honoured.
636647 spawn: function (id, cmd, args, opts) {
637648 return _send('shell', 'spawn', _stringify(Object.assign({
638 id: String(id), command: String(cmd), args: args || [],
649 id: String(id),
650 command: String(cmd),
651 args: (args || []).map(String),
639652 }, opts || {})))
640653 },
641654 kill: function (id) { return _send('shell', 'kill', _stringify({ id: String(id) })) },