Re: [PATCH 1/2] clone: allow "--bare" with "-o"
- From
Jeff King <peff@peff.net>
- Date
- Sep 22, 2022, 06:35 UTC
- Message-ID
- <YywCImASth7I0Wx2@coredump.intra.peff.net>
- In-Reply-To
- <CAPig+cQxSwz2cZFLNwg_rJ==M5=pxMVvwgbDFV1r=v+rzbCuNg@mail.gmail.com>
On Thu, Sep 22, 2022 at 02:26:09AM -0400, Eric Sunshine wrote:
Show 21 quoted lines
> > I think you might be mis-reading the advice here. It is saying to use
> > the "pwd" program, rather than relying on the shell's $PWD variable. So
> > $(pwd) and `pwd` are the same thing (and are what I'm using). The $() I
> > think is just indicating that you'd do:
> >
> > foo=$(pwd)
> >
> > And yes, I think this is a case where using the right one is important
> > (which is why I used the pwd program, and not $pwd in the test).
> >
> > Or am I missing something else?
>
> I was thinking, in particular, about this snippet from t/test-lib.sh:
>
> # git sees Windows-style pwd
> pwd () {
> builtin pwd -W
> }
>
> If that's inherited by the subshell used in the test, then I suppose
> all is okay, though I think it would not be inherited.I think it's OK. $() is itself a subshell, and you can find many calls to FOO=$(pwd) or similar. And in general, functions are inherited in subshells:
$ sh -c 'foo() { echo bar; }; (cd .. && foo)'
barThey'd have to be or many things in our test suite would break, since we use test_must_fail, etc, inside subshells.
-Peff