[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#22205: tee bug?
From: |
Pádraig Brady |
Subject: |
bug#22205: tee bug? |
Date: |
Fri, 18 Dec 2015 16:45:25 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
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