[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
%% should be usable in shell scripts, also fg/bg output should go to std
From: |
llattanzi+bash |
Subject: |
%% should be usable in shell scripts, also fg/bg output should go to stdout |
Date: |
Tue, 13 Jul 2004 16:27: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-30/bash
-I/SourceCache/bash/bash-30/bash/include
-I/SourceCache/bash/bash-30/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 Jun 21 20:09:53 PDT 2004;
root:xnu/xnu-634.obj~2/RELEASE_PPC Power Macintosh powerpc
Machine Type: powerpc-apple-darwin8.0
Bash Version: 2.05b
Patch Level: 0
Release Status: release
Description:
kill won't process %% if not interactive
fg/bg write to stderr instead of stdout
Repeat-By:
cat > test.sh <<EOF
sleep 10 &
kill -HUP %%
EOF
sh test.sh
sleep 10 &
bg > bg.out 2>bg.err
fg > fg.out 2>fg.err
# Where did the output go?
Fix:
Index: bash/jobs.c
===================================================================
RCS file: /cvs/root/bash/bash/jobs.c,v
retrieving revision 1.2
diff -u -d -b -w -r1.2 jobs.c
--- jobs.c 2003/09/12 03:24:47 1.2
+++ jobs.c 2004/07/13 23:18:49
@@ -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);
@@ -2230,6 +2230,7 @@
sigset_t set, oset;
char *wd;
static TTYSTRUCT save_stty;
+ FILE *output = posixly_correct ? stdout : stderr;
BLOCK_CHILD (set, oset);
@@ -2264,12 +2265,12 @@
p = jobs[job]->pipe;
if (foreground == 0)
- fprintf (stderr, "[%d]%c ", job + 1,
+ 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 +2278,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)
Index: bash/builtins/kill.def
===================================================================
RCS file: /cvs/root/bash/bash/builtins/kill.def,v
retrieving revision 1.1.1.4
diff -u -d -b -w -r1.1.1.4 kill.def
--- kill.def 2003/04/05 08:00:28 1.1.1.4
+++ kill.def 2004/07/13 23:18:49
@@ -178,7 +178,7 @@
builtin_error ("%s: no such pid", list->word->word);
CONTINUE_OR_FAIL;
}
- else if (*word && (interactive || job_control))
+ else if (*word)
/* Posix.2 says you can kill without job control active (4.32.4) */
{ /* Must be a job spec. Check it out. */
int job;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- %% should be usable in shell scripts, also fg/bg output should go to stdout,
llattanzi+bash <=