summaryrefslogtreecommitdiffstats
path: root/bin/sh/jobs.c
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2012-09-15 21:56:30 +0000
committerjilles <jilles@FreeBSD.org>2012-09-15 21:56:30 +0000
commit99ca87dd2daf11623d11838ece4dba4e0ab94951 (patch)
tree8f1502baabb3376aec513c46c8781c9f452a7b3d /bin/sh/jobs.c
parent56fd9326eeef1f0702902d3716e1551e76049d94 (diff)
downloadFreeBSD-src-99ca87dd2daf11623d11838ece4dba4e0ab94951.zip
FreeBSD-src-99ca87dd2daf11623d11838ece4dba4e0ab94951.tar.gz
sh: Prefer internal nextopt() to libc getopt().
This reduces code duplication and code size. /usr/bin/printf is not affected. Side effect: different error messages when certain builtins are passed invalid options.
Diffstat (limited to 'bin/sh/jobs.c')
-rw-r--r--bin/sh/jobs.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c
index 99efc80..05e2e88 100644
--- a/bin/sh/jobs.c
+++ b/bin/sh/jobs.c
@@ -250,15 +250,13 @@ restartjob(struct job *jp)
int
-jobscmd(int argc, char *argv[])
+jobscmd(int argc __unused, char *argv[] __unused)
{
char *id;
int ch, mode;
- optind = optreset = 1;
- opterr = 0;
mode = SHOWJOBS_DEFAULT;
- while ((ch = getopt(argc, argv, "lps")) != -1) {
+ while ((ch = nextopt("lps")) != '\0') {
switch (ch) {
case 'l':
mode = SHOWJOBS_VERBOSE;
@@ -269,18 +267,13 @@ jobscmd(int argc, char *argv[])
case 's':
mode = SHOWJOBS_PIDS;
break;
- case '?':
- default:
- error("unknown option: -%c", optopt);
}
}
- argc -= optind;
- argv += optind;
- if (argc == 0)
+ if (*argptr == NULL)
showjobs(0, mode);
else
- while ((id = *argv++) != NULL)
+ while ((id = *argptr++) != NULL)
showjob(getjob(id), mode);
return (0);
OpenPOWER on IntegriCloud