GNU bug report logs -
#22205
tee bug?
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 22205 in the body.
You can then email your comments to 22205 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#22205
; Package
coreutils
.
(Fri, 18 Dec 2015 16:31:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Nacho Esteban <juanignacio.esteban <at> alliance-healthcare.net>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Fri, 18 Dec 2015 16:31:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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.
[Message part 2 (text/html, inline)]
Added tag(s) notabug.
Request was from
Eric Blake <eblake <at> redhat.com>
to
control <at> debbugs.gnu.org
.
(Fri, 18 Dec 2015 16:44:02 GMT)
Full text and
rfc822 format available.
Reply sent
to
Eric Blake <eblake <at> redhat.com>
:
You have taken responsibility.
(Fri, 18 Dec 2015 16:44:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Nacho Esteban <juanignacio.esteban <at> alliance-healthcare.net>
:
bug acknowledged by developer.
(Fri, 18 Dec 2015 16:44:02 GMT)
Full text and
rfc822 format available.
Message #12 received at 22205-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#22205
; Package
coreutils
.
(Fri, 18 Dec 2015 16:46:02 GMT)
Full text and
rfc822 format available.
Message #15 received at 22205 <at> debbugs.gnu.org (full text, mbox):
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
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 16 Jan 2016 12:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 9 years and 158 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.