catks / djin

Djin is a make-like utility for docker, docker-compose and local commands

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[TECH] Change Task execution

catks opened this issue · comments

Currently, djin transforms any sequence of commands in a single command joined with &&, although it works fine in most cases, there are some caveats that can cause unexpected behavior, for example when running commands with or, eg:

  release:
    local:
      run:
        - command_that_can_fail
        - echo 'I am Here' || echo 'I shouldn’t  be here' 

This will be translated to command_that_can_fail && echo 'I am Here' || echo 'I shouldn’t be here, so if the first command fails will actually execute the echo 'I shouldn’t be here', of course this can be fixed with (), like so:

  release:
    local:
      run:
         - command_that_can_fail
        - (echo 'I am Here' || echo 'I shouldn’t  be here') 

But shouldn't be needed.

An easier approach is to insert () when joining every command, but is also not a good solution as can cause other problems, one good solution is to have a shell session that can be handled like a IO object so he can iterate and send each command capturing the STDOUT and STDERR, but must be implemented to handle local commands, docker and docker-compose interactive shells.

https://github.com/ahoward/session seems to be an option rather than using Open3 directly