From: Junio C Hamano Date: Mon, 04 Oct 2021 16:16:47 GMT Subject: Re: [PATCH] p5311: handle spaces in wc(1) output Message-ID: In-Reply-To: <87wnmuo7ii.fsf@evledraar.gmail.com> Ævar Arnfjörð Bjarmason writes: > This approach seems like a bit of plastering over the real problem. It's > fine to use the output of "wc -l" or "wc -c" in the context of the > shell's whitespace handling. That's why in various places we do: Sorry, but I am confused. > test $(wc -l <$file>) = 1 > > Or similar, but *don't* put that $() in double-quotes. I.e. we're > relying on the shell's whitespace semantics. > > So isn't it better to just pass this through the shell's own handling > before emitting the data, something like this POC: > > $ stripspace() { var=$1; echo $@; }; x=$(stripspace " hi" " there "); echo "\"$x\"" > "hi there" All of the above are not wrong per-se, but if I read the scaffolding code correctly, the way the output from "wc -c" is used is not via a variable, but test_size_ () { say >&3 "running: $2" if test_eval_ "$2" 3>"$base".result; then test_ok_ "$1" else test_failure_ "$@" fi } test_size () { test_wrapper_ test_size_ "$@" } where "$2" gets the script given to test_size, e.g. test_size "size $title" ' wc -c Of course fixing it up after that in Perl will work just as well, so I > guess this is just an asthetic preference for having the shell handle > the shell's output issues with what's guaranteed to be shell-portable > solutions... :) Meaning we could rewrite aggregation in shell, then we can say we are not making Perl clean up after mess sh creates? I dunno... Thanks.