emacs-bug-tracker
[Top][All Lists]
Advanced

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

[debbugs-tracker] bug#22205: closed (tee bug?)


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#22205: closed (tee bug?)
Date: Fri, 18 Dec 2015 16:44:02 +0000

Your message dated Fri, 18 Dec 2015 09:43:51 -0700
with message-id <address@hidden>
and subject line Re: bug#22205: tee bug?
has caused the debbugs.gnu.org bug report #22205,
regarding tee bug?
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
22205: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22205
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: tee bug? Date: Fri, 18 Dec 2015 14:18:07 +0100 User-agent: Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Thunderbird/38.4.0
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:

VAR=""

A() {
    VAR="This is my value"   
    echo "VAR in $FUNCNAME: $VAR"
}

BA() {
    A
    echo "VAR in $FUNCNAME: $VAR"
}


$ BA
VAR in A: This is my value
VAR in BA: This is my value

Many thanks for your priceless effort,
Nacho


Juan Ignacio Esteban

Integration Architect & Security Officer | Integration Centre of Expertise


Walgreens Boots Alliance - Enterprise IT Shared Services - Retail Pharmacy International & Pharmaceutical Wholesale

Pol. Ind. San Miguel Sector 4 | Villanueva de Gállego | Zaragoza (Spain) | 50830

 

Member of Walgreens Boots Alliance

 


Walgreens Boots Alliance Services Limited is registered in England & Wales with
company number 7073433 
Registered Office: 2 The Heights, Brooklands, Weybridge, Surrey, KT13 0NY 
Walgreens Boots Alliance Services Limited is a member of Walgreens Boots
Alliance. 

This e-mail (including any attachments) is confidential and may be privileged or
otherwise protected. It may be read, copied and used only by the intended
recipient. If you are not the intended recipient you should not copy it or use it
for any purpose or disclose its contents to another person. If you have received
this message in error, please notify us and remove it from your system. Messages
sent to and from companies in the Walgreens Boots Alliance company may be
monitored to ensure compliance with internal policies and to protect our
business. Emails are not secure and cannot be guaranteed to be error free. We
cannot accept liability for any damage you incur as a result of virus infection.

--- End Message ---
--- Begin Message --- Subject: Re: bug#22205: tee bug? Date: Fri, 18 Dec 2015 09:43:51 -0700 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0
tag 22205 notabug
thanks

On 12/18/2015 06:18 AM, Nacho Esteban wrote:
> Hi team,
> 
> I detected an strange behaviour of tee command that may bee a bug.

Not a bug in tee, but intentional behavior of your shell.

> 
> Please consider this script snippet
> 
>    VAR=""
> 
>    A() {
>         VAR="This is my value"
>         echo "VAR in $FUNCNAME: $VAR"
>    }
> 
>    BA() {
>         A | tee /tmp/kk

You are using a pipeline.  Shells implement pipelines by running the
left command (here, the function A) in a subshell. (POSIX also says that
the right command can also be a subshell, but there it is not required;
ksh runs the right command in the current shell, and bash used to run it
in a subshell but new enough bash now has a knob you can turn on to
emulate ksh behavior).

Therefore, all changes to the environment made during the execution of A
are local to that subshell, and are lost as soon as the subshell exits.

>         echo "VAR in $FUNCNAME: $VAR"

Thus, here you print the value of $VAR as it was before A ran, since
running A does not affect the current shell.


> In fact if "| tee /tmp/kk" is removed value of VAR is properly visible
> from BA function:

Because then you no longer have a subshell, so now the execution of
function A affects the current shell.  Again, not tee's fault.  You
could replace it with "| :" and see the same effect.

> This e-mail (including any attachments) is confidential and may be
> privileged or

Such a disclaimer is unenforceable on publically-archived lists, and you
may want to consider not using your employer's spammy email gateway when
sending mail to public lists.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---

reply via email to

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