Bug 15276 – Allow specification of shell for spawnShell/executeShell/pipeShell
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-11-02T20:31:00Z
Last change time
2016-03-19T20:22:03Z
Assigned to
markisaa
Creator
markisaa
Comments
Comment #0 by markisaa — 2015-11-02T20:31:32Z
We should allow callers to specify a particular shell to be used, be it sh, bash, zsh, or what the user has in their SHELL environment variable.
One of the things that made the fix for https://issues.dlang.org/show_bug.cgi?id=14282 so jarring is that there's no easy way to work around it to achieve the old behavior. That fix ended up being reverted.
Comment #2 by github-bugzilla — 2016-01-12T11:59:52Z
Commits pushed to master at https://github.com/D-Programming-Language/phoboshttps://github.com/D-Programming-Language/phobos/commit/963f7e4170fd02aa07c95562f2554807a8fe9178
Issue 15276: Allow users to specify shell for executeShell, pipeShell, spawnShell
This diff: This diff makes it possible to specify your preferred shell for the various `*shell` functions in `std.process`. By default it uses the new `nativeShell` function. `nativeShell` to always returns the native system shell (see the "some history" section for why this is the default value). I chose to create `nativeShell` rather than changeing `userShell` because I think it is still valuable to have something like `userShell` around in Phobos.
The one part of this diff I'm not super thrilled by is the use of variadic arguments (easier to see than to explain); if you have a suggestion for something better I'd love to hear it :).
Note: The default shell is a breaking change for Windows, which probably *should have* been broken same as posix in the diffs listed in the history section below, but I suspect was overlooked. Find rationale behind making a breaking change at all here: https://issues.dlang.org/show_bug.cgi?id=15000.
Some history:
https://github.com/D-Programming-Language/phobos/commit/a524a3571b18e440c4dd751fcf4e2d00b834fb22
and
https://github.com/D-Programming-Language/phobos/commit/f537cb50b5f8f9ad6d841db14b2e0a6cb845d008
Tried to move us from a world where we preferred the shell specified in the SHELL environment variable to a world where we always went with the native system shell, /bin/sh for posix. The former of those revisions was reverted in:
https://github.com/D-Programming-Language/phobos/commit/5b2b1fb59450cfc32ecec3252f543a9f6f34c2a4
Because the documentation was not updated to reflect the change.
Presently: we are in a state of schism, whereby `userShell` has behavior that does not align with what is actually used in `executeShell`, `pipeShell`, and `spawnShell`. This is something we *must* resolve.
Personal pain: This bit me when one of my scripts at work stopped working because it dependend on features that don't exist in `sh` (but do in `bash`, `zsh`, etc). It was really frustrating that there was no simple way to work around this and specify my preferred shell; it is, of course, possible to leverage the various `escape*` functions from `std.process` and `spawnProcess` to use whichever shell I prefer, but this seems like something warranting first class support. I was sad to not have something like this after a breaking change.
https://github.com/D-Programming-Language/phobos/commit/9284ee864c38eb062a4bcd57b4a44556fe878b94
Merge pull request #3900 from markisaa/issue_15276
Issue 15276: Allow users to specify shell for executeShell, pipeShell, spawnShell
Comment #3 by github-bugzilla — 2016-03-19T20:22:03Z