gulien / orbit

:satellite: A cross-platform task runner for executing commands and generating files from templates

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Orbit tasks fail if the caller shell is not compatible with the `run` expected shell

octplane opened this issue Β· comments

We found out that when designing a simple task such as:

run
      - |
        cat > foo.yml <<EOF
        app:
          name: {{ $.Orbit.Values.app.name }}
        EOF

it would fail for user having a shell not supporting this syntax (in my case, my fish shell is not happy about that:

fish: Expected a string, but instead found a redirection
cat > foo.yml <<EOF

Hi @octplane!

Indeed, Orbit is checking the SHELL environment variable on POSIX systems.
I'd suggest to run Orbit like this:

$ SHELL=/bin/your_shell orbit run your_task

It should solve your problem πŸ˜ƒ

If you don't want to specify the SHELL each time you're running Orbit, you could also have the following orbit.yml file:

tasks:
  
  - use: main_task
     run:
       - SHELL=/bin/your_shell orbit run sub_task

 - use: sub_task
    private: true
    run:
      - |
        cat > foo.yml <<EOF
        app:
          name: {{ $.Orbit.Values.app.name }}
        EOF 

πŸ‘

Actually this won't work with fish, because SHELL=/bin/your_shell is not a valid env variable declaration.

Ok I didn't know about that. So your PR is actually relevant, you should re-open it πŸ˜€

@octplane did you find a workaround or do you think that #28 should be the solution?

I have made an alias for my shell I the mean time and this works well. Not sure this is necessary to add an useless feature to the existing codebase for that kind of corner case. Maybe being more explicit about the default selected shell in the doc can make the trick.

I think this flag could serve for many other applications but not sure you want to apply this philosophy there too :) It could allow people to use other interpreters (such as ruby, python, ...) and have different shells for every task. This is also probably overkill...

I've updated the documentation to explain a bit about what's happening with shell selection: https://github.com/gulien/orbit/tree/documentation

Your PR is interesting because it allows to override the default behaviour πŸ˜„