Converting Bourne or Korn shell scripts to Hamilton C shell scripts
Copyright (c) 1992 to 2001 by Hamilton Laboratories. All rights reserved.
> Use TABS = 3 to view this file and any of the sed scripts <
To translate an sh script to csh, run it thru the following pipeline:
sed -f expr.sed | sed -f if.sed | sed -f proc.sed | sed -f case.sed |
sed -f loop.sed | sed -f misc.sed | sed -f expr2.sed | sed -f quotes.sed
(or just use the sh_2_csh.csh script).
Each stage is using sed to fixup a specific type of language difference
between sh and csh. Order is important and the stages must be connected
thru pipes rather than simply concatenating the scripts. But any individual
stage can be run independently for testing or just to see what it does.
These sed scripts were tested with Hamilton sed and may not work perfectly
on a standard Unix sed. (Hamilton sed has a number of minor enhancements,
e.g., to allow it to process scripts with relaxed spacing rules, etc.)
The result will (hopefully) be fairly good if the input is in clear,
well-formatted style, but with these limitations:
1. The output will depend on the C shell being run with the escape symbol
set as follows:
set escapesym = \ # Use the Unix-style \, not the OS/2 or NT
# default ^, as the escape symbol.
2. break statements will have to be manually rewritten, since sh
interprets break to mean break out of loops only, not case
statements. Also, break n means break out of n levels, even
breaking out of loops entered in calling procedures. The sed
scripts will turn break into FixBreak in the output.
3. There's no egrep or awk in the Hamilton C shell package, but grep,
fgrep and sed are provided.
4. Under the C shell, variables are either shell variable or
environment variables from the moment they're created.
5. The scripts do a pretty good job editing most things, but some
things just don't go thru very well and will require hand tuning.
E.g., backquoted expr expressions with embedded escaped quotes
are garbled and escaped newlines may cause trouble.
To really see how the changes have worked out, diff the input and output
with Hamilton diff, using the -! option to generate a merged listing using
color to highlight the changes in context. Use Hamilton more with the -i
(interactive) option to browse the output and search forward and backward
for changes, which will be marked by the ANSI escape sequences containing
"[1;".
diff -! foo.sh foo.csh | more -i
All Hamilton utilities have online help available with the -h option. In
addition, Hamilton more has a builtin help screen available during normal
operation when you press H.
Regards,
Nicole Ashley Hamilton
Hamilton Laboratories
61 Fairbank Road
Sudbury, MA 01776-1620
U.S.A.
Phone 978-440-8307
FAX 978-440-8308
Internet hamilton@hamiltonlabs.com
Web Site http://www.hamiltonlabs.com
Hamilton C shell |
Free Updates |
Free Demo Software |
Win32 Training
Y2K |
Customer Testimonials |
On-line Hamilton C shell User Guide
Home |
Email |
Support |
Company Profile |
Distributors |
Links
Copyright © 1997-2001 by Hamilton Laboratories.
All rights reserved.
You are visitor number
.
This page was last modified August 26, 2001.