From: Johannes Sixt Date: Sun, 27 Feb 2022 17:52:32 GMT Subject: Re: [PATCH v2 2/2] t0030-t0050: avoid pipes with Git on LHS Message-ID: <7e09ee3e-9ac6-e2ff-c6a4-3dd03303b576@kdbg.org> In-Reply-To: <20220227122453.25278-3-shivam828787@gmail.com> Am 27.02.22 um 13:24 schrieb Shubham Mishra: > test_expect_success \ > 'text plus spaces without newline at end should not show spaces' ' > - ! (printf "$ttt$sss" | git stripspace | grep " " >/dev/null) && > - ! (printf "$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) && > - ! (printf "$ttt$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) && > - ! (printf "$ttt$sss$sss" | git stripspace | grep " " >/dev/null) && > - ! (printf "$ttt$ttt$sss$sss" | git stripspace | grep " " >/dev/null) && > - ! (printf "$ttt$sss$sss$sss" | git stripspace | grep " " >/dev/null) > + printf "$ttt$sss" | git stripspace >tmp && > + ! grep " " tmp >/dev/null && > + printf "$ttt$ttt$sss" | git stripspace && > + ! grep " " tmp >/dev/null && > + printf "$ttt$ttt$ttt$sss" | git stripspace && > + ! grep " " tmp >/dev/null && > + printf "$ttt$sss$sss" | git stripspace && > + ! grep " " tmp >/dev/null && > + printf "$ttt$ttt$sss$sss" | git stripspace && > + ! grep " " tmp >/dev/null && > + printf "$ttt$sss$sss$sss" | git stripspace && > + ! grep " " tmp >/dev/null > ' You forgot to redirect all but the first `git stripspace`. > > test_expect_success \ > @@ -282,12 +292,18 @@ test_expect_success \ > > test_expect_success \ > 'text plus spaces at end should not show spaces' ' > - ! (echo "$ttt$sss" | git stripspace | grep " " >/dev/null) && > - ! (echo "$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) && > - ! (echo "$ttt$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) && > - ! (echo "$ttt$sss$sss" | git stripspace | grep " " >/dev/null) && > - ! (echo "$ttt$ttt$sss$sss" | git stripspace | grep " " >/dev/null) && > - ! (echo "$ttt$sss$sss$sss" | git stripspace | grep " " >/dev/null) > + echo "$ttt$sss" | git stripspace >tmp && > + ! grep " " tmp >/dev/null && > + echo "$ttt$ttt$sss" | git stripspace >tmp && > + ! grep " " tmp>/dev/null && > + echo "$ttt$ttt$ttt$sss" && > + ! grep " " tmp >/dev/null && > + echo "$ttt$sss$sss" | git stripspace >tmp && > + ! grep " " tmp >/dev/null && > + echo "$ttt$ttt$sss$sss" | git stripspace >tmp && > + ! grep " " tmp >/dev/null && > + echo "$ttt$sss$sss$sss" | git stripspace >tmp && > + ! grep " " tmp >/dev/null > ' A superficial glance at the visual pattern formed by the new lines reveals immediately that there is something foul. And indeed, one of the rewritten cases misses `| git stripspace >tmp`. -- Hannes