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

Re: [PATCH] test-lib: simplify '--option=value' parsing

From
Jeff King <peff@peff.net>
Date
Apr 22, 2016, 18:37 UTC
Message-ID
<20160422183703.GA7595@sigill.intra.peff.net>
In-Reply-To
<1461339503-6854-1-git-send-email-szeder@ira.uka.de>
On Fri, Apr 22, 2016 at 05:38:23PM +0200, SZEDER Gábor wrote:
Show 6 quoted lines
> To get the 'value' from '--option=value', test-lib.sh parses said
> option running 'expr' with a regexp.  This involves a subshell, an
> external process, and a lot of non-alphanumeric characters in the
> regexp.
> 
> Use a much simpler shell parameter expansion instead to do the same.

Looks OK to me. I doubt the extra process is a killer (we only parse options once per script), but the result is definitely more readable, IMHO.

For some reason I had always assumed that complicated pattern matching with "#" was non-POSIX, but I checked and it is definitely in there.

> ---
>  t/test-lib.sh | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

I count 5 cases in my copy of test-lib.sh. I think you are missing "--run".

-Peff
Previous: SZEDER GáborNext: SZEDER Gábor
Message 2 of 4 in “test-lib: simplify '--option=value' parsing”
  1. test-lib: simplify '--option=value' parsingSZEDER Gábor, Apr 22, 2016
  2. Jeff KingApr 22, 2016
  3. test-lib: simplify '--option=value' parsingSZEDER Gábor, Apr 22, 2016
  4. Junio C HamanoApr 22, 2016

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.