Bug 228088 - /usr/src/usr.bin/killall/killall.1 - killall recognizes only first option of conjoined option argument
Summary: /usr/src/usr.bin/killall/killall.1 - killall recognizes only first option of ...
Status: New
Alias: None
Product: Documentation
Classification: Unclassified
Component: Manual Pages (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs mailing list
Keywords: patch
Depends on:
Reported: 2018-05-09 07:13 UTC by ossbsd
Modified: 2018-05-10 12:40 UTC (History)
1 user (show)

See Also:

killall.1 patch (518 bytes, patch)
2018-05-09 07:13 UTC, ossbsd
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ossbsd 2018-05-09 07:13:42 UTC
Created attachment 193199 [details]
killall.1 patch

### Problem
killall uses a custom option parser that silently ignores all but the first option in a conjoined nonargument option set. This behavior differs from that exhibited by the FreeBSD C Standard Library POSIX.1 getopt(3) function. 

### Explication
This user was surprised to find that 
$ killall -zs foo 
did not work as implied by the manpage, a potential pitfall for the unaware. 

A quick perusal of /usr/src/usr.bin/killall.c shows the custom option parser handles option -zs by doing the following (in algol/c ish psuedocode):

  if   **av == '-'         // aha, likely an option
  then ++*av
       switch (**av)) { 
         case 'z':         // yes, it is
         ...               // handle option
  av++/ac--                      // loop driver

Back at loop top, *av now points at what originally was *(av+1). Thus the conjoined option 's' is now buried in string pointed to by *(av-1) and silently ignored. 

### Solution
Either rewrite option parsing to be more POSIXish in behavior, or change the manpage. I take the second approach and attach a patch for the killall.1 manpage.

$ man killall
      killall [-delmsvz] [-help] [-I] [-j jail] [-u user] [-t tty]

by patch changes to

$ man killall
      killall [-d] [-e] [-l] [-m] [-s] [-v] [-z] [-help] [-I] [-j jail] [-u user] [-t tty]
      This utility silently ignores all but the first member of conjoined
      options. E.g., option -zs is interpreted as if option -z alone were

### Files
See attached patch.