> 10 feb. 2023 kl. 23:09 skrev Bernhard Voelker <m...@bernhard-voelker.de>:
>
> On 2/3/23 20:58, Gunnar Lindholm wrote:
> > +With the @option{-b} and @option{-f} options one can use the exit status to
> > +verify the available space (in bytes or percentage) with a command like
> > +@samp{if df -b 640000 /var/log ; then echo "That is big enough for
> > everyone"; fi}
>
> Thanks for the patch as a basis for discussion. That's an interesting
> use-case.
> However, I'm 20:80 to add it - for the following reasons:
>
> a) The functionality can easily be achieved via scripting, e.g. using the
> --output option
> and sed(1):
>
> $ df --output=pcent /
> Use%
> 83%
>
> $ if test 80 -gt `df --output=pcent / | sed '1d;s/%//'`; then echo FINE;
> else echo TOO_FULL; fi
> TOO_FULL
>
> $ if test 85 -gt `df --output=pcent / | sed '1d;s/%//'`; then echo FINE;
> else echo TOO_FULL; fi
> FINE
>
> b) The new code adds quite some extra complexity, but still stands in
> contradiction to
> most of the other options. So it does not "feel right" in there.
>
> Have a nice day,
> Berny
Hello,
Many thanks for your feedback.
I have no problem agreeing on your b) comment (yes it radicaly changes the
behavior of df), but I’m of a different opinion when it comes to a) and see it
as an advantage to keep sed out of if-statements and make them less
complicated. But I might be in the minority on that.
Best regards
Gunnar