On Mon, Oct 11, 2021 at 09:13:16AM -0500, Scott Cheloha wrote:
> On Sun, Oct 10, 2021 at 08:26:04PM -0400, gwes wrote:
> > On 10/10/21 5:03 PM, Scott Cheloha wrote:
> > > [...]
> > > 
> > > If we want to have the unportable legacy syntax then it should work
> > > like other option arguments.  Option arguments can be respecified
> > > multiple times in most other utilities.  The last such appearance of
> > > an option argument is the one the utility uses.  That's how option
> > > arguments work, for the most part.
> > > 
> > > We could remove the legacy syntax and shave a couple lines of code.
> > > 
> > > OTOH, supporting it fully is super easy.  I've provided a patch.
> > > 
> > The man page says head [-count | -n count] [file ...]
> > There are only two valid switches.
> > One, the other, or none.
> > Using more than one is -undefined-.
> > I doubt it ever has been defined.
> > It could be asserted that any more than 1 switch is an error.
> 
> No.
> 
> It wouldn't be an error, it would be undefined.  Just like you said.

If we have survived with a crippled backwards compat since '95, it's
pretty pointless to re-add it now.

I also started thinking about e.g. kill(1). We don't support multiple
signals there.

Thinking a bit more, and testing some, I'm pretty sure the following 
change to usage() and the man page would suffice.

-       usage: head [-count | -n count] [file ...]
+       usage: head [-count] [-n count] [file ...]

/Alexander


Index: head.1
===================================================================
RCS file: /cvs/src/usr.bin/head/head.1,v
retrieving revision 1.23
diff -u -p -r1.23 head.1
--- head.1      25 Oct 2015 21:50:32 -0000      1.23
+++ head.1      14 Oct 2021 21:28:31 -0000
@@ -37,7 +37,8 @@
 .Nd display first few lines of files
 .Sh SYNOPSIS
 .Nm head
-.Op Fl Ar count | Fl n Ar count
+.Op Fl Ar count
+.Op Fl n Ar count
 .Op Ar
 .Sh DESCRIPTION
 The
Index: head.c
===================================================================
RCS file: /cvs/src/usr.bin/head/head.c,v
retrieving revision 1.22
diff -u -p -r1.22 head.c
--- head.c      10 Oct 2021 15:57:25 -0000      1.22
+++ head.c      14 Oct 2021 21:28:31 -0000
@@ -114,6 +114,6 @@ main(int argc, char *argv[])
 static void
 usage(void)
 {
-       fputs("usage: head [-count | -n count] [file ...]\n", stderr);
+       fputs("usage: head [-count] [-n count] [file ...]\n", stderr);
        exit(1);
 }

Reply via email to