bibendi / dip

The dip is a CLI dev–tool that provides native-like interaction with a Dockerized application.
MIT License
1.26k stars 44 forks source link

Dip does not wrap an actual container command in quotes on Ubuntu #132

Closed snthpr1d3 closed 3 years ago

snthpr1d3 commented 3 years ago

First of all, thank you for the really great, useful and handy tool. I apologize in advance for possible grammar mistakes. Also, I assume I might misunderstand the actual reason of the issue.

Describe the bug It's impossible to use a container application with arguments on Ubuntu and therefore it's impossible to use advanced shell constructions.

To Reproduce Steps to reproduce the behavior:

  1. Create any folder, e.g. /tmp/test_project
  2. Create the dip.yml config file in the folder:
    
    version: '2'

compose: files:

provision:

services: test: image: alpine command: tail -f /dev/null

4. Run command `dip provision` or `dip bash -c 'if [[ true ]]; then echo works; fi'` from the folder.
4. See the error

sh: -c: line 1: syntax error near unexpected token then' sh: -c: line 1:docker-compose --file /home/snthpr1d3/work/dip_bug/docker-compose.yml run --rm test /bin/sh -c if [[ true ]]; then echo works; fi' ERROR: Command 'dip bash -c 'if [[ true ]]; then echo works; fi'' executed with error



**Expected behavior**
Performs the shell command correctly and prints "works" as on MacOS environment.

**Context (please complete the following information):**
 - OS: Ubuntu 21.04
 - Version 7.1.0

**Additional context**
Don't reproduce on MacOS environment.

As you can see the `dip bash -c 'if [[ true ]]; then echo works; fi` sample command transcripts into 

```docker-compose --file /home/snthpr1d3/work/dip_bug/docker-compose.yml run --rm test /bin/sh -c if [[ true ]]; then echo works; fi```

which is evidently requires quotes to surround the arguments like this

```docker-compose --file /home/snthpr1d3/work/dip_bug/docker-compose.yml run --rm test /bin/sh -c 'if [[ true ]]; then echo works; fi'```

as it was in the original config file: `dip bash -c  'if [[ true ]]; then echo works; fi'`

As I mentioned before, works correctly on MacOS.
bibendi commented 3 years ago

Hi! I'll see about this bug this week.

snthpr1d3 commented 3 years ago

I'm sorry for the misinformation, it turned out that behaviour does not depend on OS, it depends on the actual version of the gem. I got 6.1.0 on MacOS, and 7.1.0 on the linux environment. Tried out 7.1.0 on MacOS and got the same issue, then tried out 6.1.0 on linux and it worked.

bibendi commented 3 years ago

@snthpr1d3 please try the new version

snthpr1d3 commented 3 years ago

It works, thank you!