Subject: Re: bin/2837: su manpage inaccurate
To: None <netbsd-bugs@NetBSD.ORG>
From: William O Ferry <WOFerry+@CMU.EDU>
List: netbsd-bugs
Date: 10/12/1996 14:48:16
Excerpts from netbsd-bugs: 12-Oct-96 bin/2837: su manpage inaccu.. by
William O Ferry@WarpDriv 
> >Description:
>         
>         Manpage for su(1) lists the synopsis
> "su [-Kflm] [login [shell arguments]]", yet su's usage string says
> "usage: su [-flm] [login]", and there does not appear to be code in
> /usr/src/usr.bin/su/su.c to handle the [shell arguments] option.  If
you try t
> o
> use the option, it creates some rather unusual (but consistant) results.
>  
> >How-To-Repeat:
>         
> Warpdrive# su root /bin/csh -f
> Unmatched ".
> Warpdrive# su root /usr/local/bin/tcsh -f
> M^@M^F^A^KM-P^C04M-Z: Command not found.
> Failure: Command not found.
> Bad: Command not found.
> Cannot: Command not found.
> crt0:: Too many arguments.
>  
> >Fix:
>         
>         Remove references in manpage, or add options to program (I'd prefer
> the latter, but cannot think up the code this early in the morning...  =)  If
> I work something up this weekend, I'll add onto the pr.

    Okay, thanks to a note from Theo de Raadt saying that su was working
right, but csh wasn't, here's a simple fix.  `man csh` documents a "-c"
option, which treats the remainder of the line as a command and
arguments, as opposed to the default behavior of opening the argument as
a shell script and trying to run it (which was generating the problems
above).

WARPDRIVE.RES.CMU.EDU (root) /usr/src/usr.bin/su % diff -uN su.c.orig su.c
--- su.c.orig      Fri Oct 13 23:25:22 1995
+++ su.c        Sat Oct 12 14:33:51 1996
@@ -108,7 +108,7 @@
                        break;
                case '?':
                default:
-                       (void)fprintf(stderr, "usage: su [%s] [login]\n",
+                       (void)fprintf(stderr, "usage: su [%s] [login
[shell arguments]]\n",
                            ARGSTR);
                        exit(1);
                }
@@ -251,6 +251,9 @@
        }
 
        if (iscsh == YES) {
+               if (np[1])
+                 /* if passed any additional arguments, csh needs a "-c" */
+                       *np-- = "-c";
                if (fastlogin)
                        *np-- = "-f";
                if (asme)