On Fri, Nov 21, 2025 at 11:16:11AM +0100, Jan Kiszka wrote:
> You want to add
>
> From: Konrad Schwarz <[email protected]>
>
> to the top of the commit message when submitting via a different account
> so that author and signer are aligned. Or use git sendemail which will
> do that when author and submitter address differ.
>
> On 19.11.25 18:28, [email protected] wrote:
> > The mkemmc.sh script calculates file sizes via `wc -c'. `wc'
> > normally works by reading the entire file, resulting in O(n) performance.
> >
> > Unix file systems obviously know a file's size and POSIX `ls' reports this
> > information unambiguously, so replacing `wc' with `ls' ensures O(1)
> > performance. The files in question tend to be large making this change
> > worthwhile.
>
> Valid point.
>
> >
> > Signed-off-by: Konrad Schwarz <[email protected]>
> > ---
> > scripts/mkemmc.sh | 10 ++++++++--
> > 1 file changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/scripts/mkemmc.sh b/scripts/mkemmc.sh
> > index 45dc3f08fa..d2c4e84b16 100755
> > --- a/scripts/mkemmc.sh
> > +++ b/scripts/mkemmc.sh
> > @@ -37,13 +37,19 @@ usage() {
> > exit "$1"
> > }
> >
> > +file_size() {
> > + ls_line=$(ls -Hdog "$1") || return
>
> This will not suppress the error message when a file does not exist or
> is not accessible, so:
>
> ls_line=$(ls -Hdog "$1" 2>/dev/null) || return
>
> > + printf %s\\n "$ls_line" | cut -d\ -f3
> > + unset ls_line
This parsing of 'ls' output could be simplified by
using the 'stat' command with a format string to
request only the file size.
stat --format=%s "$1"
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|