I know when Cygwin installs there is a batch file that is used to launch it in Windows. But if I want to run a script without launching Cygwin and doing "./script"
How do I create a batch file to do that?
As in... just have one batch file that when clicked, opens Cygwin and runs the shell script.
So you have to use simply /bin/ as path for bash. Do a simple check: into a CygWin terminal type the command ls /bin/bash.exe : it list the executable for bash. open a windows CMD and type the command dir C:\cygwin\bin\bash.exe : it list the executable for bash.
To run "foo.bsh", create a batch file with the following contents and run it:
set PATH=C:\cygwin\bin;%PATH%
c:\cygwin\bin\bash.exe c:\path\to\foo.bsh
The "C:\cygwin\bin" part can differ depending on your chosen install location of cygwin.
You might try something like this to trampoline from CMD to BASH (or whatever sh-variant):
: <<TRAMPOLINE
@echo off
bash -c "exit 0" || (echo.No bash found in PATH! & exit /b 1)
bash "%~f0" "%*"
goto :EOF
TRAMPOLINE
#####################
#!/bin/bash -- it's traditional!
echo "Hello from $SHELL"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With