Created attachment 518342 [details] top: 487 / bottom: 529 Hello, when using the latest less with EDITOR="emacs -nw -q -l ~/.emacs.term" and a file with a whitespace embedded in its name, using 'v' (open file in editor) doesn't pass it cleanly to EDITOR (it's IFS splitted). Downgrading to 487 gives an appropriate behaviour.
I can replicate this with v529 and v530 and VISUAL="/usr/bin/vim". In fact, less may have stopped handling all special shell chars. For instance, this makes less 529/530 execute "date" for me: $ touch 'file;date' $ less file\;date -> press 'v' On a quick glance, the following part in "diff -u less-487/main.c less-530/main.c" looks suspicious: --- less-487/main.c 2016-10-25 16:37:35.000000000 +0200 +++ less-530/main.c 2017-12-05 23:56:50.000000000 +0100 (...) @@ -188,25 +190,24 @@ (...) - filename = shell_quote(*argv); - if (filename == NULL) - filename = *argv; - argv++; - (void) get_ifile(filename, ifile); + (void) get_ifile(*argv++, ifile); ifile = prev_ifile(NULL_IFILE); - free(filename); I wonder if reversing this change would fix the issue (no time to try now). I believe get_ifile() has the side effect of registering a string to serve as a parameter to the editor cmd later. shell_quote() may be taking care of special shell chars (incl. spaces and semicolons as DEF_METACHARS suggests) and may indeed be necessary, because in the end less runs the external editor using system().
Nevermind, this hack doesn't work. But gdb confirms the general idea: a shell_quote() of the filename would solve the problem in less-530. A less-487 flow example (shell_quote() prefixes spaces with the necessary backslashes, lsystem() is a wrapper for system()): In the segment of main() quoted in comment 1: shell_quote("/home/nan/del del2") -> "/home/nan/del\\ del2" which later results in: lsystem("/usr/bin/vim +1 /home/nan/del\\ del2") which in turn correctly calls: shell_quote("/usr/bin/vim +1 /home/nan/del\\ del2") -> "/usr/bin/vim\\ +1\\ /home/nan/del\\\\\\ del2" system("/bin/bash -c /usr/bin/vim\\ +1\\ /home/nan/del\\\\\\ del2") less-530 does no shell_quote in main() (or anywhere else sufficiently early) and only does: lsystem("/usr/bin/vim +1 /home/nan/del del2") which has vim edit two distinct files eventually: shell_quote("/usr/bin/vim +1 /home/nan/del del2") -> "/usr/bin/vim\\ +1\\ /home/nan/del\\ del2" system("/bin/bash -c /usr/bin/vim\\ +1\\ /home/nan/del\\ del2") Incidentally, less-530 contains an additional call to shell_quote() in the body of lglob(), as opposed to less-487. Perhaps that was meant to take care of things in some way. By the way, less currently does: system("bash -c <something>") which execs /bin/sh -c "bash -c <something>". Hopefully this saves somebody a bit of debugging time.
FYI: I've notified the upstream developer of this URL.
Received a reply: fixed in v531, release pending.
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cf063984cc7b2efb34e61c56a15b53362e7e277d commit cf063984cc7b2efb34e61c56a15b53362e7e277d Author: Lars Wendler <polynomial-c@gentoo.org> AuthorDate: 2018-05-16 09:36:25 +0000 Commit: Lars Wendler <polynomial-c@gentoo.org> CommitDate: 2018-05-16 09:38:32 +0000 sys-apps/less: Bump to version 531 Bug: https://bugs.gentoo.org/646884 Package-Manager: Portage-2.3.36, Repoman-2.3.9 sys-apps/less/Manifest | 1 + sys-apps/less/less-531.ebuild | 44 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
i don't think there's anything left here