Ticket #4533 (new defect) — at Initial Version

Opened 8 weeks ago

Last modified 6 weeks ago

External editor does not work with command line argument

Reported by: Dhalgren Owned by:
Priority: major Milestone: 4.8.32
Component: mc-core Version: master
Keywords: Cc:
Blocked By: Blocking:
Branch state: merged Votes for changeset:

Description

When using an external editor for the "Edit" command (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

Output of LC_MESSAGES=C mc -V:
GNU Midnight Commander 4.8.30
Built with GLib 2.78.3
Built with S-Lang 2.3.3 with terminfo database
Built with libssh2 1.11.0
With builtin Editor
With subshell support as default
With support for background operations
With mouse support on xterm and Linux console
With support for X11 events
With internationalization support
With multiple codepages support
With ext2fs attributes support
Virtual File Systems:

cpiofs, tarfs, sfs, extfs, ftpfs, sftpfs

Data types:

char: 8; int: 32; long: 64; void *: 64; size_t: 64; off_t: 64;

Output of LC_MESSAGES=C mc -F:
Home directory: /home/user
Profile root directory: /home/user

[System data]

Config directory: /etc/mc/
Data directory: /usr/share/mc/
File extension handlers: /usr/libexec/mc/ext.d/
VFS plugins and scripts: /usr/libexec/mc/

extfs.d: /usr/libexec/mc/extfs.d/

[User data]

Config directory: /home/user/.config/mc/
Data directory: /home/user/.local/share/mc/

skins: /home/user/.local/share/mc/skins/
extfs.d: /home/user/.local/share/mc/extfs.d/
mcedit macros: /home/user/.local/share/mc/mc.macros
mcedit external macros: /home/user/.local/share/mc/mcedit/macros.d/macro.*

Cache directory: /home/user/.cache/mc/

I have determined the cause of the problem and will provide a fix (which works for a single command line argument) via Pull Request.
Summary: In function utilunix.c:my_system_make_arg_array the GPtrArray storing the contents of argv is not filled correctly.

Change History

Changed 8 weeks ago by Dhalgren

Note: See TracTickets for help on using tickets.