title: Why is this pipeline behave differently in ksh93 compared to bash?
body: <p>I had an issue with a ksh93 code. As it was very complex I started reducing it to an example code that will reproduce the same issue. I ended up with this:</p>
  
  <pre><code>set -o pipefail;
  
  {
          echo "progress" 1&gt;&amp;3 | false
  } 3&gt;&amp;1 | cat | \
          while read pv_output; do
                  echo "meanwhile ... we got "
                  echo $pv_output | cat
          done
  
  echo $?
  </code></pre>
  
  <p>When I run this code with ksh93 it outputs "0", when I run it with bash it outputs "1".</p>
  
  <pre><code># echo "ksh93";ksh93 ./x1.sh ;echo "bash"; bash ./x1.sh
  ksh93
  meanwhile ... we got
  progress
  0
  bash
  meanwhile ... we got
  progress
  1
  </code></pre>
  
  <p>However if I start fiddling with the code, and remove the first <code>cat</code>, both shells return "1"</p>
  
  <pre><code>set -o pipefail;
  
  {
          echo "progress" 1&gt;&amp;3 | false
  } 3&gt;&amp;1 | \
          while read pv_output; do
                  echo "meanwhile ... we got "
                  echo $pv_output | cat
          done
  
  echo $?
  </code></pre>
  
  <p>Or... if I leave in the first <code>cat</code>, but I remove the second one from inside the <code>while</code>, they work the same way again.</p>
  
  <pre><code>set -o pipefail;
  
  {
          echo "progress" 1&gt;&amp;3 | false
  } 3&gt;&amp;1 | cat | \
          while read pv_output; do
                  echo "meanwhile ... we got "
                  echo $pv_output
          done
  
  echo $?
  </code></pre>
  
  <p>Now, for this example I used <code>cat</code> for simplicity's sake. In real life the first <code>cat</code> is actually an <code>awk</code> processing the output of a complicated command. The second <code>cat</code> is actually a <code>sed</code>. I mention these, so that it is clear that the <code>cat</code> command in itself is not the culprit.</p>