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

Re: [PATCH] t/perf: fix test_export() failure with BSD `sed`

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 16, 2020, 19:07 UTC
Message-ID
<xmqq5z514lj5.fsf@gitster.c.googlers.com>
In-Reply-To
<20201216073907.62591-1-sunshine@sunshineco.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
> Fortunately, alternation is unnecessary in this case and can easily be
> avoided, so replace it with a series of simple expressions such as
> `s/^var1/.../p;s/^var2/.../p`.
Simple is good.
> While at it, tighten the expressions so they match the variable names
> exactly rather than matching prefixes (i.e. use `s/^var1=/.../p`).
Good eyes.  That is quite good.
Show 9 quoted lines
> @@ -148,13 +148,18 @@ test_run_perf_ () {
>  . '"$TEST_DIRECTORY"/test-lib-functions.sh'
>  test_export () {
>  	[ $# != 0 ] || return 0
> -	test_export_="$test_export_\\|$1"
> +	test_export_="$test_export_ $1"
>  	shift
>  	test_export "$@"
>  }

This "recursion to consume $@ one by one, instead of looping" caught my eyes a bit, but the bug being fixed is not caused by it, so it is fine to let it pass. Given that the arguments to test_export are supposed to be all variable names (i.e. no funny characters anywhere in it), I think it could just be

	test_export () {
		test_export_="$*"
	}
though.

Oh, does anybody need to clear test_export_ to an empty string (or unset it), by the way?

Show 11 quoted lines
>  '"$1"'
>  ret=$?
> -set | sed -n "s'"/'/'\\\\''/g"';s/^\\($test_export_\\)/export '"'&'"'/p" >test_vars
> +needles=
> +for v in $test_export_
> +do
> +	needles="$needles;s/^$v=/export $v=/p"
> +done
> +set | sed -n "s'"/'/'\\\\''/g"'$needles" >test_vars
>  exit $ret' >&3 2>&4
>  	eval_ret=$?

Other than these, none of which were "this is wrong and needs to be fixed", I have no comments. The patch is quite readably done.

Will queue.  Thanks.
Previous: Eric SunshineNext: Eric Sunshine
Message 2 of 8 in “t/perf: fix test_export() failure with BSD `sed`”
  1. t/perf: fix test_export() failure with BSD `sed`Eric Sunshine, Dec 16, 2020
  2. Junio C HamanoDec 16, 2020
  3. Eric SunshineDec 16, 2020
  4. Jeff KingDec 18, 2020
  5. Eric SunshineDec 18, 2020
  6. Jeff KingDec 18, 2020
  7. Eric SunshineDec 21, 2020
  8. 2/1 t/perf: avoid unnecessary test_export() recursionEric Sunshine, Dec 20, 2020

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.