Message ID | 20200329150226.GA16068@coredump.intra.peff.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | test-lib-functions: simplify packetize() stdin code | expand |
Jeff King <peff@peff.net> writes: > Here it is as a patch on top. I doubt it matters that much (there are > only two stdin calls in the whole suite). So I'm not sure if this patch > should be "eh, why not?" or "meh, pointless churn". Me, neither. ;-)
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 216918a58c..88b7dbd69a 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1373,11 +1373,10 @@ packetize() { packet="$*" printf '%04x%s' "$((4 + ${#packet}))" "$packet" else - cat >packetize.tmp && - len=$(wc -c <packetize.tmp) && - printf '%04x' "$(($len + 4))" && - cat packetize.tmp && - rm -f packetize.tmp + perl -e ' + my $packet = do { local $/; <STDIN> }; + printf "%04x%s", 4 + length($packet), $packet; + ' fi }