title: Parsing function param in bash and pass it to new function
body: <p>I'm trying to build a bash function that takes two arguments, and executes the first in a docker container, then greps the second argument in the output..but I can't get it to work.</p>
  
  <p>This is what I've come up so far:</p>
  
  <pre><code>function scriptCheckData() {
      local cmd=eval "$1"
  
      local RESULT=$(docker exec -i "$dockerName" cmd)
  
      if ! echo "$RESULT" | grep "$2"; then
          echo grep failed for "$2" in: "$RESULT"
          cleanupAndExit
      fi
  }
  </code></pre>
  
  <p>Function call:</p>
  
  <pre><code>scriptCheckData 'test.php --option 1' 'expected string'
  </code></pre>
  
  <p>Any help appreciated!</p>
  
  <p>EDIT:</p>
  
  <p>Solution was to not put my var in quotes, like this:</p>
  
  <pre><code>function scriptCheckData() {
      local RESULT=$(docker exec -i "$dockerName" $1)
  
      if ! echo "$RESULT" | grep "$2"; then
          echo "grep failed for [$2] in: [$RESULT]"
          cleanupAndExit
      fi
  }
  </code></pre>