From owner-freebsd-hackers Wed Aug 15 13:55:58 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from holly.calldei.com (adsl-208-191-149-190.dsl.hstntx.swbell.net [208.191.149.190]) by hub.freebsd.org (Postfix) with ESMTP id 9004437B413 for ; Wed, 15 Aug 2001 13:55:52 -0700 (PDT) (envelope-from chris@holly.calldei.com) Received: (from chris@localhost) by holly.calldei.com (8.11.4/8.9.3) id f7FKvZW09909 for hackers@FreeBSD.org; Wed, 15 Aug 2001 15:57:35 -0500 (CDT) (envelope-from chris) Date: Wed, 15 Aug 2001 15:57:31 -0500 From: Chris Costello To: hackers@FreeBSD.org Subject: For review: Patch to ps(1) old-style option parsing. Message-ID: <20010815155730.B606@holly.calldei.com> Reply-To: chris@calldei.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="bg08WKrSYDhXBjb5" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --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