bug-bash
[Top][All Lists]
Advanced

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

Sub shell mit pipes


From: Morard Jean-Louis
Subject: Sub shell mit pipes
Date: Wed, 11 Aug 2004 09:59:11 +0200


Dear all,

I think there is a problem whith the bash shell, at least in the version 2.05b on RedHat EL 3. Here is my script (just a test for demonstration purposes):

#!/bin/bash

ALL=""
cat /tmp/text | while read LINE
do
        ALL="$LINE $ALL"
        echo $ALL
done
echo "ALL = $ALL"

The output is the following:
a
b a
c b a
d c b a
e d c b a
f e d c b a
g f e d c b a
ALL =

The behaviour could be considered as correct if we think about sub shells and so on... But it causes problems with portability from a standard ksh script on solaris. And it's not quite nice if we think that the following works correctly:

#!/bin/bash

ALL=""
cat /tmp/text | while read LINE
do
        ALL="$LINE $ALL"
        echo $ALL
done < /tmp/text
echo "ALL = $ALL"

The output is the following:
a
b a
c b a
d c b a
e d c b a
f e d c b a
g f e d c b a
ALL = g f e d c b a


Is there any environment variable to set so that it works correctly?

Thanks for your help!
Jean-Louis



______________________________________________________

______________________________________________________




reply via email to

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