<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>665</bug_id>
          
          <creation_ts>2002-02-23 17:50:41 +0300</creation_ts>
          <short_desc>read builtin doesn\&apos;t work if its input comes from a pipe</short_desc>
          <delta_ts>2003-08-25 15:18:28 +0400</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>bash</component>
          <version>unstable</version>
          <rep_platform>all</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>NOTABUG</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P4</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="imz">vanyaz</reporter>
          <assigned_to name="placeholder@altlinux.org">placeholder</assigned_to>
          <cc>glebfm</cc>
    
    <cc>ldv</cc>
    
    <cc>placeholder</cc>
    
    <cc>vt</cc>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>636</commentid>
    <comment_count>0</comment_count>
    <who name="imz">vanyaz</who>
    <bug_when>2002-02-23 17:50:41 +0300</bug_when>
    <thetext>This command prints an empty line in bash-2.05-alt4:

a=\&amp;quot;\&amp;quot;; echo A | read a; echo $a

but it should print a line with A.

---

---
Strange that adding braces helps, these commands print A:

a=\&amp;quot;\&amp;quot;; echo A | { a=\&amp;quot;\&amp;quot;; read a; echo $a; }
a=\&amp;quot;\&amp;quot;; echo A | ( a=\&amp;quot;\&amp;quot;; read a; echo $a; )

Reading from the keyboard and not a pipe also works correctly.

All the three commands mentioned here work the same right way in zsh.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3328</commentid>
    <comment_count>1</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2002-03-22 17:49:28 +0300</bug_when>
    <thetext>See /usr/share/doc/bash-2.05/FAQ:

E4) If I pipe the output of a command into `read variable\&apos;, why doesn\&apos;t
    the output show up in $variable when the read command finishes?

This has to do with the parent-child relationship between Unix
processes.  It affects all commands run in pipelines, not just
simple calls to `read\&apos;.  For example, piping a command\&apos;s output
into a `while\&apos; loop that repeatedly calls `read\&apos; will result in
the same behavior.

Each element of a pipeline runs in a separate process, a child of
the shell running the pipeline.  A subprocess cannot affect its
parent\&apos;s environment.  When the `read\&apos; command sets the variable
to the input, that variable is set only in the subshell, not the
parent shell.  When the subshell exits, the value of the variable
is lost.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6693</commentid>
    <comment_count>2</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2002-03-22 17:49:28 +0300</bug_when>
    <thetext>See /usr/share/doc/bash-2.05/FAQ:

E4) If I pipe the output of a command into `read variable\&apos;, why doesn\&apos;t
    the output show up in $variable when the read command finishes?

This has to do with the parent-child relationship between Unix
processes.  It affects all commands run in pipelines, not just
simple calls to `read\&apos;.  For example, piping a command\&apos;s output
into a `while\&apos; loop that repeatedly calls `read\&apos; will result in
the same behavior.

Each element of a pipeline runs in a separate process, a child of
the shell running the pipeline.  A subprocess cannot affect its
parent\&apos;s environment.  When the `read\&apos; command sets the variable
to the input, that variable is set only in the subshell, not the
parent shell.  When the subshell exits, the value of the variable
is lost.
</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>