title: pgrep prints a different pid than expected
body: <p>I wrote a small script and for some reason I need to escape any spaces passed in parameters to get it to work.  </p>
  
  <p>I read numerous other articles about people with this issue and it is typically due to not quoting $@, but all of my variables are quoted within the script and the parameters quoted on the command line as well.  Also, if I run the script in debug mode the line that is returned can be run successfully via copy paste but fails when executed from within the script.</p>
  
  <p>CODE:</p>
  
  <pre><code>connections ()
  {
      args="$@"
      pid="$(pgrep -nf "$args")"
      echo $pid
      # code that shows TCP and UDP connections for $pid
  }
  connections "$@"
  </code></pre>
  
  <p>EXAMPLE:</p>
  
  <p><code>bash test.sh "blah blah"</code></p>
  
  <p>fails and instead returns the pid of the currently running shell</p>
  
  <p><code>bash test.sh "blah\ blah"</code></p>
  
  <p>succeeds and returns the pid of the process you are searching for via pgrep</p>