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

Re: On "Command-line Wildcard Expansion"

Thread Previous | Thread Next
Jenda Krynicky
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.

You mean

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

> 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.

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();

under your tcsh? What do you get? What about bash?


== == ==
: What do people think?
What, do people think?  :-)
             -- Larry Wall in <>

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