title: bash redirect to /dev/stdout: Not a directory
body: <p>I recently upgraded from CentOS 5.8 (with GNU bash 3.2.25) to CentOS 6.5 (with GNU bash 4.1.2). A command that used to work with CentOS 5.8 no longer works with CentOS 6.5. It is a silly example with an easy workaround, but I am trying to understand what is going on underneath the bash hood that is causing the different behavior. Maybe it is a new bug in bash 4.1.2 or an old bug that was fixed and the new behavior is expected?</p>
  
  <p>CentOS 5.8:</p>
  
  <pre><code>    (echo "hi" &gt; /dev/stdout) &gt; test.txt
      echo $?
  0
      cat test.txt
  hi
  </code></pre>
  
  <p>CentOS 6.5:</p>
  
  <pre><code>    (echo "hi" &gt; /dev/stdout) &gt; test.txt
  -bash: /dev/stdout: Not a directory
      echo $?
  1
  </code></pre>
  
  <p>Update: It doesn't look like this is problem related to CentOS version. I have another CentOS 6.5 machine where the command works. I have eliminated any environment variables as the culprit. Any ideas?
  On all the machines these commands gives the same output:</p>
  
  <pre><code>    ls -ld /dev/stdout
  lrwxrwxrwx 1 root root 15 Apr 30 13:30 /dev/stdout -&gt; /proc/self/fd/1
  
      ls -lL /dev/stdout
  crw--w---- 1 user1 tty 136, 0 Oct 28 23:21 /dev/stdout
  </code></pre>
  
  <p>Another Update: It seems the sub-shell is inheriting the redirected stdout of the parent shell. The is not too surprising I guess, but still why does it work on one machine, but fail on the other machine when they are running the same bash version?</p>
  
  <p>On the working machine:</p>
  
  <pre><code>    ((ls -la /dev/stdout; ls -la /proc/self/fd/1) &gt;/dev/stdout) &gt; test.txt
      cat test.txt
  lrwxrwxrwx 1 root root 15 Aug 13 08:14 /dev/stdout -&gt; /proc/self/fd/1
  l-wx------ 1 user1 aladdin 64 Oct 29 06:54 /proc/self/fd/1 -&gt; /home/user1/test.txt
  </code></pre>
  
  <p>I think Yu Huang is right, redirecting to /tmp works on both machines. Both machines are using isilon NAS for the /home mount, but probably one has slightly different filesystem version or configuration that caused the error. In conclusion, redirecting to /dev/stdout should be avoided unless you know the parent process will not redirecting it.</p>
  
  <p>UPDATE: This problem arose after upgrade to NFS v4 from v3. After downgrading back to v3 this behavior went away.</p>