stat: added features: --files0-from=FILE',
--digest-type=WORD' and `-- (original) (raw)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
From: | Stefan Vargyas |
---|---|
Subject: | stat: added features: `--files0-from=FILE', `--digest-type=WORD' and `--quoting-style=WORD' |
Date: | Thu, 22 May 2014 01:44:34 -0700 (PDT) |
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:
$ 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 ... --files-from=F display status of files specified by names in file F; If F is - then read names from standard input ... --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 ... The valid format sequences for files (without --file-system): ... %S file content digest sum ... $
These features were used as essential composing parts in the following scenario:
(1) $ find EXPR -print|sort|stat --files-from=- ... > STAT_SRC (1b) $ find EXPR -print0|sort -null|stat --files0-from=- ... > STAT_SRC
(2) $ find EXPR -print0|du --files0-from=- ... (2b) $ find EXPR -print0|sort -null|du --files0-from=- ...
(3) $ mkisofs -exclude-list EXCL -o ISO_FILE ...
(4) $ find ISO_LOOP --not type d -print|sort|stat --files-from=- ... > STAT_ISO (4b) $ find ISO_LOOP --not type d -print0|sort -null|stat --files0-from=- ...
STATISO
(5) $ diff -u <(cut out inode column from STAT_SRC) <(cut out inode column from STAT_ISO) $ wdiff STAT_SRC STAT_ISO
Here EXPR and EXCL are generated based upon a (potentially elaborated) list of file globbing patterns. Zooming into the details of the 'find|stat' commands above would show something like:
$ eval find $(GEN-FIND-EXPR)|sort|stat
--printf '%S\t%f\t%a\t%u\t%g\t%h\t%i\t%s\t%W\t%X\t%Y\t%Z\t%n\n'
--quoting-style=escape
--digest-type=sha1
--files-from=-
> files-stat.output
2>files-stat.error
I used to employ steps (1) through (5): my 'stat' implements '--files-from'. The (2b) and (4b) alternatives imply a fanciful fitted feature of 'sort': '-0|--null' options: the program is taking in lines terminated by a NUL char instead of by newline.
Please look into the attached patch files. They implement the features advertised above, relative to the latest released source tarball (version 8.22, from December 13, 2013). They apply also to the current Coreutils git repository as well.
The 'files0-from' patch modifies only 'stat.c', while the other, 'files-from' -- two additional parties belonging to 'gnulib':
$ lsdiff stat-files0-from-digest-type-quoting-style.patch src/stat.c
$ lsdiff stat-files-from-digest-type-quoting-style.patch lib/argv-iter.c lib/argv-iter.h lib/readtokens0.c lib/readtokens0.h src/stat.c
There is not much to add but to note that the modifications applied to 'stat.c' do obey to the general style of the other tools in the Coreutils package. I used a logic which extends that found in 'md5sum.c' with regards to the computations of digest sums: see functions 'out_hex_string', 'digest_{regular,symlink}_file' and 'out_file_digest'. The other changes were applied using a logic very similar to that in 'du.c' and 'wc.c'. The modifications of source files 'argv-iter.[hc]' and 'readtokens0.[hc]' were made such that their original behavior be preserved while adding functionality for reading and tokenizing input separated by a given delimiter char -- which for 'stat.c' with '--files-from' is the newline char.
Both patch sets pass the regression tests included in package. Note that these patch sets do not touch neither the documentation nor the regression test code of the package yet: they are only an initial proposition.
Sincerely,
Stefan Vargyas.
stat-files0-from-digest-type-quoting-style.patch
Description: Text Data
stat-files-from-digest-type-quoting-style.patch
Description: Text Data
- stat: added features: `--files0-from=FILE', `--digest-type=WORD' and `--quoting-style=WORD',Stefan Vargyas <=
- Re: stat: added features: `--files0-from=FILE', `--digest-type=WORD' and `--quoting-style=WORD', Pádraig Brady, 2014/05/22
* Re: stat: added features: `--files0-from=FILE', `--digest-type=WORD' and `--quoting-style=WORD', Stefan Vargyas, 2014/05/22
* Re: stat: added features: `--files0-from=FILE', `--digest-type=WORD' and `--quoting-style=WORD', Pádraig Brady, 2014/05/22
- Re: stat: added features: `--files0-from=FILE', `--digest-type=WORD' and `--quoting-style=WORD', Pádraig Brady, 2014/05/22
- Prev by Date:Re: [PATCH] maint: use consistent widths for comparison of file system constants
- Next by Date:Re: stat: added features: `--files0-from=FILE', `--digest-type=WORD' and `--quoting-style=WORD'
- Previous by thread:Re: RFE: Modification to the Timezone Modifier
- Next by thread:Re: stat: added features: `--files0-from=FILE', `--digest-type=WORD' and `--quoting-style=WORD'
- Index(es):