RasmusLindroth / tut

TUI for Mastodon with vim inspired keys
https://tut.anv.nu
MIT License
446 stars 29 forks source link

Use /bin/sh to launch editor (proper shell quoting for editor) #265

Open JacksonChen666 opened 1 year ago

JacksonChen666 commented 1 year ago

https://github.com/RasmusLindroth/tut/pull/96#issuecomment-950148821

I solved it in another way, but thank you for the pull request :)

@RasmusLindroth Your solution (assuming here) does it wrong when having to deal with escaped characters (spaces). Probably better to leave it up to the shell than do it yourself in a way that doesn't work for all.

Because my neovim config does stuff I don't want for composing toots, I have do :set tw=0 every time I open the editor. I had an idea, it's to do nvim -c ":set tw=0" but tut interprets the space between set and tw=0 to be a separate argument, basically making it impossible for my solution to work.

https://github.com/RasmusLindroth/tut/blob/33d7cd8cbf5f8048b49bf218a3c7aed2ab3d6346/ui/open.go#L89

That was my somewhat ranty rant. This PR is pretty much this but rebased so that it works on the master branch.

Also, I tested it, now my thing works. I'm not sure of other scenarios where it doesn't work (or works against the user).

(Questions welcome, although you should read the quoted text for rationale. I am sending this in quite a hurry because I already lost a previous version of my comment, it's nearly midnight and i'm kinda annoyed, so let me know of any little imperfections)