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

"process" substitution executes command immediately after substitution #10

Closed
jontroncoso opened this issue Apr 24, 2020 · 3 comments
Closed

Comments

@jontroncoso
Copy link

jontroncoso commented Apr 24, 2020

The command is getting executed before continuing after the substitution. So, if you use the substitution in the middle and have other options after the substitution, the post-substitution options/flags/arguments won't be read.

// composer.json
{
  "scripts": {
    "bash": [
      "docker exec -ti {CONTAINER} bash"
    ]
  },
    "substitution": {
      "enable": true,
      "mapping": {
        "{CONTAINER}": {
          "type": "process",
          "value": "docker ps -aqf ancestor=special-tag"
        }
      }
    }
}

results in

ivr (git)-[1337-ivr-tests]- % composer bash
> docker exec -ti ae055d08efb2
 bash
"docker exec" requires at least 2 arguments.
See 'docker exec --help'.

Usage:  docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
@jontroncoso jontroncoso changed the title "process" substitution returns after substitution. "process" substitution executes command immediately after substitution Apr 24, 2020
@villfa
Copy link
Owner

villfa commented Apr 25, 2020

I see there is a line break in your command (between the container id and bash):

> docker exec -ti ae055d08efb2
 bash

It probably comes from docker ps.

You can trim the command result this way:

    "substitution": {
      "enable": true,
      "mapping": {
        "{CONTAINER}": {
          "type": "process",
          "value": "docker ps -aqf ancestor=special-tag",
          "escape": "trim"
        }
      }
    }

@jontroncoso
Copy link
Author

jontroncoso commented Apr 29, 2020

@villfa Thank you so much. This resolved this specific issue. However now I have a new issue (which i'm sure is unrelated):

ivr (git)-[DDA-629-IVR-account-balances]- % composer bash
> docker exec -ti 95bf3fa16ef9 bash
the input device is not a TTY
Script docker exec -ti 95bf3fa16ef9 bash handling the bash event returned with error code 1

This appears to be a limitation with composer itself though. Thanks again!

@villfa
Copy link
Owner

villfa commented Apr 29, 2020

You could try adding < /dev/tty to your script:

"scripts": {
    "bash": [
        "docker exec -ti {CONTAINER} bash < /dev/tty"
    ]
}

Meanwhile I close this issue since your first problem seems fixed.

@villfa villfa closed this as completed Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants