title: What's the effective difference between redirecting to /dev/null and simply closing the stream
body: <p>Background:<br>
  I want to test some bash scripts in a modified environment with a restricted bash. In a restricted bash I am not allowed to redirect a stream to a file e.g. <code>2&gt;/dev/null</code><br>
  I found a workaround by simply closing the stream with e.g. <code>2&gt;&amp;-</code></p>
  
  <p>While trying here and there I found no effective difference between <code>2&gt;/dev/null</code> and <code>2&gt;&amp;-</code><br>
  The STDERR output is swallowed up and doesn't appear.</p>
  
  <pre><code>$ bash -c 'ls FOO'
  ls: cannot access FOO: No such file or directory
  $ bash -c 'ls FOO 2&gt;/dev/null'
  $ bash -rc 'ls FOO 2&gt;/dev/null'
  bash: /dev/null: restricted: cannot redirect output
  $ bash -rc 'ls FOO 2&gt;&amp;-'
  $ bash -rc 'ls FOO 2&gt;&amp;- ; ls BAR'
  ls: cannot access BAR: No such file or directory
  </code></pre>
  
  <p>I guess the processing inside bash is different but that's not important to me. What IS important to me, is can the general closing instead of redirecting to /dev/null cause any problems?</p>