title: Got exit code 123 in find + xargs grep
body: <p>Here is my script</p>
  
  <pre><code>eval "find \\( -type f -a \\( -name '*.h' \\) \\) -print0" | xargs -0 -n100 grep  -f &lt;(echo "stdio")
  echo $?
  </code></pre>
  
  <p>Nothing is found and the exit code is 123.</p>
  
  <p>If I modify it a little as follows</p>
  
  <pre><code>echo "stdio" &gt;.P
  eval "find \\( -type f -a \\( -name '*.h' \\) \\) -print0" | xargs -0 -n100 grep &lt;.P
  echo $?
  </code></pre>
  
  <p>Something is found but the exit code is still 123.</p>
  
  <p>So what is wrong?</p>
  
  <p>======================================================================</p>
  
  <p>Actually I just want to write a small script to make find+xargs+grep easier. For exmaple,<BR> 
  xgrep -e PATTERN1 -e PATTERN2 ... *.c *.h<BR>
  is to execute<BR>
  find -name *.c -o -name *.h|xargs grep -f &lt;(echo "$PATTEN1<BR>
  $PATTERN2")<BR><BR>
  Use -f option instead of -e is to avoid troubles in escaping single or double quations within the patterns.</p>
  
  <pre><code>#!/bin/bash
  #set -e -o pipefail
  
  eval ARGV=($(getopt -l '' -o 'e:li' -- "$@")) || exit 1
  for((i=0;i&lt;${#ARGV[@]};i++)) {
      o="${ARGV[$i]}"
      case $o in
      -e)
          i=$((i+1));
          a="${ARGV[$i]}"
          if [ -n "$grep_patterns" ]; then
              grep_patterns="$grep_patterns"$'\n'
          fi
          grep_patterns="$grep_patterns$a"
          ;;
      -i)
          grep_options="$grep_options -i"
          ;;
      -l)
          grep_options="$grep_options -l"
          ;;
      --)
          i=$((i+1));
          break;;
      esac
  }
  
  for((;i&lt;${#ARGV[@]};i++)) {
      if [ -n "$find_options" ]; then
          find_options="$find_options -o "
      fi
      find_options="${find_options}-name '${ARGV[$i]}'"
  }
  
  cmd="find \\( -type f -a \\( $find_options \\) \\) -print0"
  eval "$cmd" | xargs -0 grep $grep_options -f &lt;(echo "$grep_patterns")
  </code></pre>