title: Use CMake execute_process in Msys environment
body: <p>I'm trying to execute a script from <code>CMake</code> after building a library, in the <code>msysgit</code> environment, in order to update the <code>PATH</code>.  </p>
  
  <p>The lines of code in question:</p>
  
  <pre><code>set(SCRIPT_DIR "${CMAKE_SOURCE_DIR}/script")
  if(MINGW)
    set(COMMAND "source ${SCRIPT_DIR}/mingwpath")
  else()
    # Other script. In this case, CMake won't enter here.
  endif()
  
  set(PATH_DIRS ${CMAKE_BINARY_DIR})
  
  execute_process(COMMAND ${COMMAND} ${PATH_DIRS}
                  RESULT_VARIABLE r
                  OUTPUT_VARIABLE o
                  ERROR_VARIABLE e
  )
  
  message(STATUS ${COMMAND})
  message(STATUS ${PATH_DIRS})
  message(STATUS "RESULT: ${r}")
  message(STATUS "OUTPUT: ${o}")
  message(STATUS "ERROR: ${e}")
  </code></pre>
  
  <p>and the script:</p>
  
  <pre><code>#!/bin/bash
  
  export PATH=$1:$PATH
  </code></pre>
  
  <p>yet I always end with this result:</p>
  
  <pre><code>source D:/test/src/script/mingwpath
  D:/test/build/
  
  RESULT: System can't find the specified file.
  OUTPUT: 
  ERROR: 
  </code></pre>
  
  <p>The thing is that if I type that exact command in the terminal, it works.</p>
  
  <p>If instead of running the script, I try to run <code>ls</code>:</p>
  
  <pre><code>execute_process(COMMAND ls
                RESULT_VARIABLE r
                OUTPUT_VARIABLE o
                ERROR_VARIABLE e
  )
  </code></pre>
  
  <p>I get the same output message as before.</p>
  
  <p>I also removed the <code>source</code> in the command call, and ended up with this <code>result</code> message:</p>
  
  <pre><code>%1 is not a valid Win32 application
  </code></pre>
  
  <p>Executing directly the script from the terminal works.</p>