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:
3B706BE1.E6E35AAF@wgn.net
Jenda Krynicky wrote:
> 
> > 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.
> 
> You mean
> 
>         perl -e "print join(qq{\n}, @ARGV)" '*fubar*'

This should be *fubar* when it gets to Perl since it was escaped.

> or
>         perl -e "print join(qq{\n}, @ARGV)" *fubar*

The shell will try to expand *fubar* and replace it with the glob.

> > 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.
> 
> Depends. You can get to the "raw" command line :
> 
> use Win32::API;
> {
> my $GetCommandLine = Win32::API->new('kernel32',
>         'GetCommandLine', [], 'P' );
> $cmdline = $GetCommandLine->Call();
> }
> 
> That is if the shell did not try to help you. You can bypass the C
> runtime, not the shell.

Since I'm using tcsh, I don't think the orig commandline is available 
anymore - just guessing.

> Could you try
> 
> perl - foo.* 'bar.*' "baz   baz" 'hello    world' "see\nyou" see\nyou
> use Win32::API;
> $GetCommandLine = Win32::API->new('kernel32',
>         'GetCommandLine', [], 'P' );
> print $GetCommandLine->Call();
> ^Z
> 
> under your tcsh? What do you get? What about bash?

world" "see\nyou" "seenyou"

Using test.pl with your code in it - I get:

perl test.pl FOO.PL Foo.pm bar.* "baz   baz" "hello    world" "see\nyou" "seenyou"

The foo.* was expanded into 2 files.


Probably will miss the rest of this thread - back to Mich. for a week
-- 
  ,-/-  __      _  _         $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