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

Re: On "Command-line Wildcard Expansion"

Thread Previous | Thread Next
From:
$Bill Luebkert
Date:
August 7, 2001 15:58
Subject:
Re: On "Command-line Wildcard Expansion"
Message ID:
3B70514C.63F5E2CB@wgn.net
Jenda Krynicky wrote:
> 
> > All I want is something that ships with Perl.  Actually, I
> > find the arguments for not rolling this into Perl itself very
> > unconvincing.  I'd prefer @ARGV to have wildcards expanded
> > in the name of portability and provide Win32::GetCommandLine()
> > for people who want to write Win32ish command-line interfaces.
> 
> Agreed completely.

I'm using a native tcsh which expands args (within the funky env 
limitations of Windoze.  I don't want any args passed in as '*fubar*' 
to be expanded since they aren't file globs.

The args need to be selectively globbed based on what they refer to.

> should be sufficient unless some kind of globbing will be provided by
> default.

Only the shell can provide globbing properly, since by the time Perl 
sees the args, I believe they are already stripped of ' and ", etc.

This leaves it up to the programmer to decide which args need possible 
globbing and which don't.


> > And if Perl were to have built-in
> > command-line glob()ing for Win32, I'd want an argument of
> > "*.x" to remain "*.x" in the absence of any matching files.
> > The only problem I see with the above code is that it
> > _silently_ drops "*.x" from the command line.

I assume you mean a quoted *.x should not be globbed - I agree.
But are the quotes still there when Perl gets them - I thought not.

> What do Unix shells do? (I have not Unix handy so I can't check)

If the arg is quoted, they wouldn't try to glob it.

> At 08:28 AM 8/7/2001 -0700, Gurusamy Sarathy wrote:
> >I don't mind adding a Wild.pm-like thing to the distribution, perhaps
> >even a single-character switch that's an alias for -MWild.
> >
> >But changing the default strikes me as a bad decision.  How are we
> >going to explain the breakage to (say) bash users?
> 
> I'm not sure.
> I mean ... people usually expect to get the wildcards expanded
> so why couldn't it be the way they get them by default ?

If Perl can differentiate between quoted and non-quoted args, then 
it might be possible to glob each non-quoted arg with a wild card in it.
Otherwise it makes no sense to do so.

> Anyway .. I think a Wild.pm-like module would be handy in the
> distribution.
> Plus the installation/building process could ask whether I want
> Unix-like parameter globing and set PERL5OPT accordingly.

As long as globing is not the default - fine.

-- 
  ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
 (_/   /  )    // //       DBE Collectibles   Mailto:dbe@todbe.com 
  / ) /--<  o // //      http://dbecoll.webjump.com/ (Free site for Perl)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/

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