Moving from Hamilton C-shell to Cygwin T-shell
The Cygwin T-shell (tsch) interface, which replaced the Hamilton C-shell interface as of Version 7.0, was introduced to enable 64-bit and Windows support. This document is a guide on how to convert existing Hamilton C-shell scripts into valid Cygwin T-shell scripts.
- Indices
- Escape characters
- =~ and !~ operators
- End vs. Endif
- File extensions
In order to execute existing C-shell scripts in a T-shell environment, you will need to either;
- use the
csh
command, for example%> csh create.csh.
- alter the first line of the script to include a reference to the path of the C-shell executable (
#!/bin/csh
). To invoke the script, enter the file name, for example%> create.csh.
Note: Do not use the Notepad or Wordpad text editors when creating or editing scripts. These editors introduce line terminating control characters that result in interpreting errors when using the T-shell. We instead recommend using gVim or a freeware editor like Context.
Indices
Hamilton handles the indexing of “list variables” differently depending on whether the script contains the standard #!/bin/csh
header line.
If the Hamilton script contains a header line, then the indexing will not need to be changed to work with Cygwin T-Shell. If, however, the Hamilton script does not contain a header line, then you will have to convert the indices.
For example: In a Hamilton shell script without the header, $ARGV[0]
was the first argument to the script. In T-Shell the first argument to the script is $ARGV[1].
Escape characters
In a Hamilton shell script, a caret (^) is used to represent the escape character. In a Cygwin shell scrip, a backslash (\) is used instead.
Hamilton: c:/>echo ^$ $ Cygwin: c:/>echo \$ $
=~ and !~ operators
If a Hamilton script contains a =~
or a !~
operator, then the right side of the if
statement will be processed as a wildcard expression regardless of whether or not it is quoted. In a Cygwin script, the shell will not process the wildcard expression if it is quoted.
if (1 =~ “*”) then echo "Valid Match" endif
In Hamilton, the if
statement will output the “Valid Match"
string. In Cygwin, it won’t evaluate as a match unless you remove the quotes around the asterisk.
End vs. Endif
Within Hamilton scripts, an if
statement is concluded with the end
keyword. In Cygwin, the endif
keyword is required.
File extensions
In a Hamilton shell, a script could be run without referencing its file extension. Cygwin T-Shell does not have this bonus feature. Therefore, if running a script, whether from a shell or from another script, the file extension must be explicitly included.