[PATCH v2 3/3] touch: add --time=what option

Denys Vlasenko vda.linux at googlemail.com
Tue Apr 13 22:37:50 UTC 2021


On Tue, Apr 13, 2021 at 11:37 PM Xabier Oneca -- xOneca
<xoneca at gmail.com> wrote:
> > > +        static const char *time_values ALIGN1 =
> > > +            /* OPT_a: */ "access\0" "atime\0" "use\0"
> > > +            /* OPT_m: */ "modify\0" "mtime\0";
> > > +        int pos = index_in_substrings(time_values, time_arg);
> > > +
> > > +        if (pos >= 3) {
> > > +            opts |= OPT_m;
> > > +        } else if (pos >= 0) {
> > > +            opts |= OPT_a;
> > > +        } else {
> > > +            //bb_error_msg("Invalid value: %s", time_arg);
> > > +            bb_show_usage();
> > > +        }
> >
> > how about this instead? -
> >            opts |= (time_arg[0] == 'm') ? OPT_m : OPT_a;
>
> Your suggestion is pretty smart. But I don't know... If it were a more
> popular option maybe. But I don't like it 'half baked'.
>
> This option being neither popular[citation needed] nor part of the
> standard, if I had to vote I would reject it entirely. I'm guilty of
> featuritis. Sorry. :)

My proposal would make all _valid_ uses of --time XYZ to work
properly, with minimum of code.

It would work incorrectly only for invalid XYZs,
there are far fewer people who would care about that.


More information about the busybox mailing list