chkdupexe, a bug, version numbers and bashisms
Hi,
This pull has couple patches which are worth while to mention.
The first patch reimplements chkdupexe in C. Whole point of doing that is to get rid of dependency to perl, as there where nothing else that needed it. It is questionable if this version is good enough. If not perhaps others can chip in get the command better or more useful.
The setterm patch fixes a bug, which is almost year old faa0548de47df5691cf56dd49daaba8dbc89d34a and part of couple release. Sorry.
First of the pg patches changes version number from old cvs(?) line to config.h version. I wonder if the G. Ritter's copyright year mark up be updated as well?
Finally I started to check shell scripts with checkbashisms. IMHO making POSIX bourne shell compliant makes sense, as one cannot know if /bin/sh is dash (Debian Almquist shell) on some systems. In best case the /bin/sh really is dash, and these patches make scripts run slightly quicker.
The following changes since commit 9895daca9cb9611b6565434d29619f0d28ea9e81:
fsck: tiny coding style fix (2012-03-20 11:22:09 +0100)
are available in the git repository at:
git://github.com/kerolasa/lelux-utiliteetit.git 2012wk11
for you to fetch changes up to 34337b125ddfa961ccc001dd51c5fb076ff7202a:
tools: ko-release: make scripts bourne sh compliant [checkbashisms]
(2012-03-20 20:24:42 +0100)
----------------------------------------------------------------
Sami Kerola (31):
chkdupexe: reimplement command in C
mountpoint: add --version & align with howto-usage-function.txt
findmnt: add --version & align with howto-usage-function.txt
findfs: add --version & align with howto-usage-function.txt
setterm: correct manual page reference
partx: add --version option
addpart: align with util-linux coding standards
delpart: align with util-linux coding standards
raw: align with howto-usage-function.txt
raw: add long options and version printing
raw: use symbolic exit numbers
raw: use libc error printing facilities
raw: use pathnames.h for file locations
raw: check numeric user inputs
raw: clean up coding style
pg: correct version printing in help screen
pg: align with howto-usage-function.txt
fsck.cramfs: add long options
fsck.minix: use symbolic exit codes
fsck.minix: use rpmatch() for yes/no question
fsck.minix: align with howto-usage-function.txt
fsck.minix: clean up coding style
fsck.minix: fix printf format warning
swaplabel: add --version and align with howto-usage-function.txt
fallocate: add --version and align with howto-usage-function.txt
findmnt: remove dublicate usage() line
fstrim: add --version and align with howto-usage-function.txt
reset: make scripts bourne sh compliant [checkbashisms]
tools: checkconfig.sh: make scripts bourne sh compliant [checkbashisms]
tools: config-gen: make scripts bourne sh compliant [checkbashisms]
tools: ko-release: make scripts bourne sh compliant [checkbashisms]
configure.ac | 4 - disk-utils/fsck.cramfs.c | 32 +- disk-utils/fsck.minix.c | 781 ++++++++++++++++++++--------------------- disk-utils/raw.c | 266 +++++++------- disk-utils/swaplabel.c | 26 +- include/pathnames.h | 9 + misc-utils/Makefile.am | 6 +- misc-utils/chkdupexe.1 | 43 ++- misc-utils/chkdupexe.c | 307 ++++++++++++++++ misc-utils/chkdupexe.pl | 120 ------- misc-utils/findfs.c | 23 +- misc-utils/findmnt.c | 17 +- partx/Makefile.am | 2 + partx/addpart.c | 78 ++-- partx/delpart.c | 73 ++-- partx/partx.c | 6 +- sys-utils/fallocate.c | 21 +- sys-utils/fstrim.c | 21 +- sys-utils/mountpoint.c | 19 +- term-utils/reset | 6 +- term-utils/reset.033c | 2 +- term-utils/setterm.c | 2 +- text-utils/pg.c | 45 ++- tools/checkconfig.sh | 6 +- tools/config-gen | 5 +- tools/config-gen-functions.sh | 2 +- tools/ko-release-gen | 8 +- tools/ko-release-push | 2 +- 28 files changed, 1143 insertions(+), 789 deletions(-) create mode 100644 misc-utils/chkdupexe.c delete mode 100755 misc-utils/chkdupexe.pl mode change 100644 => 100755 term-utils/reset
Signature · 2 lines
Sami Kerola http://www.iki.fi/kerolasa/
Karel Zak
maintainerMerged, but
Quoted 2 lines · Sami Kerola
Sami Kerola (31):
chkdupexe: reimplement command in C
please, send the new chkdupexe to mailing list for review.
Quoted 2 lines
addpart: align with util-linux coding standards
delpart: align with util-linux coding standards
Fixed...
if ((fd = open(argv[1], O_RDONLY)) < 0)
err(EXIT_FAILURE, "%s", argv[1]);
...
err(EXIT_FAILURE, "BLKPG");"%s", "BLKPG" are not usable error messages.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Quoted 2 lines · Karel Zak
Merged, but
Thank you for merge and message clarifications.
Quoted 5 lines · Sami Kerola
Quoted 2 lines
Sami Kerola (31):
chkdupexe: reimplement command in Cplease, send the new chkdupexe to mailing list for review.
Sound fair. The incoming chkdupexe, and other two small fixes, are also available in the git repository at:
git://github.com/kerolasa/lelux-utiliteetit.git 2012wk13
Signature · 2 lines
Sami Kerola http://www.iki.fi/kerolasa/
PATCH 1/3 tests: hwclock: locate ntpdate by using path
--- tests/ts/hwclock/systohc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tests/ts/hwclock/systohc +2 -1
@@ -24,7 +24,8 @@ NTP_SERVER="0.fedora.pool.ntp.org" ts_init "$*" ts_skip_nonroot -[ -x "/usr/sbin/ntpdate" ] || ts_skip "cannot find ntpdate command" +PATH='/usr/sbin:/usr/bin:/sbin:/bin' +type ntpdate >/dev/null 2>&1 || ts_skip "cannot find ntpdate command" set -o pipefail
Signature · 1 line
1.7.9.5
Re: [PATCH 1/3] tests: hwclock: locate ntpdate by using path
Quoted 2 lines · Sami Kerola
tests/ts/hwclock/systohc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Applied, thanks.
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
PATCH 2/3 script: error in usage() output
In reply to Sami KerolaError originates to commit 3ff526391fb5c6b33418dc9cfec31c2ff9b4792e which is bit more than year, and part or releases v2.20 & v2.21.
--- term-utils/script.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
term-utils/script.c +1 -1
@@ -133,7 +133,7 @@ usage(FILE *out)fputs (_ ("\nOptions:\n" ), out); fputs(_(" -a, --append append the output\n" " -c, --command <command> run command rather than interactive shell\n" - " -r, --return return exit code of the child process\n" + " -e, --return return exit code of the child process\n" " -f, --flush run flush after each write\n" " --force use output file even when it is a link\n" " -q, --quiet be quiet\n"
Signature · 1 line
1.7.9.5
Re: [PATCH 2/3] script: error in usage() output
Quoted 2 lines · Sami Kerola
Error originates to commit
3ff526391fb5c6b33418dc9cfec31c2ff9b4792ewhich is bit more than year, and part or releases v2.20 & v2.21.
Wouldn't be possible to write a tools/checkusage script to check long_options[] and getopt_long() with usage() ?
Quoted 2 lines
term-utils/script.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
PATCH 3/3 chkdupexe: reimplement command in C
In reply to Sami KerolaThe new version of the command is nearly identical to old. Major differences are:
* New output is a little rough what comes to alignment. This is flagged as FIXME item in source.
* The command is much quicker than perl implementation which used to exec ls -ldU.
* Size of chkdupexe binary is about five times bigger than perl script.
--- configure.ac | 4 - include/pathnames.h | 2 + misc-utils/Makefile.am | 6 +- misc-utils/chkdupexe.1 | 43 ++++++- misc-utils/chkdupexe.c | 307 +++++++++++++++++++++++++++++++++++++++++++++++ misc-utils/chkdupexe.pl | 120 ------------------ 6 files changed, 351 insertions(+), 131 deletions(-) create mode 100644 misc-utils/chkdupexe.c delete mode 100755 misc-utils/chkdupexe.pl
configure.ac +0 -4
@@ -114,9 +114,6 @@ UL_SET_ARCH(M68K, m68*) UL_SET_ARCH(MIPS, mips*) UL_SET_ARCH(HPPA, hppa*) -dnl script chkdupexe requires perl -AC_PATH_PROG(PERL, perl) - AC_SYS_LARGEFILE AM_GNU_GETTEXT_VERSION([0.14.1])
@@ -1223,7 +1220,6 @@ libuuid/uuid.pc login-utils/Makefile man/ru/Makefile misc-utils/Makefile -misc-utils/chkdupexe:misc-utils/chkdupexe.pl mount/Makefile partx/Makefile po/Makefile.in
include/pathnames.h +2 -0
@@ -25,6 +25,8 @@#undef _PATH_DEFPATH_ROOT#define _PATH_DEFPATH_ROOT "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" +#define _PATH_CHKDUPEXE "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/X11/bin:/usr/bin/X11:/usr/local/X11/bin:/usr/TeX/bin:/usr/tex/bin:/usr/games:/usr/local/games" +#define _PATH_SECURETTY "/etc/securetty"#define _PATH_WTMPLOCK "/etc/wtmplock"
misc-utils/Makefile.am +2 -4
@@ -8,19 +8,17 @@ usrsbin_exec_PROGRAMS = usrbin_exec_PROGRAMS = \ cal \ + chkdupexe \ logger \ look \ mcookie \ namei \ whereis +chkdupexe_SOURCES = chkdupexe.c $(top_srcdir)/lib/strutils.c logger_SOURCES = logger.c $(top_srcdir)/lib/strutils.c mcookie_SOURCES = mcookie.c $(top_srcdir)/lib/md5.c -usrbin_exec_SCRIPTS = chkdupexe - -CLEANFILES = chkdupexe - dist_man_MANS = \ cal.1 \ chkdupexe.1 \
misc-utils/chkdupexe.1 +40 -3
61 lines not on this page · raw message
misc-utils/chkdupexe.c new file +307 -0
307 lines not on this page · raw message
misc-utils/chkdupexe.pl deleted +0 -120
120 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Karel Zak
maintainerRe: [PATCH 3/3] chkdupexe: reimplement command in C
Quoted 9 lines · Sami Kerola
The new version of the command is nearly identical to old. Major differences are:
* New output is a little rough what comes to alignment. This is flagged as FIXME item in source.
* The command is much quicker than perl implementation which used to exec ls -ldU.
* Size of chkdupexe binary is about five times bigger than perl script.
I have doubts about chkdupexe, do we really need this command?
* it provides very rarely used functionality (for example nobody complains that the command is missing in Fedora/RHEL ;-)
* it seems that you can replace it by
ls $(echo "$PATH" | tr : ' ') | sort | uniq -d
or we can extend which(1) or so...
I see two possible ways:
1) mark chkdupexe as deprecated and remove it from distros
2) or add new command (lspath ?) and get much more information from $PATH (like duplicates, per-directory stats, per-owner stats, per-device stats, selinux summary, suids, etc.) and make chkdupexe as alias to the new command (just for backward compatibility).
If 2) makes sense then it would be better to have it in coreutils ;-)
... let's flame :-)
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Re: [PATCH 3/3] chkdupexe: reimplement command in C
Quoted 32 lines · Karel Zak
Quoted 9 lines · Sami Kerola
The new version of the command is nearly identical to old. Major differences are:
* New output is a little rough what comes to alignment. This is flagged as FIXME item in source.
* The command is much quicker than perl implementation which used to exec ls -ldU.
* Size of chkdupexe binary is about five times bigger than perl script.I have doubts about chkdupexe, do we really need this command?
* it provides very rarely used functionality (for example nobody complains that the command is missing in Fedora/RHEL ;-)
* it seems that you can replace it by
ls $(echo "$PATH" | tr : ' ') | sort | uniq -d
or we can extend which(1) or so...
I see two possible ways:
1) mark chkdupexe as deprecated and remove it from distros
2) or add new command (lspath ?) and get much more information from $PATH (like duplicates, per-directory stats, per-owner stats, per-device stats, selinux summary, suids, etc.) and make chkdupexe as alias to the new command (just for backward compatibility).
Quoted 6 lines
If 2) makes sense then it would be better to have it in coreutils ;-)
CC Padraig... let's flame :-)
I am in favour of removal. As you said few, if anyone, is using this command and to be honest I do not know why I would use it. Duplicated commands in path are more likely to be intentional than interesting. Perhaps extended 'lspath' might be more useful, but again I'm struggling to come up with real use case, and the fact that existing tools allow quite easily do similar things. For example find suid bit executables.
find $(echo $PATH | tr ':' ' ') -mindepth 1 -maxdepth 1 -perm -u+s
Besides isn't the path polluted enough with all sort of legacy things? Shouldn't removing of crud be considered virtue?
Signature · 2 lines
Sami Kerola http://www.iki.fi/kerolasa/
Karel Zak
maintainerRe: [PATCH 3/3] chkdupexe: reimplement command in C
Quoted 2 lines · Sami Kerola
I am in favour of removal. As you said few, if anyone, is using this command and to be honest I do not know why I would use it. Duplicated
I agree ... so, we need --enable-chkdupexe (disabled by default) and Documentation/deprecated.txt entry ;-)
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Re: [PATCH 3/3] chkdupexe: reimplement command in C
In reply to Karel ZakQuoted 18 lines · Karel Zak
Quoted 9 lines · Sami Kerola
The new version of the command is nearly identical to old. Major differences are:
* New output is a little rough what comes to alignment. This is flagged as FIXME item in source.
* The command is much quicker than perl implementation which used to exec ls -ldU.
* Size of chkdupexe binary is about five times bigger than perl script.I have doubts about chkdupexe, do we really need this command?
* it provides very rarely used functionality (for example nobody complains that the command is missing in Fedora/RHEL ;-)
* it seems that you can replace it by
Quoted 8 lines
ls $(echo "$PATH" | tr : ' ') | sort | uniq -dor we can extend which(1) or so...
I see two possible ways:
1) mark chkdupexe as deprecated and remove it from distros
I notice it's no longer on my Fedora 15 distro at least.
Quoted 4 lines
2) or add new command (lspath ?) and get much more information from $PATH (like duplicates, per-directory stats, per-owner stats, per-device stats, selinux summary, suids, etc.) and make chkdupexe as alias to the new command (just for backward compatibility).
Possible but unlikely
Quoted 1 line
If 2) makes sense then it would be better to have it in coreutils ;-)
I'd vote for 1.
Note I actually wrote a very similar tool as part of fslint, called findsn. It has different modes of operation, but the default is the same as chkdupexe.
$ ~/git/util-linux/misc-utils/chkdupexe.pl Dangling symlink: /usr/bin/openoffice.org -rwxr-xr-x. 1 root root 86360 Feb 8 2011 /usr/bin/bc -rwxrwxr-x. 1 padraig padraig 1767 Apr 11 2007 /home/padraig/bin/bc -rwxr-xr-x. 1 root root 50616 Aug 25 2011 /usr/bin/timeout -rwxrwxr-x. 1 padraig padraig 2141 Oct 29 2009 /home/padraig/bin/timeout -rwxr-xr-x. 1 root root 51176 Feb 8 2011 /usr/bin/truncate -rwxrwxr-x. 1 padraig padraig 1273 Dec 16 2005 /home/padraig/bin/truncate
$ fslint/findsn -rwxr-xr-x. 1 root root 86360 Feb 8 2011 /usr/bin/bc -rwxrwxr-x. 1 padraig padraig 1767 Apr 11 2007 /home/padraig/bin/bc lrwxrwxrwx. 1 root root 2 May 13 2011 /bin/ex -> vi lrwxrwxrwx. 1 root root 3 May 22 2011 /usr/bin/ex -> vim -rwxr-xr-x. 1 root root 50616 Aug 25 2011 /usr/bin/timeout -rwxrwxr-x. 1 padraig padraig 2141 Oct 29 2009 /home/padraig/bin/timeout -rwxr-xr-x. 1 root root 51176 Feb 8 2011 /usr/bin/truncate -rwxrwxr-x. 1 padraig padraig 1273 Dec 16 2005 /home/padraig/bin/truncate
$ ./fslint/findbl $(fslint/supprt/getffp) /usr/bin/openoffice.org -> /usr/lib64/libreoffice/program/libreoffice
cheers,
Pádraig.
Karel Zak
maintainerRe: [PATCH 3/3] chkdupexe: reimplement command in C
Quoted 1 line · Sami Kerola
I am in favour of removal. As you said few, if anyone, is using this
Quoted 3 lines · Pádraig Brady
Quoted 1 line
1) mark chkdupexe as deprecated and remove it from distros
I'd vote for 1.
Done.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com