Re: [PATCH v2 11/17] fetch tests: fetch <url> <spec> as well as fetch [<remote>]
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Feb 9, 2018, 21:14 UTC
- Message-ID
- <CAPig+cSVgzp4CdmzmGo6j31Tiv6Yf3o1EA6gcv_z9gdKvicsyw@mail.gmail.com>
- In-Reply-To
- <20180209202733.GA18966@sigill.intra.peff.net>
On Fri, Feb 9, 2018 at 3:27 PM, Jeff King <peff@peff.net> wrote:
Show 23 quoted lines
> On Fri, Feb 09, 2018 at 09:05:00PM +0100, Ævar Arnfjörð Bjarmason wrote:
>> >> + key=$(echo $1 | sed -e 's/^remote\.origin/fetch/')
>> >
>> > Faster (thus more Windows-friendly) assuming that $1 always starts
>> > with "remote.origin":
>> >
>> > key=fetch${u#remote.origin}
>>
>> Tests fail with this and I'm not excited to be the first user in git's
>> test suite to use some novel shell feature, no existing uses of
>> ${u[...].
>>
>> I also think stuff like this is on the wrong side of cleverness
>> v.s. benefit. I can't find any reference to this syntax in bash or dash
>> manpages (forward-search "${u"), but echo | sed is obvious, and it's not
>> going to make a big difference for Windows.
>
> The "u" isn't the magic, it's the "#". I.e.:
>
> key=fetch${1#remote.origin}
>
> and it's used all over the place in our scripts. I'm not sure why Eric
> wrote "u". :)Because I was testing the expression interactively in the shell and assigned to a variable arbitrarily named "u". When I copy/pasted the working expression from the shell session into the email, I stupidly forgot to change the "u" to "1".