#! /bin/csh -f # # Filename: cformat # # Programmer: Br. David Carlson # # Date: January 22, 1994 # # Description: C shell script to format the c program given as a # command line parameter. Saves a backup of the original file. # # Example of usage: cformat test.c # if ($#argv != 1) then echo "ERROR -- usage is: cformat filename.c" exit(1) else if ("$argv[1]:e" != "c") then echo "ERROR -- filename must have an extension of c" exit(1) else if (! -f "$argv[1]") then echo "ERROR -- File $argv[1] cannot be found" exit(1) else if (! -w "$argv[1]") then echo "ERROR -- must have write access to file $argv[1]" exit(1) else cp "$argv[1]" "$argv[1]:r.$$" cb "$argv[1]" | tabclear > "$argv[1]:r.t$$" rm "$argv[1]" mv "$argv[1]:r.t$$" "$argv[1]" endif