[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
jobs output should be to stdout, bg/fg should write to stderr
From: |
llattanzi+bash |
Subject: |
jobs output should be to stdout, bg/fg should write to stderr |
Date: |
Mon, 19 Jul 2004 13:55:08 -0700 (PDT) |
Configuration Information [Automatically generated, do not change]:
Machine: powerpc
OS: darwin8.0
Compiler: gcc
Compilation CFLAGS: -arch i386 -arch ppc -g -Os -pipe -no-cpp-precomp
-arch i386 -arch ppc -pipe -DPROGRAM='bash' -DCONF_HOSTTYPE='powerpc'
-DCONF_OSTYPE='darwin8.0' -DCONF_MACHTYPE='powerpc-apple-darwin8.0'
-DCONF_VENDOR='apple' -DSHELL -DHAVE_CONFIG_H -DMACOSX -I.
-I/SourceCache/bash/bash-32/bash
-I/SourceCache/bash/bash-32/bash/include
-I/SourceCache/bash/bash-32/bash/lib -arch i386 -arch ppc -g -Os -pipe
-no-cpp-precomp -arch i386 -arch ppc -pipe
uname output: Darwin stderr.apple.com 8.0.0b1 Darwin Kernel Version
8.0.0b1: Mon Jul 12 21:41:56 PDT 2004;
root:xnu/xnu-638.1.obj~4/RELEASE_PPC Power Macintosh powerpc
Machine Type: powerpc-apple-darwin8.0
Bash Version: 2.05b
Patch Level: 0
Release Status: release
Description:
jobs > jobs.out #is empty
wait $!; wait $! # will succeed
Fix:
Index: bash/bash/jobs.c
diff -u bash/bash/jobs.c:1.2 bash/bash/jobs.c:1.2.18.1
--- bash/bash/jobs.c:1.2 Thu Sep 11 20:24:47 2003
+++ bash/bash/jobs.c Mon Jul 19 13:53:59 2004
@@ -986,7 +986,7 @@
job = find_job (pid, 0);
if (job != NO_JOB)
- printf ("[%d] %ld\n", job + 1, (long)pid);
+ fprintf (posixly_correct ? stderr : stdout, "[%d] %ld\n", job + 1,
(long)pid);
else
programming_error ("describe_pid: %ld: no such pid", (long)pid);
@@ -1601,6 +1601,7 @@
sigset_t set, oset;
int r, job;
+ cleanup_dead_jobs(); /* Don't let "wait $pid; wait $pid" succeed */
BLOCK_CHILD (set, oset);
child = find_pipeline (pid, 0, (int *)NULL);
UNBLOCK_CHILD (oset);
@@ -2230,6 +2231,7 @@
sigset_t set, oset;
char *wd;
static TTYSTRUCT save_stty;
+ FILE *output = posixly_correct ? stdout : stderr;
BLOCK_CHILD (set, oset);
@@ -2263,13 +2265,17 @@
/* Tell the outside world what we're doing. */
p = jobs[job]->pipe;
- if (foreground == 0)
- fprintf (stderr, "[%d]%c ", job + 1,
- (job == current_job) ? '+': ((job == previous_job) ? '-' : ' '));
+ if (foreground == 0) {
+ if (posixly_correct) {
+ fprintf (output, "[%d] ", job + 1);
+ } else
+ fprintf (output, "[%d]%c ", job + 1,
+ (job == current_job) ? '+': ((job == previous_job) ? '-' : '
'));
+ }
do
{
- fprintf (stderr, "%s%s",
+ fprintf (output, "%s%s",
p->command ? p->command : "",
p->next != jobs[job]->pipe? " | " : "");
p = p->next;
@@ -2277,12 +2283,12 @@
while (p != jobs[job]->pipe);
if (foreground == 0)
- fprintf (stderr, " &");
+ fprintf (output, " &");
if (strcmp (wd, jobs[job]->wd) != 0)
- fprintf (stderr, " (wd: %s)", polite_directory_format
(jobs[job]->wd));
+ fprintf (output, " (wd: %s)", polite_directory_format
(jobs[job]->wd));
- fprintf (stderr, "\n");
+ fprintf (output, "\n");
/* Run the job. */
if (already_running == 0)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- jobs output should be to stdout, bg/fg should write to stderr,
llattanzi+bash <=