coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RFC: change cksum -b to allow full emulation of older utils


From: Jim Meyering
Subject: Re: RFC: change cksum -b to allow full emulation of older utils
Date: Sat, 8 Jul 2023 15:33:46 -0700

On Sat, Jul 8, 2023 at 1:58 PM Pádraig Brady <P@draigbrady.com> wrote:
> On 08/07/2023 19:52, Jim Meyering wrote:
> > On Sat, Jul 8, 2023 at 7:28 AM Pádraig Brady <P@draigbrady.com> wrote:
> >> It would be nice to be able to support users who want to replace all
> >> the *sum utilities with a script that did:
> >>
> >>     exec cksum -a <algo> --untagged "$@"
> >>
> >> To that end, it would be good to support all the options of the older 
> >> utils.
> >> This is a bit awkward with --base64 added in the last few months, as that
> >> also added the short -b option.  However it's only a few months released,
> >> so it's probably not too onerous to change.
> >>
> >> The attached makes the change, which I'll augment with NEWS and tests/ 
> >> upon agreement.
> >
> > Good idea. I agree that the added value outweighs the cost of
> > divergence with OpenBSD cksum's -b (https://man.openbsd.org/cksum.1)
>
> Oh right. Though all OpenBSD's cksum options are not supported
> so we don't have to worry too much about direct compat here.
>
> > One nit: the in-comment reference to -b needs to say --base64, too (in
> > tests/cksum/cksum-base64.pl):
> >
> >      # Ensure that each of the above works with -b:
> >      (map {my ($h,$v)= @$_; my $o=fmt $h,$v;
> > -         [$h, "-ba $h", {IN=>{f=>''}}, {OUT=>"$o\n"}]} @pairs),
> > +         [$h, "--base64 -a $h", {IN=>{f=>''}}, {OUT=>"$o\n"}]} @pairs),
>
> Latest patch attached.

Nice. I like seeing so many ifdefs being deleted.
One nit is in NEWS. I'd change this:
+  'cksum -b' will no longer print base64-encoded checksums.  Rather that

to this:
+  'cksum -b' no longer prints base64-encoded checksums.  Rather that

oh, and also simplify this:
+    printf -- '%s' "$pmode" | grep '<mode>' > /dev/null && pmode="$tmode"

to this:
+    case $pmode in *'<mode>') pmode=$tmode;; esac

If you were to use e.g., MODE as the marker instead of <mode>, you
could drop the single quotes, too.

Thanks!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]