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

Re: [PATCH 2/2] Quoting paths in tests

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Oct 18, 2007, 06:08 UTC
Message-ID
<4716F849.3090102@viscovery.net>
In-Reply-To
<6E65762D-FBC4-4A7C-97A9-20F6744E25DE@steelskies.com>
Jonathan del Strother schrieb:
Show 20 quoted lines
> 
> On 17 Oct 2007, at 12:32, Johannes Sixt wrote:
> 
>> Jonathan del Strother schrieb:
>>> --- a/t/lib-git-svn.sh
>>> +++ b/t/lib-git-svn.sh
>>> @@ -25,7 +25,7 @@ perl -w -e "
>>> use SVN::Core;
>>> use SVN::Repos;
>>> \$SVN::Core::VERSION gt '1.1.0' or exit(42);
>>> -system(qw/svnadmin create --fs-type fsfs/, '$svnrepo') == 0 or 
>>> exit(41);
>>> +system(qw/svnadmin create --fs-type fsfs/, \"$svnrepo\") == 0 or 
>>> exit(41);
>>
>> Here you have to work harder: The reason is that this is part of a 
>> perl expression (as opposed to an eval'd string), which does not have 
>> access to $svnrepo of the shell by which it is invoked. The original 
>> version failed if there were single-quotes in $svnrepo, the new 
>> version fails if it contains double-quotes.
You can rewrite this expression as
     perl -w -e '$svnrepo = shift;
	...
	$SVN::Core::Version gt "1.1.0" ...
	system(qw/svnadmin create --fs-type fsfs/, $svnrepo) == 0 ...
	...
     ' >&3 2>&4 "$svnrepo"
i.e. you pass the repository name as an argument to the scriptlet.
Show 17 quoted lines
>> May I recommend that you run the test suite in a directory named like 
>> this:
>>
>>     $ mkdir \"\ \$GIT_DIR\ \'
>>     $ ls
>>     " $GIT_DIR '
> 
> 
> Eww.  I'm struggling a bit with paths this perverse, actually.
> 
> For instance, git_editor in git-sh-setup expects the editor path to be 
> pre-quoted.  So in t3404, you need to produce escaped double quotes & 
> dollar signs, resulting in unpleasantness like this :
> 
> VISUAL="`pwd`/fake-editor.sh"
> VISUAL=${VISUAL//\"/\\\"}
> VISUAL=${VISUAL//$/\\\$}
This is a bashism - that's a big no-no.
Show 9 quoted lines
> VISUAL=\"$VISUAL\"
> export VISUAL
> 
> 
> And I'm struggling to come up with neat ways of rewriting things like, 
> eg, this bit from t5500 -
> test_expect_success "clone shallow" "git-clone --depth 2 
> \"file://`pwd`/.\" shallow"
> - to handle paths like that properly.

These examples expand `pwd` too early. Can't you just put everything inside single-quotes? Although I'm not sure about VISUAL: Is it invoked with $PWD that is different from $PWD when VISUAL is defined? If so, then you can hardly delay `pwd`...

I know I'm a bit anal with my criticism. I reviewed your patch because I think fixing for paths with whitespace is worthwhile. However, I also think any fix should go the full way and not only shift the problems into a different corner. Maybe a word from $maintainer would be in order ;)

-- Hannes
Previous: David KastrupNext: Jonathan del Strother
Message 30 of 38 in “Fixing path quoting issues”
  1. Fixing path quoting issuesJonathan del Strother, Oct 10, 2007
  2. Johannes SixtOct 11, 2007
  3. David KastrupOct 11, 2007
  4. Johannes SixtOct 11, 2007
  5. Jonathan del StrotherOct 11, 2007
  6. Johannes SixtOct 11, 2007
  7. David KastrupOct 11, 2007
  8. Jonathan del StrotherOct 11, 2007
  9. Johannes SchindelinOct 11, 2007
  10. David KastrupOct 11, 2007
  11. Johannes SixtOct 12, 2007
  12. Wincent ColaiutaOct 12, 2007
  13. Johannes SchindelinOct 12, 2007
  14. Wincent ColaiutaOct 12, 2007
  15. Johannes SchindelinOct 12, 2007
  16. David KastrupOct 12, 2007
  17. Jonathan del StrotherOct 13, 2007
  18. Andreas EricssonOct 13, 2007
  19. Jonathan del StrotherOct 15, 2007
  20. 1/3 Fixing path quoting in git-rebaseJonathan del Strother, Oct 15, 2007
  21. Johannes SixtOct 15, 2007
  22. Jonathan del StrotherOct 17, 2007
  23. Quoting paths, take 3Jonathan del Strother, Oct 17, 2007
  24. 1/2 Fixing path quoting in git-rebaseJonathan del Strother, Oct 17, 2007
  25. 2/2 Quoting paths in testsJonathan del Strother, Oct 17, 2007
  26. Johannes SixtOct 17, 2007
  27. Jonathan del StrotherOct 17, 2007
  28. David KastrupOct 17, 2007
  29. David KastrupOct 17, 2007
  30. Johannes SixtOct 18, 2007
  31. Jonathan del StrotherOct 24, 2007
  32. Johannes SixtOct 17, 2007
  33. 2/3 Quoting paths in testsJonathan del Strother, Oct 15, 2007
  34. Johannes SixtOct 15, 2007
  35. Jonathan del StrotherOct 15, 2007
  36. Johannes SixtOct 15, 2007
  37. David KastrupOct 15, 2007
  38. 3/3 Fix apostrophe quoting in testsJonathan del Strother, Oct 15, 2007

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.