Can I make bash in cygwin run a command immediately after invocation?

2

I need this for automated build configuration in Eclipse (long story). What I'm trying to figure out is the following. When invoking CMD from Run menu in Windows, one can do it as follows:

cmd /c CD "C:\Users\me\FolderWithExecutable" & executable.exe arg1 arg2

In other words, I can bring up the CMD window and execute a command in it, all from one line. Can I do the same thing with Cygwin? If I go to the Run menu (Windows+R), which is just a wrapper for a generalized Windows "run command" input, can I type in something like

C:\cygwin\bin\bash -SomeBashArgument cd "C:\Users\me\FolderWithBashScript" & script.sh arg1 arg2

or something similar, and make it do something analogous to what is done above with CMD?

Phonon

Posted 2011-10-11T20:39:11.697

Reputation: 123

Answers

1

Yes, something like

C:\cygwin\bin\bash -c "cd /cygdrive/c/Users/me/FolderWithBashScript" && script.sh arg1 arg2; read -p 'hit enter'"

If you need to have an interactive shell afterwards:

C:\cygwin\bin\bash -c "cd /cygdrive/c/Users/me/FolderWithBashScript" && script.sh arg1 arg2; bash --login -i"

glenn jackman

Posted 2011-10-11T20:39:11.697

Reputation: 18 546

I'm afraid it's not working. thanks what I tried initially as well, but as soon as I use the -c option, the window simply closes immediately. If I sun it from command prompt, it simply goes back to the system32 folder. – Phonon – 2011-10-11T21:11:08.610

@Phonon, updated answer. – glenn jackman – 2011-10-11T21:38:19.613