[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1247: perl <...> globbing only works if (t)csh installed



Package: perl
Version: 5.0001-3

As you can see from the transcript below, Perl's <...> globbing only
works if you have tcsh installed.

I surmise that this is related to the following info, from perlop(1):

       ...  Example:

           while (<*.c>) {
               chmod 0644, $_;
           }

       is equivalent to

           open(FOO, "echo *.c | tr -s ' \t\r\f' '\\012\\012\\012\\012'|");
           while (<FOO>) {
               chop;
               chmod 0644, $_;
           }

       In fact, it's currently implemented that way.  (Which
       means it will not work on filenames with spaces in them
       unless you have csh(1) on your machine.)

So, what is probably happening is that it is failing for users who
don't have tcsh *installed*, because the person who built Perl did
have csh installed and so Perl was configured to use it.

Clearly this is not acceptable.  However, a version of Perl whose
globbing doesn't work for filenames with spaces is also unacceptable
(and that's presumably what you'd get if you rebuilt Perl configured
to think that csh wasn't available).

Perl should be fixed to use the C library `glob' function - this will
also fix the other problems described in perlop(1):

       Because globbing invokes a shell, it's often faster to
       call readdir() yourself and just do your own grep() on the
       filenames.  Furthermore, due to its current implementation
       of using a shell, the glob() routine may get "Arg list too
       long" errors (unless you've installed tcsh(1L) as
       /bin/csh).

Thanks to Peter Tobias for spotting this problem and asking me about
it in private email.

Ian.

chiark:~/junk> dpkg -l '*csh*'
Desired=Unknown/Install/Remove/Purge
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required
||/ Name         Version   Rev  Description
+++-============-=========-====-===============================================
ii  tcsh              6.05 4    An enhanced version of the Berkeley C shell.
chiark:~/junk> perl -e '@x=<t*>; print "@x\n";'
t.c t.cc t.cc~ t.cpio t.c~ t.o t.old t.pl t.pl~ tar termcap test.ld touchdata trinity.wad.gz trn-to-addnewsgroup.pl trn-to-addnewsgroup.pl~ ts typescript tzu t~
chiark:~/junk> really dpkg --purge tcsh
(Reading database ... 15631 files and directories currently installed.)
Removing tcsh ...
Purging configuration files for tcsh ...
chiark:~/junk> perl -e '@x=<t*>; print "@x\n";'

chiark:~/junk> really dpkg --install /usr/src/debian-archive/binary/shells/tcsh-6.05-4.deb
Selecting previously deselected package tcsh.
(Reading database ... 15625 files and directories currently installed.)
Unpacking tcsh (from .../binary/shells/tcsh-6.05-4.deb) ...
Setting up tcsh ...

chiark:~/junk> perl -e '@x=<t*>; print "@x\n";'
t.c t.cc t.cc~ t.cpio t.c~ t.o t.old t.pl t.pl~ tar termcap test.ld touchdata trinity.wad.gz trn-to-addnewsgroup.pl trn-to-addnewsgroup.pl~ ts typescript tzu t~
chiark:~/junk> echo t*
t.c t.cc t.cc~ t.cpio t.c~ t.o t.old t.pl t.pl~ tar termcap test.ld touchdata trinity.wad.gz trn-to-addnewsgroup.pl trn-to-addnewsgroup.pl~ ts typescript tzu t~
chiark:~/junk>


Reply to: