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

Re: [PATCH] git-rebase--interactive.sh: LF terminate line sent to cut

From
BCBrandon Casey <brandon.casey.ctr@nrlssc.navy.mil>
Date
Sep 17, 2010, 18:59 UTC
Message-ID
<VzbuextQE2-OASqyG4sJxmg1IuyBq5BWWiDERv0h-YQdVcnL8Enurg@cipher.nrlssc.navy.mil>
In-Reply-To
<7vsk182p2q.fsf@alter.siamese.dyndns.org>
On 09/17/2010 01:38 PM, Junio C Hamano wrote:
> Agreed; the less use of 'cut' we see, the better ;-)
Double agreed.
Show 10 quoted lines
> As to portability guideline in our shell script:
> 
>     ${param#word} ${param##word} ${param%word} ${param%%word}
> 
> are permissible POSIX constructs (together with more traditional -/=/?/+), and
> their use is encouraged over 'cut', 'expr', etc. [*1*]
> 
>     ${param:ofs} ${param:ofs:len} ${param/pattern/string}
> 
> are bashisms we avoid (unless of course in the bash completion script).

It's been a long while since I've reviewed Documentation/CodingGuidelines, but these are indeed in there, and have been for a very long time. Maybe I should refresh my memory more often. :)

> We do not seem to use ${#param}, not because it is forbidden, but I think
> because it is not very useful without ${param:ofs:len}.

CodingGuidelines does say "No strlen ${#parameter}", so that could be part of the reason. But like you say, it's not very useful without ${param:ofs:len}.

-Brandon
Previous: Junio C HamanoNext: Chris Johnsen
Message 4 of 7 in “git-rebase--interactive.sh: LF terminate line sent to cut”
  1. git-rebase--interactive.sh: LF terminate line sent to cutChris Johnsen, Sep 17, 2010
  2. Brandon CaseySep 17, 2010
  3. Junio C HamanoSep 17, 2010
  4. Brandon CaseySep 17, 2010
  5. git-rebase--interactive.sh: replace cut with ${v%% *}Chris Johnsen, Sep 17, 2010
  6. Junio C HamanoSep 17, 2010
  7. Chris JohnsenSep 18, 2010

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.