[Bug 228088] /usr/src/usr.bin/killall/killall.1 - killall recognizes only first option of conjoined option argument

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Wed May 9 07:13:47 UTC 2018


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=228088

            Bug ID: 228088
           Summary: /usr/src/usr.bin/killall/killall.1 - killall
                    recognizes only first option of conjoined option
                    argument
           Product: Documentation
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: Manual Pages
          Assignee: bugs at FreeBSD.org
          Reporter: ossbsd at gmail.com
                CC: doc at FreeBSD.org

Created attachment 193199
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=193199&action=edit
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):

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

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
...
SYNOPSIS
      killall [-delmsvz] [-help] [-I] [-j jail] [-u user] [-t tty]
....

by patch changes to

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

### Files
See attached patch.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the freebsd-doc mailing list