home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
magazine
/
drdobbs
/
1991
/
01
/
c_shell.asc
< prev
next >
Wrap
Text File
|
1990-12-07
|
1KB
|
56 lines
_EXAMINING THE HAMILTON C SHELL_
by Scott Richman
[LISTING ONE]
# CTL_T.CSH
while (1) # endless
echo -n ^x14 > com1: # send control t to com1:
sleep 400 # Zzz for 400 seconds
end # while
[LISTING TWO]
# Procedure zcw builds Zortech C++ and creates a PM program,
proc zcw(name) # param name
ztc -W -c $name.cpp # compile ($name is param name)
# we test name.obj for eistance,
if (-e $name.obj ) then # got valid obj file to link
link $name,/align:16,NUL,os2+d:\oz\cp\srzpm.lib,$name
rm $name.obj # remove the obj
end # if
end # proc
zcw $argv # now here's the invocation of my proc defined above.
[LISTING THREE]
proc ged(edt_str,files) # 2 params
local i #local variables used
local n
foreach i ($files) # loop thru the files
@ n = concat($i:r,".bak") # save a backup (:r is root name)
cp -l $i:f $n:f # copy it (:f is full name)
sed "$edt_str" < $n:f > $i:f # edit from new to i
end # foreach i
end # end ged proc()
[EXAMPLE 1: Commands to print the attributes of a specified file.]
if ( -d $a) echo $a is a directory
if ( -H $a) echo $a is Hidden
if ( -R $a) echo $a is ReadOnly
if ( -S $a) echo $a is SystemFile
if ( -e $a) echo $a exists
if ( -x $a) echo $a Is Executable
if ( -z $a) echo $a Zero Length
[EXAMPLE 2: Command to find all duplicate file names on the
current disk]
foreach i (`ls -r \`:gt) echo $i; end | sort | uniq -d