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

Add --shell option to limactl shell #779

Merged
merged 2 commits into from
Apr 6, 2022

Conversation

jandubois
Copy link
Member

@jandubois jandubois commented Apr 6, 2022

This allows to use a predictable shell for scripting, and also provides a way to recover an instance when the user shell has
been misconfigured:

$ limactl shell --shell /bin/ash alpine uname -a
Linux lima-alpine 5.10.93-0-virt #1-Alpine SMP Thu, 27 Jan 2022 09:34:38 +0000 x86_64 Linux

This is a followup to #775 (review)

I'm not happy about the repetition of the word "shell" in limactl shell --shell /bin/sh ..., but it still seems like the most appropriate name for the option.


This part has been split off into #780

Also adds LIMA_SHELL support to the lima command:

$ export LIMA_INSTANCE=alpine
$ lima sudo apk add fish
[...]
$ export LIMA_SHELL=/usr/bin/fish
$ lima
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
jan@lima-alpine /U/jan>

@jandubois jandubois added this to the v0.10.0 milestone Apr 6, 2022
@jandubois
Copy link
Member Author

FYI @faceair @xfoxfu

@faceair
Copy link

faceair commented Apr 6, 2022

Based on my previous comment is that the -l option seems to be more generic than --login, so is it possible to use -l instead of the --login option.

cmd/lima Outdated Show resolved Hide resolved
@jandubois
Copy link
Member Author

jandubois commented Apr 6, 2022

Based on my previous comment is that the -l option seems to be more generic than --login, so is it possible to use -l instead of the --login option.

I don't know, the only shell where it makes a difference (that I'm aware off) is tcsh, and there it has to be the only argument, so it only works for interactive mode:

$ tcsh -c "echo foo"
foo
$ tcsh -l -c "echo foo"
Unknown option: `-l'
Usage: tcsh [ -bcdefilmnqstvVxX ] [ argument ... ].
$ echo "echo foo" | tcsh -l
foo

So I'm not sure if we should bother; any modern shell should support --login.

AkihiroSuda
AkihiroSuda previously approved these changes Apr 6, 2022
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

cmd/limactl/shell.go Outdated Show resolved Hide resolved
This allows to use a predictable shell for scripting, and also
provides a way to recover an instance when the user shell has
been misconfigured.

Signed-off-by: Jan Dubois <jan.dubois@suse.com>
Because golang and shell quoting requirements are different.
E.g. "foo$bar" really needs to be 'foo$bar' to avoid interpolation.

Signed-off-by: Jan Dubois <jan.dubois@suse.com>
@AkihiroSuda AkihiroSuda merged commit 6fefbbe into lima-vm:master Apr 6, 2022
@jandubois jandubois deleted the shell branch April 8, 2022 00:58
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

Successfully merging this pull request may close these issues.

None yet

3 participants