title: How to exit from cygwin/bash environment called from a perl script?
body: <p>On windows XP, I have a bat file which calls a perl script, which itself shall contain a "make" command in a cygwin context. (I can't change this BAT -> PERL -> CYGWIN structure). This works a little bit but I don't find how to exit from the cygwin environment.</p>
  
  <p>For example, in my perl script, this line seems to work :</p>
  
  <pre><code>        print STDOUT "START PERL SCRIPT\n" ;
  system ("$ENV{CYGWIN_HOME}\\bin\\bash | $ENV{CYGWIN_HOME}\\bin\\make -version");
  print STDOUT "END OF PERL SCRIPT\n" ;
  </code></pre>
  
  <p>However, in my cmd.exe, this is my output:</p>
  
  <ul>
  <li>START PERL SCRIPT</li>
  <li>GNU Make 3.80 Copyright (C) 2002  Free Software
  Foundation, Inc.</li>
  <li>This is free software; see the source for copying
  conditions. There is NO warranty; not even for MERCHANTABILITY or
  FITNESS FOR A PARTICULAR PURPOSE.</li>
  <li>bash-3.2$</li>
  </ul>
  
  <p>My problem is that I stay in bash environment : the line "bash-3.2$" still waits for a command, and I cant' find a solution to exit automatically from it (the only way is to manually print "exit" in cmd.exe).
  My perl script is thus stopped instead of automatically continuing its jobs.</p>
  
  <p>I've not succeeded with solutions such as
  "<a href="https://stackoverflow.com/questions/18491962/using-perl-to-run-more-than-one-system-command-in-a-row">Using perl to run more than one system command in a row</a>"</p>
  
  <p>Do you know how to write the perl script and commands in order to get out of the bash environment and continue the perl script ?</p>
  
  <p>Thanks a lot,
  Calim</p>
  
  <hr>
  
  <h3>Update</h3>
  
  <p>So finally I have moved to another solution. It seems to work (i.e. I go back to my perl script after the shell command is executed) ; I just hope there will be no unexpected effect. Do you have any opinion about it ?</p>
  
  <pre><code>print STDOUT "START PERL SCRIPT\n";
  
  open ( CYGWIN , "|-" , "$ENV{CYGWIN_HOME}\\bin\\bash" ) ;
  print CYGWIN "$ENV{CYGWIN_HOME}\\bin\\make -w -C /cygdrive/c/tmp/Generation makefile" ;
  close CYGWIN ;
  
  print STDOUT "END OF PERL SCRIPT\n";
  </code></pre>