git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jakub Narebski <jnareb@gmail.com>
Date
Aug 30, 2008, 20:37 UTC
Message-ID
<200808302237.17017.jnareb@gmail.com>
In-Reply-To
<20080830183949.GA16415@coredump.intra.peff.net>
On Sat, 30 August 2008, Jeff King wrote:
Show 7 quoted lines
> 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.
Show 18 quoted lines
> 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
Previous: Jeff KingNext: Robert Schiele
Message 7 of 29 in “change Perl syntax to support Perl 5.6”
  1. change Perl syntax to support Perl 5.6Robert Schiele, Aug 30, 2008
  2. Jeff KingAug 30, 2008
  3. Junio C HamanoAug 30, 2008
  4. Jeff KingAug 30, 2008
  5. Robert SchieleAug 30, 2008
  6. Jeff KingAug 30, 2008
  7. Jakub NarebskiAug 30, 2008
  8. Robert SchieleAug 30, 2008
  9. Avery PennarunAug 31, 2008
  10. Randal L. SchwartzAug 31, 2008
  11. Junio C HamanoAug 31, 2008
  12. Avery PennarunAug 31, 2008
  13. Jakub NarebskiAug 31, 2008
  14. Petr BaudisAug 31, 2008
  15. H. Peter AnvinSep 1, 2008
  16. Robert SchieleSep 1, 2008
  17. Tom G. ChristensenSep 1, 2008
  18. Brandon CaseySep 4, 2008
  19. Tom G. ChristensenSep 5, 2008
  20. Jakub NarebskiAug 31, 2008
  21. Jay SoffianSep 1, 2008
  22. Alex RiesenSep 1, 2008
  23. Avery PennarunSep 2, 2008
  24. Avery PennarunSep 2, 2008
  25. Junio C HamanoAug 30, 2008
  26. Randal L. SchwartzAug 31, 2008
  27. Ask Bjørn HansenAug 31, 2008
  28. Junio C HamanoSep 1, 2008
  29. Junio C HamanoSep 1, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.