Re: [PATCH] t5319: don't trip over a user name with whitespace
- From
Jeff King <peff@peff.net>
- Date
- Jul 1, 2019, 09:16 UTC
- Message-ID
- <20190701091602.GA24791@sigill.intra.peff.net>
- In-Reply-To
- <3e5c0286-7514-9e00-fbc5-5b0ad9403d30@kdbg.org>
On Mon, Jul 01, 2019 at 08:33:18AM +0200, Johannes Sixt wrote:
Show 7 quoted lines
> > If we are OK relying on rudimentary perl[1], then: > > > > perl -le "print((stat)[7]) for @ARGV" > > I'm fine with that. But then we should do the sort + head -n 1 at the > same time. I can do that with a small script, but I'm sure it's possible > in a one-liner...
Something like:
perl -le 'print((sort { $a <=> $b } map { (stat)[7] } @ARGV)[0])'but that is getting pretty unreadable. If we rely on List::Util, it's a bit nicer:
perl -MList::Util=min -e 'print min(map { (stat)[7] } @ARGV)'but that implies perl v5.7.3. Which is from 2002, and older than our usual minimum-perl version, but we've typically been very conservative with these one-liners, since they do not respect NO_PERL.
Probably writing it out like:
perl -le '
my @sizes = map { (stat)[7] } @ARGV;
@sizes = sort { $a <=> $b } @sizes;
print $size[0];
'would be better (and makes "3rd-smallest" a trivial change).
I see Gábor suggested using "wc -c" elsewhere in the thread. That would be fine with me, too, though I think the required sed there may be getting pretty unreadable, too. :)
-Peff