Subject: tcsh filename substitution bug
From: Keith Thompson <[email-masked]>
To: [email-masked]
Cc: Keith Thompson <[email-masked]>
Date: Tue, 14 Sep 2010 20:54:24 -0700
List-Id: <cygwin.cygwin.com>

% cygcheck -c cygwin tcsh
Cygwin Package Information
Package              Version         Status
cygwin               1.7.5-1         OK
tcsh                 6.17.00.1-1     OK

I've noticed that certain file matching patterns in tcsh under Cygwin
are matching more files than they should.  In the cases I've noticed,
a pattern like *__* or *xx* matches files containing only a single
trailing '_' or 'x' character, respectively.

I do not see this problem with tcsh 6.17.00 under Ubuntu 9.04, nor do
I see it with tcsh 6.17.00 compiled from source under Cygwin on the
same system where I see the problem with the Cygwin-provided tcsh.

setup.exe says I have the latest tcsh.

Here's a script that demonstrates the problem:
========== CUT HERE ==========
#!/bin/tcsh -f

set nonomatch

set tmpdir = /tmp/$$
mkdir $tmpdir || exit 1
cd $tmpdir || exit 1

set ok

touch xyz zyx
echo Directory contents: *

set match = ( *x* ) ; set expected = ( xyz zyx )
if ("$match" == "$expected") then
    echo "*x* matched ( $match ), ok"
else
    echo "*x*, matched ( $match ), expected ( $expected )"
    unset ok
endif

set match = ( *xx* ) ; set expected = ( "*xx*" )
if ("$match" == "$expected") then
    echo "*xx* matched ( $match ), ok"
else
    echo "*xx*, matched ( $match ), expected ( $expected )"
    unset ok
endif

set match = ( *xxx* ) ; set expected = ( "*xxx*" )
if ("$match" == "$expected") then
    echo "*xxx* matched ( $match ), ok"
else
    echo "*xxx*, matched ( $match ), expected ( $expected )"
    unset ok
endif

echo ''
touch abcx
echo Directory contents: *

set match = ( *x* ) ; set expected = ( abcx xyz zyx )
if ("$match" == "$expected") then
    echo "*x* matched ( $match ), ok"
else
    echo "*x*, matched ( $match ), expected ( $expected )"
    unset ok
endif

set match = ( *xx* ) ; set expected = ( "*xx*" )
if ("$match" == "$expected") then
    echo "*xx* matched ( $match ), ok"
else
    echo "*xx*, matched ( $match ), expected ( $expected )"
    unset ok
endif

set match = ( *xxx* ) ; set expected = ( "*xxx*" )
if ("$match" == "$expected") then
    echo "*xxx* matched ( $match ), ok"
else
    echo "*xxx*, matched ( $match ), expected ( $expected )"
    unset ok
endif

cd
rm -rf $tmpdir

echo ''

if ($?ok) then
    echo "Passed"
    exit 0
else
    echo "Failed"
    exit 1
endif
========== AND HERE ==========

Here's the output I get with the Cygwin-provided tcsh:
========== CUT HERE ==========
Directory contents: xyz zyx
*x* matched ( xyz zyx ), ok
*xx*, matched ( zyx ), expected ( *xx* )
*xxx* matched ( *xxx* ), ok

Directory contents: abcx xyz zyx
*x* matched ( abcx xyz zyx ), ok
*xx*, matched ( abcx zyx ), expected ( *xx* )
*xxx*, matched ( zyx ), expected ( *xxx* )

Failed
========== AND HERE ==========

And here's the output I get with tcsh compiled from source
on the same system:
========== CUT HERE ==========
Directory contents: xyz zyx
*x* matched ( xyz zyx ), ok
*xx* matched ( *xx* ), ok
*xxx* matched ( *xxx* ), ok

Directory contents: abcx xyz zyx
*x* matched ( abcx xyz zyx ), ok
*xx* matched ( *xx* ), ok
*xxx* matched ( *xxx* ), ok

Passed
========== AND HERE ==========

-- 
Keith Thompson (The_Other_Keith) [email-masked]  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple