This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Executing bash commands from the bash command line

On Thursday 01 August 2002 16:35, Hamish Fawns wrote:
> Dear All,
>     I am trying to create a "Bash Here" utility that will allow me to open
> a Bash window in any directory by right clicking in the window and
> selecting "Bash Here" (similar to the "Command Prompt Here" Microsoft
> Powertoys utility). To do this I need to be able to cd to a given directory
> from the bash command line, for example:
> bash "cd /cygdrive/c/myfolder" where "myfolder is a variable.
>     How can I do this?

I think the trick here is to change to the directory BEFORE you run bash, eg 
instead of

bash "cd /cygdrive/c/myfolder"

do something like

cd /cygdrive/c/myfolder ; bash

Or if you're not actually doing this in the context of a bash command line to 
begin with, then perhaps something like

bash -c "cd /cygdrive/c/myfolder ; exec bash"

or if you're actually launching it from Win32 code (eg if you're writing some 
kind of wacky DLL to plug into Explorer) then why not just supply the desired 
directory as a the lpCurrentDirectory argument to CreateProcess()? I think 
this is by far the simplest and most robust way of dealing with this issue.

>     Thanks,
>         Hamish


Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]