Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decide whether to support cmd.exe or not #85

Closed
rdsubhas opened this issue Apr 27, 2017 · 3 comments
Closed

Decide whether to support cmd.exe or not #85

rdsubhas opened this issue Apr 27, 2017 · 3 comments
Labels
Milestone

Comments

@rdsubhas
Copy link
Member

rdsubhas commented Apr 27, 2017

cmd.exe support was recently contributed, thanks to @blaubaer. But we are discovering that there is more specifics involved:

  • Subshells ($(command ...))
  • Variable substitution ($VAR, ${VAR}, ${VAR:-default}, etc)
  • Environment variable cascading to further subcommands
  • Exit codes
  • Piping (foo | grep), Tests (&&, ||), I/O Redirection (>, >>)
  • Any other sh "standard" expectations that we miss?
  • cmd.exe vs powershell

Keeping this issue open and 1.0.0 release on hold until this is decided.

@rdsubhas rdsubhas added this to the v1.0.0 milestone Apr 27, 2017
@blaubaer
Copy link
Contributor

Using of UNIX features within myke config files is not a good idea in case of cross platform compatibility. The Windows shell works simply completely different and use different syntax.

  • Subshells ($(command ...))

Windows similar variant (nut not equal):
for /f "tokens=*" %%i in ('command ...') do set VAR=%%i

  • Variable substitution ($VAR, ${VAR}, ${VAR:-default}, etc)

Generally the CMD of windows uses %VAR% instead of $VAR or ${VAR}.

Environment variable cascading to further subcommands
Exit codes
Piping (foo | grep), Tests (&&, ||), I/O Redirection (>, >>)

This works similar. Could only be that this does not work 100% well we need tests that shows the expected and currently failing behavior.

Generally I propose the following:

  1. Remove the Golang Variable expansion from the code for Windows.
  2. Added all system stable variant to execute things like subshells, variables ({{.var}}), piping etc.
  3. Add a general warning if someone uses System specific commands or operations like $VAR, subshells etc.

...because the target should be to have a platform and system specific independent tool. Also specific differences in *nix system can lead to poor user experience in using such tool.

@rdsubhas
Copy link
Member Author

rdsubhas commented Apr 28, 2017

Yep @blaubaer it already takes a certain amount of knowledge to make a script work with both /bin/sh and /bin/bash, for example. So writing scripts that work in windows/linux is pretty much a big scope. Hence, I'd like to propose the following:

  • Already all CLI task aggregation tools (make, robo, etc linked on the README) have standardized around /bin/sh, which is cross platform

  • For v1.0.0, its may not be good to take such a big step forward, as it may postpone indefinitely

  • Let's standardize on /bin/sh as a minimum requirement, because end of the day, myke is primarily a script entrypoint/aggregator (makefile equivalent) and it doesn't actually do anything other than invoking tasks

  • For the next 1.1 release, we can add platform-specific commands for tasks. i.e.

    task:
      cmd:
        {{ if eq .platform windows }} windows commands {{ end }}
        {{ if eq .platform linux }} linux commands {{ end }}
    

We'll definitely get the semantics better (this is not a suggestion), but you get the overall gist :) This can be solved with templating, rather than trying to parse scripts and warn people on differences between /bin/sh, /bin/bash and cmd.exe, which will be a HUGE work of going through all these shell standards, and writing parsers for that.

@rdsubhas
Copy link
Member Author

rdsubhas commented May 7, 2017

Closing to release v1.0.0. /bin/sh is the default shell used across platforms. Supporting multiple shells is right now possible with a shell: argument in tasks, broad multi-shell compatibility across scripts is out of scope of myke - its the developer (or) script writer's call, and whether to support cmd.exe or powershell, and in general multi-shell support, is moved to a different issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants