Ticket #4533: External editor does not work with arguments in $EDITOR
commit44d8213f4ebc16bce3cd68395af885d9e8f3edad
authorAndrew Borodin <aborodin@vmail.ru>
Sun, 31 Mar 2024 15:53:59 +0000 (31 18:53 +0300)
committerAndrew Borodin <aborodin@vmail.ru>
Sun, 31 Mar 2024 16:04:26 +0000 (31 19:04 +0300)
tree917c6899b0545239d378ac4634cf32f35243d3da
parent25f008c0b0ed0ce8ee7bef4b0d4368af09ec228a
Ticket #4533: External editor does not work with arguments in $EDITOR

When using an external editor (i.e. "Use internal edit" in the Configure
Options is unchecked) the environment variable EDITOR is used. However,
if $EDITOR contains a command line argument after the executable name,
these arguments are not processed properly, and the editor might not be
started at all.

How to reproduce: (Precondition: vi is available on the system)
  1) On the command line, execute: export EDITOR="vi +" && mc
(the + argument should let vi start at the document's end instead of the
beginning).
  2) Go to the Options menu -> Configuration -> uncheck "Use internal
edit".
  3) Move the cursor to a file that is larger than a single screen (e.g.
ABOUT-NLS in mc's source directory).
  4) Press F4 to start the external editor.

Result: Nothing visible happens

Expected result: vi is opened showing the end of the file ABOUT-NLS

The bug: my_system_make_arg_array() doesn't perform full-feature
parsing of the comman line.

  * (str_tokenize): mew function based on history_tokenize_internal()
from GNU readline-8.2.
  * (str_tokenize_word): mew function based on history_tokenize_word()
from GNU readline-8.2.
  * (my_system_make_arg_array): reimplement using str_tokenize().
  * (my_systemv_flags): use modified my_system_make_arg_array().
  * (fork_child_tokens): new test for string tokenization.
  * (fork_child_tokens2): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
lib/strutil.h
lib/strutil/Makefile.am
lib/strutil/tokenize.c [new file with mode: 0644]
lib/utilunix.c
tests/lib/utilunix__my_system-fork_child.c