Skip to content

fix(limactl): allow $EDITOR with flags#4935

Open
nyanotech wants to merge 1 commit intolima-vm:masterfrom
nyanotech:master
Open

fix(limactl): allow $EDITOR with flags#4935
nyanotech wants to merge 1 commit intolima-vm:masterfrom
nyanotech:master

Conversation

@nyanotech
Copy link
Copy Markdown

Allows $VISUAL/$EDITOR to have flags in it, eg for code -w, or for some emacs setups

Allows $VISUAL/$EDITOR to have flags in it, eg for "code -w", or for some emacs
setups

Signed-off-by: nyanotech <nyanotechnology@gmail.com>
Copy link
Copy Markdown
Member

@unsuman unsuman left a comment

Choose a reason for hiding this comment

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

Looks good but could you please fix this minor inconsistency?

@unsuman
Copy link
Copy Markdown
Member

unsuman commented May 6, 2026

There is some issue with Github, I cannot comment on the code:
Screenshot 2026-05-06 at 9 29 43 PM

Investigating - We are investigating reports of degraded performance for Pull Requests
May 06, 2026 - 15:25 UTC

https://www.githubstatus.com/

@jandubois
Copy link
Copy Markdown
Member

Can't comment on the code either; here is what I wanted to write:

This is very simplistic and doesn't support quoted names including whitespace.

And while I think it doesn't matter, this is also a functional change: returns the command now instead of the resolved filename.

I think Detect should have tests.

I would recommend looking at the kubectl edit implementation and copying the basic logic from there.

@nyanotech
Copy link
Copy Markdown
Author

Can't comment on the code either; here is what I wanted to write:

This is very simplistic and doesn't support quoted names including whitespace.edi
And while I think it doesn't matter, this is also a functional change: returns the command now instead of the resolved filename.
I think Detect should have tests.

I would recommend looking at the kubectl edit implementation and copying the basic logic from there.

Good point, I should've looked at some prior art before making this.

I'm thinking I'll do an implementation vaguely like git's, where it passes to a shell if the $EDITOR contains spicy characters (including quotes, spaces, ~), and if not, runs it directly. Compared to kubectl's, this drops the "split the args and then run it directly" path in favor of invoking a shell for those situations as well, and also has more characters in the list of ones it won't try to handle (such as ~).

Adding extra logic to decide if a shell should be invoked or not makes the split between editutil.go/editorcmd.go feel a bit more intertwined than I'd like; any objections to moving the actual editor invocation to the latter (and keeping the file handling in the former), or merging them into one file?

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.

3 participants