also looking at this
fix(shell): actually pass spawn its arguments
#77
4 files
+284
-11
| @@ -633,9 +633,22 @@ | ||
| 633 | 633 | openExternal: function (url) { return _send('shell', 'openUrl', _stringify({ url: String(url) })) }, |
| 634 | 634 | openPath: function (path) { return _send('shell', 'openPath', _stringify({ path: String(path) })) }, |
| 635 | 635 | 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. | |
| 636 | 647 | spawn: function (id, cmd, args, opts) { |
| 637 | 648 | 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), | |
| 639 | 652 | }, opts || {}))) |
| 640 | 653 | }, |
| 641 | 654 | kill: function (id) { return _send('shell', 'kill', _stringify({ id: String(id) })) }, |