views:

119

answers:

1

A quick couple of Cygwin questions that I am not quite sure how to search in order to find the answer myself:

Question: When I run

which perl

on my cygwin installation, it doesn't point to my pre-installed windows installation, it points to the cygwin one. How can i change it so it points to my windows based perl installation:

/cygdrive/c/perl/bin/perl

Question: When I look at the desktop shortcut that invokes cygwin, it points to bash:

c:\cygwin\bin\bash --login -i

I cannot find the documentation for the allowed commandline flags. Specifically, I would like to find a flag that allows me to pass in a pre-defined user command, so that when cygwin starts up, that command is automatically invoked without me having to type it in.

This is something that I would want to customize regularly, so it is not efficient to put it in .bash_profile or something like that. If possible, I'd like to be able to specify it from the command-line.

+2  A: 

The answer to your first point is to make sure that the native win32 perl appears before the cygwin one in your path.

The answer to the second part is -c which will execute a command supplied on the command line. The command flags are the same as standard bash, so man bash or any bash documentation will get you a list of them.

Just as an aside, if you're mixing and matching native win32 applications with cygwin, take a look at UnxUtils. It is based on msvcrt.dll rather than cygwin.dll so the programs will play nicely with standard windows paths (e.g. C:\foo\bar instead of needing a /cygdrive path like /cygdrive/c/foo/bar).

It's much less comprehensive than Cygwin, but is mature and stable and has a good cross-section of the basic unix commands (sed etc.) It will play nicely with windows command files (you can do piping and redirection) and there is a port of zsh with it so it will also run shell scripts, although zsh is not totally compatible with bash.

ConcernedOfTunbridgeWells
Excellent answer, thanks.
dreftymac