Re: [PATCH] t5319: don't trip over a user name with whitespace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 01, 2019 at 08:33:18AM +0200, Johannes Sixt wrote:

> > 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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux