id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	blockedby	blocking	branch_state	votes
4253	Interference of injected subshell commands output with e.g. read in .zshrc causing 10s startup delay	marlonrichert		"== Steps to reproduce ==

{{{#!sh
$ cd $(mktemp -d); exec env -i HOME=$PWD TERM=$TERM zsh -f 
% print -r ""typeset -F SECONDS
print -nr \$'\e[6n'  # We query the terminal for info.
IFS=\$'\e[;' read -Asd R -- reply  # We read the terminal's reply.
print \$SECONDS
"" > .zshrc
% exec zsh  # Starting zsh is still instantaneous.
0.0557880000
% SECONDS=0; mc; print $SECONDS  # Starting mc is now really slow.

11.5728380000
%
}}}

The problem is here: https://github.com/MidnightCommander/mc/blob/a88a626e76139259e5b6fc0db39045f051e243dd/src/subshell/common.c#L1378

You print commands to the shell as if it were user input or terminal input. This interferes with the `read` statement in the `.zshrc` file: The terminal's reply is now buried inside the characters you are printing. As a result, the `read` statement hangs until it times out and most of the commands you print don't get executed.

== Expected behavior ==

Don't print to the shell. If you want to execute commands, just pass them straight to Zsh by using the `-c` flag. See https://zsh.sourceforge.io/Doc/Release/Invocation.html#Invocation-2

== `mc` debug info ==

{{{#!sh
% LC_MESSAGES=C mc -F
Home directory: /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX
Profile root directory: /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX

[System data]
    Config directory: /usr/local/Cellar/midnight-commander/4.8.26/etc/mc/
    Data directory:   /usr/local/Cellar/midnight-commander/4.8.26/share/mc/
    File extension handlers: /usr/local/Cellar/midnight-commander/4.8.26/libexec/mc/ext.d/
    VFS plugins and scripts: /usr/local/Cellar/midnight-commander/4.8.26/libexec/mc/
	extfs.d:        /usr/local/Cellar/midnight-commander/4.8.26/libexec/mc/extfs.d/
	fish:           /usr/local/Cellar/midnight-commander/4.8.26/libexec/mc/fish/

[User data]
    Config directory: /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX/.config/mc/
    Data directory:   /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX/.local/share/mc/
	skins:          /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX/.local/share/mc/skins/
	extfs.d:        /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX/.local/share/mc/extfs.d/
	fish:           /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX/.local/share/mc/fish/
	mcedit macros:  /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX/.local/share/mc/mc.macros
	mcedit external macros: /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX/.local/share/mc/mcedit/macros.d/macro.*
    Cache directory:  /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX/.cache/mc/
% LC_MESSAGES=C mc -F
mc --configure-options
Home directory: /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX
Profile root directory: /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX

[System data]
    Config directory: /usr/local/Cellar/midnight-commander/4.8.26/etc/mc/
    Data directory:   /usr/local/Cellar/midnight-commander/4.8.26/share/mc/
    File extension handlers: /usr/local/Cellar/midnight-commander/4.8.26/libexec/mc/ext.d/
    VFS plugins and scripts: /usr/local/Cellar/midnight-commander/4.8.26/libexec/mc/
	extfs.d:        /usr/local/Cellar/midnight-commander/4.8.26/libexec/mc/extfs.d/
	fish:           /usr/local/Cellar/midnight-commander/4.8.26/libexec/mc/fish/

[User data]
    Config directory: /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX/.config/mc/
    Data directory:   /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX/.local/share/mc/
	skins:          /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX/.local/share/mc/skins/
	extfs.d:        /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX/.local/share/mc/extfs.d/
	fish:           /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX/.local/share/mc/fish/
	mcedit macros:  /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX/.local/share/mc/mc.macros
	mcedit external macros: /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX/.local/share/mc/mcedit/macros.d/macro.*
    Cache directory:  /private/var/folders/24/37_vm48s2tz9bhmj1rzffvl40000gn/T/tmp.J1v4nVJX/.cache/mc/
 '--disable-debug' '--disable-dependency-tracking' '--disable-silent-rules' '--prefix=/usr/local/Cellar/midnight-commander/4.8.26' '--without-x' '--with-screen=slang' '--enable-vfs-sftp' 'CC=clang' 'PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig:/usr/local/opt/pcre/lib/pkgconfig:/usr/local/opt/openssl@1.1/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig:/usr/local/opt/sqlite/lib/pkgconfig:/usr/local/opt/tcl-tk/lib/pkgconfig:/usr/local/opt/xz/lib/pkgconfig:/usr/local/opt/python@3.9/lib/pkgconfig:/usr/local/opt/glib/lib/pkgconfig:/usr/local/opt/libssh2/lib/pkgconfig:/usr/local/opt/libpng/lib/pkgconfig:/usr/local/opt/s-lang/lib/pkgconfig' 'PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/11'
% mc -V
GNU Midnight Commander 4.8.26
Built with GLib 2.66.4
Built with S-Lang 2.3.2 with terminfo database
With builtin Editor
With subshell support as default
With support for background operations
With mouse support on xterm
With internationalization support
With multiple codepages support
Virtual File Systems:
 cpiofs, tarfs, sfs, extfs, ftpfs, sftpfs, fish
Data types:
 char: 8; int: 32; long: 64; void *: 64; size_t: 64; off_t: 64;
}}}"	defect	new	major	Future Releases	mc-core	4.8.26		subshell common.c init_subshell zsh .zshrc	baltazar.bz@…			no branch	
