Bug 1334751 - tcsh: Quoted backslashes gets repeated when taken from history
Summary: tcsh: Quoted backslashes gets repeated when taken from history
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: tcsh
Version: 6.8
Hardware: All
OS: Linux
Target Milestone: rc
: ---
Assignee: David Kaspar [Dee'Kej]
QA Contact: Iveta Wiedermann
Lenka Kimlickova
Keywords: Regression, ZStream
: 1347237 (view as bug list)
Depends On: 1333523
Blocks: 1301857 1357126
TreeView+ depends on / blocked
Reported: 2016-05-10 13:01 UTC by David Kaspar [Dee'Kej]
Modified: 2017-03-21 11:17 UTC (History)
10 users (show)

Several regressions in the "tcsh" have been fixed

This update fixes several regressions in the "tcsh" command language interpreter:

* When browsing command history using the `Ctrl+P` or `Up Arrow` keys, backslashes are now shown correctly.

* A backslash now correctly escapes user-defined aliases; this fixes git-completion.

* The output of the built-in "time" command is now correctly captured when used with the built-in "setenv" command.
Clone Of: 1333523
: 1357126 (view as bug list)
Last Closed: 2017-03-21 11:17:53 UTC

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2017:0731 normal SHIPPED_LIVE tcsh bug fix update 2017-03-21 12:43:34 UTC
Red Hat Knowledge Base (Solution) 2593261 None None None 2016-08-31 06:29 UTC

Description David Kaspar [Dee'Kej] 2016-05-10 13:01:20 UTC
This is also present in RHEL-6, since tcsh-6.17-35.el6:

+++ This bug was initially created as a clone of Bug #1333523 +++

Description of problem:
If a command has a backslash within quotes, and that command is brought back with e.g. "up-history", the backslash is doubled.

Version-Release number of selected component (if applicable):

How reproducible:
Every time

Steps to Reproduce:
1. echo '\n'
2. <Up> (or ctrl-p)

Actual results:
The line says: echo '\\n'

Expected results:
A line saying: echo '\n'

--- Additional comment from Kamil Dudka on 2016-05-06 10:07:46 CEST ---

I am able to reproduce it on f23 if I just compile the f24 version of tcsh:

kdudka@f23 ~/fedora/tcsh/tcsh-6.19.00 $ ./tcsh 
[kdudka@f23 tcsh-6.19.00]$ echo '\n'

[kdudka@f23 tcsh-6.19.00]$ echo '\\n'

After commenting out tcsh-6.19.00-026-quote-backslashes-properly.patch, the bug is no longer reproducible:

kdudka@f23 ~/fedora/tcsh/tcsh-6.19.00 $ ./tcsh 
[kdudka@f23 tcsh-6.19.00]$ echo '\n'

[kdudka@f23 tcsh-6.19.00]$ echo '\n'

--- Additional comment from David Kaspar [Dee'Kej] on 2016-05-10 14:50:10 CEST ---

I have already informed upstream about this:

--- Additional comment from David Kaspar [Dee'Kej] on 2016-05-10 14:54 CEST ---

The patch seems to be an EasyFix (one liner). It fixes the regression, testsuite passes, as well as the testcase for the initial issue.

Comment 9 David Kaspar [Dee'Kej] 2016-05-24 12:41:02 UTC
Supreet has found another issue related to this:
On RHEL 6.7 : 

[root@localhost ~]# set myvar = `\echo "1 2 3"`
[root@localhost ~]# echo ${myvar}
1 2 3
[root@localhost ~]# echo ${myvar[1]}
[root@localhost ~]# echo ${myvar[2]}
[root@localhost ~]# echo ${myvar[3]}
[root@localhost ~]# echo ${myvar[3]}
[root@localhost ~]# echo $SHELL
[root@localhost ~]#

On RHEL 6.8 :

[root@vm6 ~]# set myvar = `\echo "1 2 3"`
[root@vm6 ~]# echo ${myvar}
1 2 3
[root@vm6 ~]# echo ${myvar[1]}
1 2 3
[root@vm6 ~]# echo ${myvar[2]}
myvar: Subscript out of range.
[root@vm6 ~]# echo $SHELL
[root@vm6 ~]#

This gives the correct behaviour
  set myvar = `echo "1 2 3"`

But this doesn't in 6.8
  set myvar = `\echo "1 2 3"`

I found these comments in the change log, it looks like it did more then preserving the backslash.
- quote backslashes properly to preserve them in `...` expressions
Resolves: #1301857

The real reason I came across this issue, is that there is a widely distributed setup for
shell completion support for git that fails with the 6.8 tcsh.

This is the code...
set __git_tcsh_completion_version = `\echo ${tcsh} | \sed 's/\./ /g'`
if ( ${__git_tcsh_completion_version[1]} < 6 || \
     ( ${__git_tcsh_completion_version[1]} == 6 && \
       ${__git_tcsh_completion_version[2]} < 16 ) ) then
        echo "git-completion.tcsh: Your version of tcsh is too old, you need version 6.16.00 or newer.  Git completion will not work."

I have already informed upstream about this:

Comment 10 David Kaspar [Dee'Kej] 2016-06-16 11:09:22 UTC
Upstream has already fixed the regression, here is the commit:

Comment 11 David Kaspar [Dee'Kej] 2016-06-16 11:10:50 UTC
*** Bug 1347237 has been marked as a duplicate of this bug. ***

Comment 32 David Kaspar [Dee'Kej] 2016-10-21 09:36:29 UTC
I have closed this by mistake (thought this was fixed in RHEL 6.7.z), reopening...

Comment 36 errata-xmlrpc 2017-03-21 11:17:53 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.