Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

limactl shell escapes special characters too aggressively in some cases #1482

Open
sam-berning opened this issue Apr 14, 2023 · 1 comment
Open
Labels
area/cli limactl CLI user experience

Comments

@sam-berning
Copy link
Contributor

Description

I was trying to find a way to share my local environment to the VM while working on an issue on Finch and while testing out a few (admittedly hacky) options I kept running into issues with the way that limactl shell escapes special characters:

1. Running multiple commands at once via limactl shell

$ limactl shell default source /tmp/lima/env-proto \; env
$ limactl shell default source /tmp/lima/env-proto \&\& env

What I expected: the file should be sourced, and the env command should run
What happened: the special character argument was surrounded in quotes, causing it to be interpreted as an argument to /tmp/lima/env-proto:

$ limactl shell --debug default source /tmp/lima/env-proto \&\& env
...
exec "$SHELL" --login -c 'source /tmp/lima/env-proto '"'"'&&'"'"' env']

2. Declaring an env variable that contains a special character

$  limactl shell default FOO="\$" env                        
/bin/bash: line 1: FOO=$: command not found

What I expected: FOO should be declared as $, and then the env command should run
What happened: FOO=$ was surrounded in single quotes, causing it to be interpreted as a filename instead of a variable declaration:

$ limactl shell --debug default FOO="\$" env
...
exec "$SHELL" --login -c ''"'"'FOO=$'"'"' env']

Version

OS:

$ sw_vers
ProductName:	macOS
ProductVersion:	12.6.3
BuildVersion:	21G419

Lima:

$ limactl --version
limactl version 0.15.0
@sam-berning
Copy link
Contributor Author

I'm realizing now that both of these options are possible using bash -c as the command to limactl shell... 🤦‍♂️

$ limactl shell default bash -c 'source /tmp/lima/env-proto ; env'
FOO=bar
...
$ limactl shell default bash -c 'FOO=$ env'   
FOO=$
...

Still, I think the env variable PR I opened would be nice to have, and I don't think it breaks any existing scenarios

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
area/cli limactl CLI user experience
Projects
None yet
Development

No branches or pull requests

2 participants