Remove Cygwin Path for Called Batch Script

Brian Dessent brian@dessent.net
Tue Mar 25 18:17:00 GMT 2008


Scott Wegner wrote:

> My question is, whether there is a way to easily strip the Cygwin
> entries from the path for the batch call.  Hopefully the solution would
> be portable, and not affect the environment outside of the bash script.

PATH is just a regular variable like any other.  If you want to remove
something from it, use whatever text processing tool you like.  The
shell lets you set environment variables only for the command being
executed using the syntax "var=value command arg ...", so:

PATH=$(perl -e 'print join(":", grep(!m@^/(usr/)?bin@, 
       split(":", $ENV{PATH})))') cmd.exe /k batch-script.bat params

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list