develooper Front page | perl.perl5.porters | Postings from August 2001

Re: On "Command-line Wildcard Expansion"

Thread Previous | Thread Next
From:
Tye McQueen
Date:
August 7, 2001 13:16
Subject:
Re: On "Command-line Wildcard Expansion"
Message ID:
200108072013.f77KDxI23175@metronet.com
Excerpts from the mail message of Jenda Krynicky:
) Well that realy depends. Imagine you have a script that is supposed 
) to process a list of files and you call it like this :
) 
) c:\some\dir\> script.pl *.txt *.html
) 
) Now if there are some TXT files but no HTML the script will get 
) something like
) 
) @ARGV = ('one.txt', 'two.txt', '*.html');
) 
) and will most probably report that it can't open a file named
) '*.html'. I as a user would be quite surprised by such a message.

Then your users shouldn't use Unix either:

    tye@unix-$ echo *.px
    *.px
    tye@unix-$ ls *.px
    *.px not found
    tye@unix-$ cat *.px
    cat: cannot open *.px: No such file or directory
    tye@unix-$

Some shells have a separate error message for "*.px" not matching
(and also have an option to disable that to be compatible with the
"default"/"historical" shell behavior).  I can see advantages to
both choices.

Two advantages of the "keep the glob and let the open fail" method
are that it works better when faced with a lack of a well-defined
don't-glob quoting scheme (which Win32 lacks) and it eases backward
compatability in this case.  So I'd go with that as the default in
this specific case.

Tye

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About