title: passing arguments to a node script coming from stdin
body: <h2>overview</h2>
  
  <p>I'd like to pass arguments to a node script coming from stdin.</p>
  
  <p>generally, I'm shooting for something like this</p>
  
  <pre><code>nodeScript.js | node {{--attach-args??}} --verbose --dry-run
  </code></pre>
  
  <p>that would act the same as</p>
  
  <pre><code>node nodeScript.js --verbose --dry-run
  </code></pre>
  
  <h3>more detail</h3>
  
  <p>here's a boiled down script <em>for illustration</em>, <code>dumpargs.js</code></p>
  
  <pre><code>console.log("the arguments you passed in were");
  console.log(process.argv);
  console.log("");
  </code></pre>
  
  <p>so you could then:</p>
  
  <pre><code>node dumpargs.js --verbose --dry-run file.txt
  [ 'node',
    '/home/bill-murray/Documents/dumpargs.js',
    '--verbose',
    '--dry-run',
    'file.js' ]
  </code></pre>
  
  <p>now the question, if that script comes in across stdin (say, via <code>cat</code> or <code>curl</code>)</p>
  
  <pre><code>cat dumpars.js | node
  the arguments you passed in were
  [ 'node' ]
  </code></pre>
  
  <p>is there a good way to pass arguments to it?</p>
  
  <blockquote>
    <p><strong>not node</strong>: with bash, using <code>dumpargs.sh</code> this time</p>
  
  <pre><code>echo "the arguments you passed in were"
  printf "&gt; $@"
  echo 
  </code></pre>
    
    <p>the answer would look like </p>
  
  <pre><code>cat dumpargs.sh | bash -s - "--verbose --dry-run file.txt"
  the arguments you passed in were
  &gt;  --verbose --dry-run file.txt
  </code></pre>
  </blockquote>