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

Re: On "Command-line Wildcard Expansion"

Thread Previous | Thread Next
$Bill Luebkert
August 7, 2001 15:58
Re: On "Command-line Wildcard Expansion"
Message ID:
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 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 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 
  / ) /--<  o // // (Free site for Perl)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About