fmang / opustags

Ogg Opus tags editor
BSD 3-Clause "New" or "Revised" License
75 stars 10 forks source link

Support VISUAL with --edit #37

Closed fmang closed 3 years ago

fmang commented 3 years ago

@rrthomas Here’s as you suggested. Please tell me if that works for you.

VISUAL is only used if you have a TERM set. I copied the logic of Git again :)

Close #35.

rrthomas commented 3 years ago

If I set VISUAL=emacsclient, no problem. If I set VISUAL="emacsclient -c" then

error: execvp failed: No such file or directory

I presume it is not passing the command to the shell or attempting to tokenize it?

fmang commented 3 years ago

The shell is not called indeed.

I guess it works with other tools though, and I don’t know which solution is best between calling the shell after escaping the path name, or tokenizing EDITOR.

EDITOR='echo vim' git commit works, so Git surely passes EDITOR as is to the shell. I could reuse Git’s escaping logic: https://github.com/git/git/blob/385c171a018f2747b329bcfa6be8eda1709e5abd/quote.c

Tokenizing would be simple to implement too provided we decide not to support weird values like things with backticks.

I’ll try using the shell, and possibly replace execvp by a system() call.

rrthomas commented 3 years ago

Or it might be possible to use wordexp(3)?

fmang commented 3 years ago

Or it might be possible to use wordexp(3)?

Wow, I didn’t know about this function. I tried it and it’s perfect! Thanks for the tip.

rrthomas commented 3 years ago

Or it might be possible to use wordexp(3)?

I only found out about it recently and by accident, and I didn't even need it!