Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Aug 2001 15:57:31 -0500
From:      Chris Costello <chris@calldei.com>
To:        hackers@FreeBSD.org
Subject:   For review: Patch to ps(1) old-style option parsing.
Message-ID:  <20010815155730.B606@holly.calldei.com>

next in thread | raw e-mail | index | archive | help

--bg08WKrSYDhXBjb5
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

   This is pretty low-priority and I don't think it needs to be
MFC'd for the 4.4 release, but there is a small error in ps's
old-style option handling.  An outstanding example of this is
when one runs `ps Uroot':

$ ps Uroot
ps: rooT: no such user
ps: No users specified

   The problem is that the function ps.c:kludge_oldps_options()
capitalizes any 't' at the end of the option string, regardless
of whether it's a flag or an option argument.  The patch attached
to this message should fix the problem.

-- 
+-------------------+----------------------------------------------------+
| Chris Costello    | The cost of living hasn't affected its popularity. |
| chris@calldei.com |                                                    |
+-------------------+----------------------------------------------------+

--bg08WKrSYDhXBjb5
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="ps.patch"

Index: ps.c
===================================================================
RCS file: /home/ncvs/src/bin/ps/ps.c,v
retrieving revision 1.40
diff -u -r1.40 ps.c
--- ps.c	2001/05/30 03:27:07	1.40
+++ ps.c	2001/08/15 20:55:04
@@ -599,8 +599,12 @@
 	 * if last letter is a 't' flag with no argument (in the context
 	 * of the oldps options -- option string NOT starting with a '-' --
 	 * then convert to 'T' (meaning *this* terminal, i.e. ttyname(0)).
+	 *
+	 * However, if a flag accepting a string argument is found in the
+	 * option string, the remainder of the string is the argument to
+	 * that flag; do not modify that argument.
 	 */
-	if (*cp == 't' && *s != '-')
+	if (strcspn(s, "MNOoUW") == len && *cp == 't' && *s != '-')
 		*cp = 'T';
 	else {
 		/*

--bg08WKrSYDhXBjb5--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010815155730.B606>