Re: [PATCH v2] t8002: fix ambiguous printf conversion specifications
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 21, 2025, 22:10 UTC
- Message-ID
- <xmqqplkfyg1l.fsf@gitster.g>
- In-Reply-To
- <20250120114106.2844157-1-jpalus@fastmail.com>
Jan Palus <jpalus@fastmail.com> writes:
> - $(printf "%0.s " $(test_seq 11)) (<author@example.com> 2005-04-07 15:45:13 -0700 1) abbrev > + $(printf "%11s" "") (<author@example.com> 2005-04-07 15:45:13 -0700 1) abbrev
This obviously is much clearer than the obscure original that concatenates " " 11 times (for 11 arguments that printf receives).
Nice.
Show 6 quoted lines
> @@ -146,7 +146,7 @@ test_expect_success 'blame --abbrev -b truncates the blank boundary' '
>
> test_expect_success 'blame with excessive --abbrev and -b culls to hash length' '
> cat >expect <<-EOF &&
> - $(printf "%0.s " $(test_seq $hexsz)) (<author@example.com> 2005-04-07 15:45:13 -0700 1) abbrev
> + $(printf "%${hexsz}s" "") (<author@example.com> 2005-04-07 15:45:13 -0700 1) abbrevThe fact that $hexsz was not quoted in the original made me look at how it is defined (as an unquoted variable reference is often a way to lose unwanted leading whitespaces, e.g. bytes=$(wc -c <foo) && show $bytes), but it seems that hexsz would not get any leading (or trailing) whitespaces so this rewrite perfectly fine.
Thanks. Will queue.