#894665 moreutils: vidir does not accept variable assignments in $EDITOR

Package:
moreutils
Source:
moreutils
Description:
additional Unix utilities
Submitter:
Boruch Baum
Date:
2022-04-18 11:27:04 UTC
Severity:
normal
#894665#5
Date:
2018-04-03 03:46:17 UTC
From:
To:
Dear Maintainer,

vidir exits with exit code 2 and the message "exited nonzero,
aborting" when $EDITOR includes a variable assignment prefix such as
the following:

TERM=xterm-256color emacsclient -nw -c --alternate-editor=""

#894665#10
Date:
2022-04-18 11:24:49 UTC
From:
To:
I think you see this because vidir doesn't do real parsing of the
$EDITOR/$VISUAL command line but only splits it on whitespace and pass it
to system(). This means it can't handle quotes properly like the shell
would. Here's a test case illustrating this:

$> export VISUAL='printf %s\n "two words" "" arg'

If vidir inkoved this command line correctly, the output would be like the
following:
----
two words

arg
----

But this what I get:

$> vidir .
"two
words"
""
arg
<path-to-vidir-temp-file>

So the quotes are passed as literal '"' instead of being stripped and
quoted values with spaces are split.

I believe something like what  Parse::CommandLine (
https://metacpan.org/pod/Parse::CommandLine) does is needed.