sort cmd args and document OpenBSD differences

This commit is contained in:
albert 2004-07-21 14:27:56 +00:00
parent 256b87dc12
commit 9e52b5aa29

94
pgrep.c
View File

@ -505,9 +505,44 @@ parse_opts (int argc, char **argv)
while ((opt = getopt (argc, argv, opts)) != -1) { while ((opt = getopt (argc, argv, opts)) != -1) {
switch (opt) { switch (opt) {
case 'G':
opt_rgid = split_list (optarg, conv_gid);
if (opt_rgid == NULL)
usage (opt);
++criteria_count;
break;
// case 'L': // OpenBSD: print full args along w/ PID
// opt_printargs = 1;
// break;
case 'P':
opt_ppid = split_list (optarg, conv_num);
if (opt_ppid == NULL)
usage (opt);
++criteria_count;
break;
case 'U':
opt_ruid = split_list (optarg, conv_uid);
if (opt_ruid == NULL)
usage (opt);
++criteria_count;
break;
case 'V':
fprintf(stdout, "%s (%s)\n", progname, procps_version);
exit(0);
case 'd':
opt_delim = strdup (optarg);
break;
case 'f': case 'f':
opt_full = 1; opt_full = 1;
break; break;
case 'g':
opt_pgrp = split_list (optarg, conv_pgrp);
if (opt_pgrp == NULL)
usage (opt);
break;
// case 'i':
// opt_insensitive = 1;
// break;
case 'l': case 'l':
opt_long = 1; opt_long = 1;
break; break;
@ -523,64 +558,37 @@ parse_opts (int argc, char **argv)
opt_oldest = 1; opt_oldest = 1;
++criteria_count; ++criteria_count;
break; break;
case 'v':
if (opt_oldest|opt_negate|opt_newest)
usage (opt);
opt_negate = 1;
break;
case 'x':
opt_exact = 1;
break;
case 'd':
opt_delim = strdup (optarg);
break;
case 'P':
opt_ppid = split_list (optarg, conv_num);
if (opt_ppid == NULL)
usage (opt);
++criteria_count;
break;
case 'g':
opt_pgrp = split_list (optarg, conv_pgrp);
if (opt_pgrp == NULL)
usage (opt);
break;
case 's': case 's':
opt_sid = split_list (optarg, conv_sid); opt_sid = split_list (optarg, conv_sid);
if (opt_sid == NULL) if (opt_sid == NULL)
usage (opt); usage (opt);
++criteria_count; ++criteria_count;
break; break;
case 'u':
opt_euid = split_list (optarg, conv_uid);
if (opt_euid == NULL)
usage (opt);
++criteria_count;
break;
case 'U':
opt_ruid = split_list (optarg, conv_uid);
if (opt_ruid == NULL)
usage (opt);
++criteria_count;
break;
case 'G':
opt_rgid = split_list (optarg, conv_gid);
if (opt_rgid == NULL)
usage (opt);
++criteria_count;
break;
case 't': case 't':
opt_term = split_list (optarg, conv_str); opt_term = split_list (optarg, conv_str);
if (opt_term == NULL) if (opt_term == NULL)
usage (opt); usage (opt);
++criteria_count; ++criteria_count;
break; break;
case 'u':
opt_euid = split_list (optarg, conv_uid);
if (opt_euid == NULL)
usage (opt);
++criteria_count;
break;
case 'v':
if (opt_oldest|opt_negate|opt_newest)
usage (opt);
opt_negate = 1;
break;
// Solaris -x, the standard, does ^(regexp)$
// OpenBSD -x, being broken, does a plain string
case 'x':
opt_exact = 1;
break;
case '?': case '?':
usage (opt); usage (opt);
break; break;
case 'V':
fprintf(stdout, "%s (%s)\n", progname, procps_version);
exit(0);
} }
} }
if (argc - optind == 1) if (argc - optind == 1)