[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: stat: added features: `--files0-from=FILE', `--digest-type=WORD' and
From: |
Pádraig Brady |
Subject: |
Re: stat: added features: `--files0-from=FILE', `--digest-type=WORD' and `--quoting-style=WORD' |
Date: |
Thu, 22 May 2014 12:28:22 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 |
On 05/22/2014 09:44 AM, Stefan Vargyas wrote:
>
> Dear maintainers,
>
> Since coreutils v8.9 I was using a customized 'stat', which has the additional
> features implied by the command line options and by the format sequence shown
> below:
Thanks for the patch.
It's cleanly implemented in a table driven manner.
However there are a few conceptual issues ...
>
> $ stat --help
> Usage: stat [OPTION]... [FILE]...
> or: stat [OPTION]... --files-from=F
> Display file or file system status.
> ...
> --digest-type=WORD
> when computing file content sums use specified
> message digest algorithm: md5, sha1, sha224, sha256,
> sha384 or sha512; when the option is not specified
> compute sha1 digests
So you provide the above to essentially munge the checksum into the line for
easy
comparision with diff etc. While this is a valid and useful technique,
wouldn't it be better to leverage the existing utilities to join the data like:
join -j2 <(stat -c '%s %n' /bin/ls /bin/cp | sort) <(sha1sum /bin/cp /bin/ls
| sort)
Also diff might not be that general in the presence of many different files,
so you might also find this construct useful:
tr '\n' '\1' |
sort |
uniq -u ...
> ...
> --files-from=F display status of files specified by names in file
> F;
> If F is - then read names from standard input
There is no advantage of supporting this option in stat
as that is only useful when a command needs to process all
file names in a _single invocation_, like when sorting or accumulating etc.
For stat one can efficiently:
find ... -print 0 | xargs -r0 stat ...
or
find ... -exec stat {} +
Note also that sort has the --zero-terminated option, as do newer versions of
join and uniq.
> --quoting-style=WORD
> use quoting style WORD for file names:
> literal, locale, shell, shell-always, c, escape
> c-maybe, clocale;
> when no option is given, use literal style
This could be useful, however there is already the %N option for quoted file
name.
$ stat -c %N /bin/ls
‘/bin/ls’
$ LANG=C src/stat -c %N /bin/ls
'/bin/ls'
Can you detail the exact use case for this.
If we were to apply this bit I guess it would make sense to only
apply the selection to %N ?
thanks!
Pádraig.