From owner-freebsd-arch@FreeBSD.ORG Fri May 28 08:52:24 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5CFEF16A4CE for ; Fri, 28 May 2004 08:52:24 -0700 (PDT) Received: from mailhost.stack.nl (vaak.stack.nl [131.155.140.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id C2AA943D3F for ; Fri, 28 May 2004 08:52:23 -0700 (PDT) (envelope-from jilles@stack.nl) Received: from turtle.stack.nl (turtle.stack.nl [IPv6:2001:610:1108:5010::132]) by mailhost.stack.nl (Postfix) with ESMTP id 7BC881F189; Fri, 28 May 2004 17:51:40 +0200 (CEST) Received: by turtle.stack.nl (Postfix, from userid 1677) id 4A3781CD8A; Fri, 28 May 2004 17:51:40 +0200 (CEST) Date: Fri, 28 May 2004 17:51:40 +0200 From: Jilles Tjoelker To: Garance A Drosihn Message-ID: <20040528155139.GB85017@stack.nl> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: FreeBSD 5.2.1-RELEASE-p8 i386 User-Agent: Mutt/1.5.6i cc: arch@FreeBSD.ORG Subject: Re: Change to "kludge option processing" in /bin/ps X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 May 2004 15:52:24 -0000 On Sun, May 23, 2004 at 10:58:23PM -0400, Garance A Drosihn wrote: > After staring at the kludge-option processing in `ps' for awhile, I > found enough edge-cases where it simply did not work "right" (for my > definition of "right", at keast...), so I rewrote it. As part of that, > I also removed the ancient "BACKWARD_COMPATIBILITY" compile-time > option, where: > ps -options arg1 arg2 > (with no '-' on "arg1" and "arg2") was treated as: > ps -options -N arg1 -M arg2 > I did this because I have often been puzzled/annoyed when I type: > ps 12 > to get process 12, and then realize I wanted it shown in a > different format so I type: > ps -u 12 What you should use is 'ps u12' :) That also works on old (pre-Reno) BSD ps, and it's shorter too. It doesn't work on Solaris /usr/ucb/ps, but my ps shell function takes care of that (for me). > and I get a completely different list of processes, or I type: > ps 12 34 > and I only see process 12, or I type > ps 12 34 56 > and get the error message: > ps: 56: No such file or directory > This BACKWARD_COMPATIBILITY is not documented in the usage() > or the man page, so I'd like to replace it. Note that netstat(1) has similar backward compatibility, and gdb -k uses the same order (namelist then memory). You're right that this is rather confusing. > So, I changed `ps' to check for any additional arguments after > processing all '-'-options, and if those start with a digit then > `ps' will try to use the entire argument as a pid or pidlist. > If an extra argument does not start with a digit, then `ps' just > prints an error and exits. > I want to do more testing on this before committing, but I thought > that all this was enough of a change that I should also give people > a chance to scream before I commit it. Also, I'm not sure if I > might have clobbered some subtle aspect of the kludge processing. > If anyone wants to try the update, it is available at: > http://people.freebsd.org/~gad/ps-kludge.diff > [disclaimer: at the moment it's only had about 15 minutes of > testing, but I *think* this is about the way I want it to work] > Assuming there aren't any major objections to these ideas, I plan > to do some more testing on this and commit it next weekend. Unfortunately, I can't try it out because I don't have access to a very recent -CURRENT. What's the deeper purpose of the `optlist' argument for `kludge_oldps_options' if it's always set to PS_ARGS? I have some doubts on whether `ps t' instead of `ps T' should still be supported, since `ps t p0' doesn't work because of it. You could only change 't' to 'T' when there are no more arguments. Am I right that `ps U0' is equivalent to `ps -U0' with the patch? (This wasn't really much of an issue before `-U' accepted uids instead of names.) What happens when you do `ps 1,2,3,4'? And `ps uww0,1'? Or even `ps "v1 $$"'? All this complexity makes me think of not using getopt(3), as Albert Cahalan suggested :) -- Jilles Tjoelker