title: Does /dev/stdin have input?
body: <p>In Bash, I would like to use /dev/stdin.  As with many commands, stdin is optional though.  So, how would I know if I had stdin to read?  If there is no standard input, a command like <code>cat /dev/stdin</code> hangs waiting for input.</p>
  
  <p>Here is my first attempt:</p>
  
  <pre><code>#Always says "no stdin"
  if test -s /dev/stdin
  then 
    echo stdin
  else
    echo no stdin
  fi
  </code></pre>
  
  <p>man test => -s FILE exists and has a size greater than zero</p>
  
  <p>I guess the device file does not keep up with the available bytes.  It would be nice to do this in bash, <code>ssh</code> implements this functionality (in another language no doubt).</p>