cortesi / modd

A flexible developer tool that runs processes and responds to filesystem changes
MIT License
2.79k stars 130 forks source link

Add PowerShell Support #48

Closed mhils closed 6 years ago

mhils commented 6 years ago

...and make it the default shell on Windows. The behaviour of bash.exe (if present) is quite variable, and a user that invokes modd from Windows itself does not expect that modd 'teleports' its commands into WSL or something alike. PowerShell is relatively compatible with bash as least as it supports the very basic unix commands such as cd.

alejandro5042 commented 6 years ago

We should also support PowerShell Core (pwsh.exe). Windows PowerShell (powershell.exe) won't be getting new development going forward; but it is still the only PS that ships with Windows.

I wonder if the @shell= should provide an option for any shell. For example:

@shell=powershell -command
@shell=pwsh -command

The line is appended to the end as an argument. That would give ultimate flexibility to the user.

cortesi commented 6 years ago

I want to think about this a bit more. Something that I really want to support is the ability to check a modd.conf into a repo, and be reasonably sure that it will work the same on everyone's systems, across platforms. This obviously doesn't work if the default shell is different on different systems, hence the current common default of bash.

I'm thinking of approaching this differently, and using one of the pure-Go, cross-platform shell implementations out there to support a built-in default for modd. The frontrunner at the moment, looking at code quality, testing, documentation and general approach is Oh:

https://github.com/michaelmacinnis/oh

Thoughts?

cortesi commented 6 years ago

This also looks pretty good, and aims to be POSIX and bash compatible:

https://github.com/mvdan/sh

mhils commented 6 years ago

That sounds good to me in general. Unless you want to remove the @shell configuration entirely, this should still be merged as-is though. It enables much better (default) behaviour on Windows, we can install one of the shells you mentioned as the default in a later PR. 😉

alejandro5042 commented 6 years ago

I have no opinion on changing the default shell. However, I would advocate against removing @shell. I work primarily on Windows and losing support for using PowerShell would be unfortunate. I have lots of modd scripts that would break. I also don't want to be forced to learn a new shell (e.g. oh) when my existing shell is well suited for the platform and I have a large library of helper scripts/modules.

The way it works now is great! Change the default shell, sure, but let me choose my own if I want to.

cortesi commented 6 years ago

@alejandro5042 That's the plan at this point - defaulting to a built-in shell, with the shell configuration variable remaining for people who want to use specific shells.

cortesi commented 6 years ago

modd now has a built-in shell, and PowerShell is officially supported as an alternative on all platforms.