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

Re: [PATCH] git-prompt.sh: shorter equal upstream branch name

From
Julien Carsique <julien.carsique@gmail.com>
Date
Oct 7, 2014, 15:57 UTC
Message-ID
<54340D63.8030507@gmail.com>
In-Reply-To
<xmqqppebptmj.fsf@gitster.dls.corp.google.com>
Hi,
Thank you both for your feedback!
I'm looking at applying your requests:
- add tests,
- variable renaming,
- use of local,
- fix multiple issues on string parsing
- avoid useless bash-isms? Did you agree on the ones I should remove?
I'll send an updated patch asap. Tell me if I forgot something.

Regards, Julien

On 01/10/2014 19:49, Junio C Hamano wrote:
Show 24 quoted lines
> Richard Hansen <rhansen@bbn.com> writes:
>
>>> and there is no hope to "fix" them to stick to
>>> the bare-minimum POSIX,
>> I don't think it'd be hard to convert it to pure POSIX if there was a
>> desire to do so.
> Not necessarily; if you make it so slow to be usable as a prompt
> script, that is not a "conversion".  Bash-isms in the script is
> allowed for a reason, unfortunately.
>
>> It would be unwise to go to great lengths to avoid Bashisms, but I think
>> it would be smart to use POSIX syntax when it is easy to do so.  
> In general, I agree with you. People who know only bash tend to
> overuse bash-isms where they are not necessary, leaving an
> unreadable mess.
>
> For the specific purpose of Julien's "if the tail part of this
> string matches the other string, replace that with an equal sign",
> ${parameter/pattern/string} is a wrong bash-ism to use.  But the
> right solution to count the length of the other string and take a
> substring of this string from its beginning would require other
> bash-isms ${#parameter} and ${parameter:offset:length}.
>
> And that's fine.
Previous: Junio C HamanoNext: Richard Hansen
Message 6 of 9 in “git-prompt.sh: shorter equal upstream branch name”
  1. git-prompt.sh: shorter equal upstream branch nameJulien Carsique, Sep 30, 2014
  2. Richard HansenSep 30, 2014
  3. Junio C HamanoSep 30, 2014
  4. Richard HansenOct 1, 2014
  5. Junio C HamanoOct 1, 2014
  6. Julien CarsiqueOct 7, 2014
  7. Richard HansenOct 7, 2014
  8. Junio C HamanoOct 7, 2014
  9. Junio C HamanoSep 30, 2014

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.