From b72e0fae17fc6090caae787b8da94c9d48147a91 Mon Sep 17 00:00:00 2001 From: tjr Date: Sun, 19 May 2002 07:27:26 +0000 Subject: Make the fg and bg commands give the output required by SUSv3. fg outputs the name of the command, bg outputs the name of the command and the job id. --- bin/sh/jobs.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'bin/sh') diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index b1cc2de..54d596b 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -203,6 +203,9 @@ fgcmd(int argc __unused, char **argv) jp = getjob(argv[1]); if (jp->jobctl == 0) error("job not created under job control"); + out1str(jp->ps[0].cmd); + out1c('\n'); + flushout(&output); pgrp = jp->ps[0].pid; #ifdef OLD_TTY_DRIVER ioctl(2, TIOCSPGRP, (char *)&pgrp); @@ -220,13 +223,20 @@ fgcmd(int argc __unused, char **argv) int bgcmd(int argc, char **argv) { + char s[64]; struct job *jp; do { jp = getjob(*++argv); if (jp->jobctl == 0) error("job not created under job control"); + if (jp->state == JOBDONE) + continue; restartjob(jp); + fmtstr(s, 64, "[%d] ", jp - jobtab + 1); + out1str(s); + out1str(jp->ps[0].cmd); + out1c('\n'); } while (--argc > 1); return 0; } -- cgit v1.1