summaryrefslogtreecommitdiffstats
path: root/bin/ps/ps.c
diff options
context:
space:
mode:
authorgad <gad@FreeBSD.org>2004-06-01 02:31:44 +0000
committergad <gad@FreeBSD.org>2004-06-01 02:31:44 +0000
commit7a915f30a709eb7c2e2d7f4f5f9ce5ad30818fa8 (patch)
tree5d57cc1f7dfad89a0ca4f695ca371a6229044041 /bin/ps/ps.c
parent3672d683c6bfff855f778c844e4930b7f1fbc51d (diff)
downloadFreeBSD-src-7a915f30a709eb7c2e2d7f4f5f9ce5ad30818fa8.zip
FreeBSD-src-7a915f30a709eb7c2e2d7f4f5f9ce5ad30818fa8.tar.gz
Additional tiny adjustment to kludge-option processing so `ps t p0'
is treated like `ps -t p0', instead of changing it to `ps -T p0'. Note that `ps t' is still changed to `ps -T', since that is one of the main reasons for this kludge processing... Noticed by: Jilles Tjoelker on freebsd-arch
Diffstat (limited to 'bin/ps/ps.c')
-rw-r--r--bin/ps/ps.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/bin/ps/ps.c b/bin/ps/ps.c
index 56ba01e..df49ab4 100644
--- a/bin/ps/ps.c
+++ b/bin/ps/ps.c
@@ -140,7 +140,7 @@ static const char *
KINFO *, char *, int);
static void free_list(struct listinfo *);
static void init_list(struct listinfo *, addelem_rtn, int, const char *);
-static char *kludge_oldps_options(const char *opts, char *);
+static char *kludge_oldps_options(const char *opts, char *, const char *);
static int pscomp(const void *, const void *);
static void saveuser(KINFO *);
static void scanvars(void);
@@ -193,7 +193,7 @@ main(int argc, char *argv[])
* to support some historical BSD behaviors, such as `ps axu'.
*/
if (argc > 1)
- argv[1] = kludge_oldps_options(PS_ARGS, argv[1]);
+ argv[1] = kludge_oldps_options(PS_ARGS, argv[1], argv[2]);
all = dropgid = _fmt = nselectors = optfatal = 0;
prtheader = showthreads = wflag = xkeep_implied = 0;
@@ -1077,7 +1077,7 @@ pscomp(const void *a, const void *b)
* feature is available with the option 'T', which takes no argument.
*/
static char *
-kludge_oldps_options(const char *optlist, char *origval)
+kludge_oldps_options(const char *optlist, char *origval, const char *nextarg)
{
size_t len;
char *argp, *cp, *newopts, *ns, *optp, *pidp;
@@ -1114,9 +1114,10 @@ kludge_oldps_options(const char *optlist, char *origval)
len = strlen(origval);
cp = origval + len - 1;
pidp = NULL;
- if (*cp == 't' && *origval != '-' && cp == argp)
- *cp = 'T';
- else if (argp == NULL) {
+ if (*cp == 't' && *origval != '-' && cp == argp) {
+ if (nextarg == NULL || *nextarg == '-' || isdigitch(*nextarg))
+ *cp = 'T';
+ } else if (argp == NULL) {
/*
* The original value did not include any option which takes
* an argument (and that would include `p' and `t'), so check
OpenPOWER on IntegriCloud