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

Re: [PATCH 2/2] t/README: hint about using $(pwd) rather than $PWD in tests

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jan 11, 2011, 08:37 UTC
Message-ID
<20110111083729.GD9445@burratino>
In-Reply-To
<4D2C11A5.4050709@viscovery.net>
Johannes Sixt wrote:
> Am 1/11/2011 8:54, schrieb Jonathan Nieder:
Show 9 quoted lines
>> Perhaps it is also worth explaining the cases where $PWD is needed?
>>
>> 	By contrast, when a passing a path to git or constructing a URL,
>> 	use $PWD.
>
> The first part of the "or" is not true: you can pass the result of $(pwd)
> to a command, and it means the same as $PWD; I would even recommend
> against $PWD so that a reader does not have to wonder "why pass $PWD, but
> check for $(pwd)?"

I _think_ that passing $PWD always gives the right result. By contrast, constructions like

	PATH=$(pwd)/bin:$PATH
break iirc.

I suspect that the reader will end up wondering "why does this have to be so complicated" no matter what.

> The second part I don't know whether it is true: I haven't noticed a
> pattern where people did it the wrong way, therefore, I'don't even know
> whether $PWD is really *always* required. Do *you* know?
24f1136 is one example.  I don't know of any utility that treats
	file://c:/foo/bar/baz

as a URL representing a resource on localhost (and msys bash has no rewriting rule for it), so in that particular case (file://$directory), $PWD really does seem to be always required.

Show 7 quoted lines
>>       It makes a difference on Windows, where
>>
>> 	 - $(pwd) is a Windows-style path such as git might output, and
>> 	 - $PWD is a Unix-style path that the shell (MSYS bash) will
>> 	   mangle before passing to native apps like git.
>
> This information is already included by reference to 4114156ae9.

... but if we can summarize it nicely, we can save the reader a step, no?

Anyway, what you have already written is useful; clearing up these details would just be icing on the top.

Previous: Johannes SixtNext: Johannes Sixt
Message 10 of 12 in “Re: [PATCH] Fix expected values of setup tests on Windows”
  1. Nguyen Thai Ngoc DuyDec 31, 2010
  2. Johannes SixtDec 31, 2010
  3. Jonathan NiederDec 31, 2010
  4. Johannes SixtDec 31, 2010
  5. Junio C HamanoJan 2, 2011
  6. Nguyen Thai Ngoc DuyJan 1, 2011
  7. 2/2 t/README: hint about using $(pwd) rather than $PWD in testsJohannes Sixt, Jan 11, 2011
  8. Jonathan NiederJan 11, 2011
  9. Johannes SixtJan 11, 2011
  10. Jonathan NiederJan 11, 2011
  11. Johannes SixtJan 11, 2011
  12. Junio C HamanoJan 11, 2011

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.