Hamilton LaboratoriesHamilton C shell 2012User guide

Using with Cygwin

Oregon Coast

Using with Cygwin
Previous | Next

Topics

Does it work?
Login.csh
Startup.csh
See also

Does it work?

Of course it does. Cygwin includes a lot of helpful GNU utilities that nicely complement the set provided with Hamilton C shell, so of course you should be able to use them with the C shell and of course you can. You can even run bash scripts from the C shell if they start with #!/bin/bash.

To use the Cygwin tools with Hamilton C shell only requires that the Cygwin bin directory be listed on the search path and that the GNU utilities know to expect Windows-format filenames with drive letters and backslashes. In addition, since some GNU utilities have the same names as the Hamilton versions the C shell would normally run, it's helpful to have a way specify GNU version if that's what you want. The easy way to do this via the C shell's login.csh and startup.csh scripts.

Login.csh

Here's a sample login.csh file you might add to your home directory. It inherits anything that might normally be set up in the default login.csh script by source'ing it, then adds the Cygwin bin directory to the path variable and sets an environment variable to tell the GNU utilies to expect Windows filenames.

# Source the default login.csh source $shell:h:h\login.csh # Add Cygwin to the search path set path = $path C:\Cygwin64\bin # Tell the GNU utilities not to complain about Windows filenames # with drive letters and backslashes setenv CYGWIN = nodosfilewarning

The 32-bit version of Cygwin is normally installed at C:\Cygwin. The 64-bit version is normally installed at C:\Cygwin64. Here I've assumed the 64-bit version and that it's been installed in the usual location. Setting the CYGWIN environment variable to nodosfilewarning tells the GNU utilities to expect Windows filenames.

Startup.csh

Some of the GNU utilities, like ls and grep and others provide similar functions as the Hamilton versions of the same name, but sometimes a little differently. Whichever version comes first in the search path is the one that will be run. If you've added Cygwin to the path as suggested above, you'll get the Hamilton version. That might not always be what you want.

Here's a sample startup.csh file you might add to your home directory. It inherits from the from the default startup.csh script, then defines an alias to let you specify you want the GNU version of something. Again, note that I'm assuming the 64-bit version of Cygwin, installed in the usual place.

# Source the default startup.csh source $shell:h:h\startup.csh # Alias to run the GNU utilities that come with Cygwin alias gnu c:\Cygwin64\bin\^!^*

To run the GNU version of something, simply prepend gnu onto the front of the command, e.g., gnu ls to run the GNU version of ls.

See also

Order of evaluation: Search order
path variable
Login.csh
Startup.csh
Aliases
source statement
Tutorial: source statement
Tutorial: Environment variables
Tutorial: Aliases

Previous | Next

Running Cygwin utilities from Hamilton C shell

This screenshot shows the Cygwin bash, tcsh and ls utilities and even a bash script being invoked from Hamilton C shell. It all works just fine.