Ticket #3852 (closed defect: fixed)

Opened 7 years ago

Last modified 7 years ago

fix broken tcsh subshell escaping

Reported by: anatoly.borodin Owned by: zaytsev
Priority: major Milestone: 4.8.20
Component: mc-core Version: master
Keywords: subshell, tcsh Cc:
Blocked By: Blocking:
Branch state: merged Votes for changeset: anatoly.borodin

Description

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

Attachments

mc.diff (904 bytes) - added by anatoly.borodin 7 years ago.

Change History

Changed 7 years ago by anatoly.borodin

comment:1 Changed 7 years ago by anatoly.borodin

  • Summary changed from tcsh subshell escaping broken to fix broken tcsh subshell escaping

comment:2 Changed 7 years ago by zaytsev

I would prefer to see single quotes if they still work, just in case that someone later sees that it's unquoted and decides to add quotes, or are tcsh developers planning to introduce more breakage such that single quotes will also not work anymore?

Also, it would be great if you could add an explanatory comment to the patch as to why %b is quoted the way it is (tcsh) & refer to this bug, and supply a git-format produced patch against latest master.

comment:3 Changed 7 years ago by zaytsev

  • Status changed from new to accepted
  • Owner set to zaytsev
  • Milestone changed from Future Releases to 4.8.20

comment:4 Changed 7 years ago by zaytsev

  • Branch state changed from no branch to on review

Branch: 3852_broken_tcsh_escaping
Initial changeset:0fec3ef449de6f22281161ba7af8f5dbb948292d

comment:5 Changed 7 years ago by anatoly.borodin

Hi @zaytsev,

I'm sorry I didn't send the patch earlier, I planned to work on it today.

But your commit looks good, thanks!

comment:6 Changed 7 years ago by zaytsev

  • Votes for changeset set to anatoly.borodin
  • Branch state changed from on review to approved

comment:7 Changed 7 years ago by zaytsev

  • Status changed from accepted to testing
  • Resolution set to fixed

comment:8 Changed 7 years ago by zaytsev

  • Branch state changed from approved to merged

comment:9 Changed 7 years ago by zaytsev

  • Status changed from testing to closed

Hi Anatoly, no problem, thanks for high quality report & contribution! --Yury

Note: See TracTickets for help on using tickets.