GNU bug report logs - #22205
tee bug?

Previous Next

Package: coreutils;

Reported by: Nacho Esteban <juanignacio.esteban <at> alliance-healthcare.net>

Date: Fri, 18 Dec 2015 16:31:03 UTC

Severity: normal

Tags: notabug

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

Full log


Message #15 received at 22205 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Nacho Esteban <juanignacio.esteban <at> alliance-healthcare.net>,
 22205 <at> debbugs.gnu.org
Subject: Re: bug#22205: tee bug?
Date: Fri, 18 Dec 2015 16:45:25 +0000
tag 22205 notabug
close 22205
stop

On 18/12/15 13:18, Nacho Esteban wrote:
> Hi team,
> 
> I detected an strange behaviour of tee command that may bee a bug.
> 
> Please consider this script snippet
> 
>     VAR=""
> 
>     A() {
>         VAR="This is my value"   
>         echo "VAR in $FUNCNAME: $VAR"
>     }
> 
>     BA() {
>         A | tee /tmp/kk
>         echo "VAR in $FUNCNAME: $VAR"
>     }
> 
> This is the output when when executed:
> 
>     $ BA
>     VAR in A: This is my value
>     VAR in BA:
> 
> 
> I miss the value of VAR inside BA function.
> 
> 
> 
> In fact if "| tee /tmp/kk" is removed value of VAR is properly visible from BA function:

The reason is due to the "|", not tee.
You can see that by replacing the tee with cat.
The pipe is implemented in a subshell and thus
can't propagate the VAR back to the current shell.

cheers,
Pádraig





This bug report was last modified 9 years and 159 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.