title: Bash: Redirecting file descriptors
body: <p>I am hoping someone can explain a phenomenon. As the title indicates I am learning about redirection of file descriptors. Along the way I have come across a question surrounding the use of the redirect symbol, specifically when setting permanent redirection. I have noticed that in certain cases it does not seem to matter whether I use <code>&lt;</code> or <code>&gt;</code>. For example, working with the following script:</p>
  
  <pre><code>#!/bin/bash
  
  #Setting file descriptor 3 to redirect  to STDIN
  exec 3&lt;&amp;0
  
  #Setting STDIN to read from input file
  exec 0&lt;inputFile
  
  
  while read var
  do
      echo "$var"
  
  done
  
  #Setting STDIN to read from file descriptor 3 which is redirected to the default STDIN
  exec 0&lt;&amp;3
  
  read -p "Enter a word:" word
  
  echo "$word"
  </code></pre>
  
  <p>To my astonishment it does not seem to matter if I use <code>&gt;</code> or <code>&lt;</code> in the statements <code>exec 3&lt;&amp;0</code> or <code>exec 0&lt;&amp;3</code>. In either of these statements it seems that if I swap out the redirect symbols, I still get the exact same result. It seems obvious to me that making the same types of changes to the line:</p>
  
  <pre><code>exec 0&lt;inputFile
  </code></pre>
  
  <p>vs.</p>
  
  <pre><code>exec 0&gt;inputFile
  </code></pre>
  
  <p>does not produce the same results, because redirecting STDIN to a file is not the same thing as redirecting a file to STDIN.</p>
  
  <p>So my questions are:</p>
  
  <ol>
  <li><p><code>&lt;</code> vs <code>&gt;</code>:</p>
  
  <pre><code># Why aren't there any differences between these two statements?
  exec 3&lt;&amp;0
  exec 3&gt;&amp;0
  </code></pre></li>
  <li><p><code>3&lt;&amp;0</code> vs <code>0&lt;&amp;3</code>:</p>
  
  <pre><code># Why is there a difference between these two statements?
  exec 3&lt;&amp;0
  exec 0&lt;&amp;3
  </code></pre></li>
  </ol>
  
  <p>This type of redirection is hard enough for me to wrap my head around and keep straight without these types inconsistencies. Any explanation(s) will be greatly appreciated.</p>