Re: [PATCH] change Perl syntax to support Perl 5.6

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 30 August 2008, Jeff King wrote:
> On Sat, Aug 30, 2008 at 08:34:13PM +0200, Robert Schiele wrote:
> 
> > If there are problems with that change I recommend just using my
> > initial patch changing the documentation to require Perl 5.8 since my
> > interest in Perl 5.6 support is not big enough to mess around with
> > quoting all that stuff.  If someone really needs this he or she can
> > still do it --- it should be not too difficult.

First, IIRC gitweb requires Perl 5.8 _anyway_ because of unicode stuff.

> I think it is as simple as:
> 
> diff --git a/git-add--interactive.perl b/git-add--interactive.perl
> index da768ee..4ee6f89 100755
> --- a/git-add--interactive.perl
> +++ b/git-add--interactive.perl
> @@ -61,7 +61,7 @@ sub run_cmd_pipe {
>  		return qx{@args};
>  	} else {
>  		my $fh = undef;
> -		open($fh, '-|', @_) or die;
> +		open($fh, '-|', join(' ', map { quotemeta($_) } @_)) or die;
>  		return <$fh>;
>  	}
>  }
> 
> But I didn't do any testing beyond checking that "git add -i 'file with
> spaces'" which was broken by your patch now works at all.

No, you would need something like this code from gitweb.perl (used in
very rare cases where list form of open cannot be used, which means
when we need pipeline like for compressed snapshot, or redirecting
stdout and/or stderr to /dev/null like when getting type of possibly
not existing object in git_object)

 # quote the given arguments for passing them to the shell
 # quote_command("command", "arg 1", "arg with ' and ! characters")
 # => "'command' 'arg 1' 'arg with '\'' and '\!' characters'"
 # Try to avoid using this function wherever possible.
 sub quote_command {
 	return join(' ',
 		    map( { my $a = $_; $a =~ s/(['!])/'\\$1'/g; "'$a'" } @_ ));
 }


Or you can use "open $fd, '-|'" to fork, an "manually" exec/system.
-- 
Jakub Narebski
Poland
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux