title: How to execute a bat file from cygwin bash that uses the Windows find command
body: <p>The <code>find</code> command does completely different in Windows and Unix. On Windows it is a <code>fgrep</code>-like utility listing matching lines in a file; on Unix -- and on Cygwin -- it list filenames matching some criteria. </p>
  
  <p>Cygwin bash <em>prepends</em> its standard directories to the current path, so inside bash <code>$PATH</code> is typically <code>/bin:/usr/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS</code>. </p>
  
  <p><em>Begin Update to provide additional details</em></p>
  
  <p>For example I have many scripts that use the gnu <code>find</code> command -- for example scripts to purge directory trees that contain no files:</p>
  
  <pre><code>purge-empty-dirs.sh
  find . -depth -type d -empty | xargs rmdir -p
  </code></pre>
  
  <p>I also have a bat file to start my build, which uses the windows find command, which searches for lines matching a string (similar to gnu <code>grep</code>). </p>
  
  <pre><code>build.bat
  ...
  dir | find "target"
  if errorlevel = 1 goto no_target_dir
  ...
  </code></pre>
  
  <p>Now, for my bash script to work I need <code>/bin</code> to be in path before <code>c:\windows\system32</code>. But for my bat file to run I need <code>c:\windows\system32</code> to be in path before <code>/bin</code> </p>
  
  <p>In general we might be able to claim that <strong>all bat files should be executed with the original environment inherited by bash, not the modified one</strong>. Does that make sense?</p>
  
  <p><em>End Update</em></p>
  
  <p>This how it should be, but breaks the bat files executed from bash. What is the best way to address this? </p>
  
  <p>Is there a way to force Cygwin to execute bat files (or even <em>all</em> Windows executables) with the environment it started with? I am thinking of <code>start /i</code> behavior of cmd.exe. I am thinking of writing my own <code>cygstart</code> like utility that does this, by saving the environment (or at least <code>$PATH</code>) in <code>.bash_profile</code>/<code>.bashrc</code>. Does that make sense?    </p>
  
  <p>Any other suggestions? </p>
  
  <p>Edit: See also <a href="https://stackoverflow.com/questions/8261156/start-new-cmd-exe-and-not-inherit-environment/8282423#8282423">Start new cmd.exe and NOT inherit environment</a></p>