title: How can I evaluate the filename passed to a bash script via stdin
body: <p>I would like to evaluate a filename passed to a script via stdin and then use this in a sed command. At the moment I have the following code:</p>
  
  <pre><code>#!/bin/bash
  
  eval file="${1:-/dev/stdin}"
  echo "$file"
  sed -i -r ':a; s%(.*)/\*.*\*/%\1%; ta; /\/\*/ !b; N; ba' "$file"
  </code></pre>
  
  <p>Calling this as:</p>
  
  <pre><code>bash callfile &lt; file.txt
  </code></pre>
  
  <p>results in the following error:</p>
  
  <pre><code>/dev/stdin
  sed: couldn't open temporary file /dev/sedSVVTdr: Permission denied
  </code></pre>
  
  <p>Why is this code unable to read the filename I pass to it?</p>