bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Mixing exec redirection with explicit redirection, unexpected results


From: root
Subject: Mixing exec redirection with explicit redirection, unexpected results
Date: Tue, 8 Dec 2009 16:39:21 -0500

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-redhat-linux-gnu' 
-DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H -DRECYCLES_PIDS   -I.  -I. -I./include -I./lib  -D_GNU_SOURCE 
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall 
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
--param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic 
-fasynchronous-unwind-tables
uname output: Linux enterprise.herffjones.hj-int 2.6.18-128.el5 #1 SMP Wed Dec 
17 11:42:39 EST 2008 i686 i686 i386 GNU/Linux
Machine Type: i686-redhat-linux-gnu

Bash Version: 3.2
Patch Level: 25
Release Status: release

Description:
        When I use the 'exec' built-in to redirect standard output 
        for a script, and then also use explicit redirection on 
        other commands, pointing both to the same output file, 
        I get unpredictable (but repeatable) results with the output 
        out of order.

Repeat-By:
        The following script:

#!/bin/bash

>/tmp/foo
exec 1>/tmp/foo

echo a
echo B >>/tmp/foo
echo c
echo D >>/tmp/foo
echo e
echo F >>/tmp/foo

...should produce the following contents in /tmp/foo:
a
B
c
D
e
F

...but instead it produces:
a
c
e
F



Fix:
        I am at a loss for how to understand this behavior -- sorry, 
        I can't suggest a fix. :-(




reply via email to

[Prev in Thread] Current Thread [Next in Thread]