Re: [PATCH] p3400: stop using tac(1)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 04.10.21 um 10:31 schrieb Jeff King:
> On Sat, Oct 02, 2021 at 07:44:14PM +0200, René Scharfe wrote:
>
>> b3dfeebb92 (rebase: avoid computing unnecessary patch IDs, 2016-07-29)
>> added a perf test that calls tac(1) from GNU core utilities.  Support
>> systems without it by reversing the generated list using sort -nr
>> instead.  sort(1) with options -n and -r is already used in other tests.
>
> Cute fix. With regular seq(1), this whole thing can become:
>
>   seq 1000 -1 1
>
> without the extra process, but our test_seq doesn't understand non-1
> increments (nor comparisons besides -le). It wouldn't be that hard to
> teach it, but given that this is the first time we've wanted it, it may
> not be worth the effort.

Right.  The original also allows "seq 1000 1", by the way.  Not sure we
need that either.

But when you say "without the extra process", I think:

test_seq () {
	set_step='END {step = first < last ? 1 : -1}'
	loop='END {for (; first <= last && step > 0 || first >= last && step < 0; first += step) print first}'
	case $# in
	1)      awk -v first=1    -v last="$1"    "$set_step $loop" ;;
	2)      awk -v first="$1" -v last="$2"    "$set_step $loop" ;;
	3)      awk -v first="$1" -v last="$3" -v step="$2" "$loop" ;;
	*)      BUG "not 1, 2, or 3 parameters to test_seq" ;;
	esac </dev/null
}

;-)

René




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux