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

garden exec splits quoted arguments #2957

Closed
mattwarenski opened this issue May 17, 2022 · 2 comments · Fixed by #5470
Closed

garden exec splits quoted arguments #2957

mattwarenski opened this issue May 17, 2022 · 2 comments · Fixed by #5470

Comments

@mattwarenski
Copy link

Bug

Current Behavior

Running garden exec api '/usr/bin/env -v echo "hello world"' gives this output:

executing: echo
   arg[0]= 'echo'
   arg[1]= '"hello'
   arg[2]= 'world"'
"hello world"

In the above example "hello" and "world" are being passed as two separate arguments even though they are quoted.

Expected behavior

Running garden exec api '/usr/bin/env -v echo "hello world"' should match the output of kubectl exec pod -- /usr/bin/env -v echo "hello world"

executing: echo
   arg[0]= 'echo'
   arg[1]= '"hello world"'
"hello world"

In this example "hello world" is passed as a single argument.

Your environment

The examples were generated running on mac os with garden 0.12.40

@thsig thsig added the bug label Jun 2, 2022
@vvagaytsev vvagaytsev removed their assignment Jun 2, 2023
@stefreak
Copy link
Member

I believe we should not split at all, but allow using -- to provide multiple parameters, similar to how kubectl works:

% kubectl exec -it x -- "ls -lah"
OCI runtime exec failed: exec failed: unable to start container process: exec: "ls -lah": executable file not found in $PATH: unknown
command terminated with exit code 126
% kubectl exec -it x -- ls -lah
total 8K
drwxr-xr-x    1 root     root          86 Oct 16 18:17 .
drwxr-xr-x    1 root     root          86 Oct 16 18:17 ..

@shumailxyz
Copy link
Contributor

In Bonsai, this doesn't work with the command arguments at all. So running this will fail altogether:

garden exec <pod-name> ls -la 
garden exec <pod-name> "/bin/sh -c ls"

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

Successfully merging a pull request may close this issue.

5 participants