id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	blockedby	blocking	branch_state	votes
3852	fix broken tcsh subshell escaping	anatoly.borodin	zaytsev	"mc version: 4.8.18
tcsh version: 6.20

== The regression in tcsh ==

Actually, the bug is in tcsh, but it would be easier to ""fix"" it on the mc's side.

There was a regression in the version 6.20 of tcsh: the escaping of nested quotes has been changed in https://github.com/tcsh-org/tcsh/commit/c445a078a7b124fd86dd6eba9c076476b8e757d4 . Unfortunately, it is tricky to really fix the tcsh escaping consistently without breaking legacy scripts even more.

To test the regression in tcsh:

# mkdir -p '/tmp/a b' && ls -d ""`printf ""%b"" '\0057tmp\0057a\0040b'`""

Before the commit:

/tmp/a b

(The same result in bash and zsh btw.)

After the commit:

ls: cannot access '/tmp/a': No such file or directory
ls: cannot access 'b': No such file or directory

== Fixing in mc ==

I propose to fix the problem on the Midnight Commander side instead. To prevent messages like 'Warning: Cannot change to /tmp/a b/c d..' and failure to cd to such directories when using mc with recent versions of tcsh (SHELL=/bin/tcsh), mc can be patched (init_subshell_precmd() in src/subshell/common.c) the following way: **%b** should not be escaped (or escaped with single quotes), because there are no ambiguities. See the attached diff for an example. I've tested the patch with different shells: tcsh (both old and new), bash, zsh, fish.

== Launchpad ==

https://bugs.launchpad.net/ubuntu/+source/mc/+bug/1706223"	defect	closed	major	4.8.20	mc-core	master	fixed	subshell, tcsh				merged	anatoly.borodin
