ignatz (06/24/82)
# # traverse - prints all readable and printable files in a directory # # Invocation: traverse[[ directory]["command"]] # # Author: David M. Ihnat Copyright 1981 # # This program is available for public use, provided that this disclaimer is # retained intact, and that it is neither sold, nor used directly for profit. # The author, while willing to discuss problems or requests, and to, # at his discretion, accept, provide, and/or distribute enhancements and/or # corrections to the program, assumes no liablility or responsiblity for # this program or any effect or effects resulting from its use. # In addition, the author assumes no responsibility or obligation # to maintain, enhance, or correct the program as distributed. # # Caveat Utilitor # export BASE COMMAND INVOKED; if [ $# -ge 1 ] then WKDIR=`pwd`; cd $1; shift; else WKDIR=''; fi; if [ ! "$BASE" ] then BASE="entered"; INVOKED="$0"; if [ $# -gt 0 ] then COMMAND="$*"; else COMMAND="pr -l62 -fn"; fi; fi; FILES=`ls`; HFILES=""; CFILES=""; SFILES=""; RESTFILES=""; DIRECTORIES=""; WARN=''; for file in $FILES do SCCS=""; case $file in s.* ) SCCS="sccs! ";; esac; case $file in *.hx | *.o | *.fs) WARN="$WARN \n\n\t***** nonprintable file $SCCS$file \t*****";; *.h ) HFILES="$HFILES $SCCS$file";; *.c ) CFILES="$CFILES $SCCS$file";; *.s ) SFILES="$SFILES $SCCS$file";; * ) TYPE=`file $file`; set $TYPE; shift; case $1 in ascii | English | fortran | *roff, ) RESTFILES="$RESTFILES $SCCS$file";; ascii ) if [ "$2" = text ] then RESTFILES="$RESTFILES $SCCS$file"; fi;; assembler ) SFILES="$SFILES $SCCS$file";; c ) CFILES="$CFILES $SCCS$file";; commands) RESTFILES="$RESTFILES $SCCS$file";; directory) DIRECTORIES="$DIRECTORIES $SCCS$file";; *) WARN="$WARN \\n ** nonprintable file $SCCS$file: $* **";; esac; esac; done; # # Now process the files. Print files in .h,.c,.s, & 'rest' order; then warnings; # then traverse directories, after printing the list. # if [ "$BASE" = entered ] then echo "\f\n\t\t\t***** Traversal of directory `pwd` *****"; BASE="processing"; else echo "\f\n\t\t\t***** Directory `pwd` *****"; fi; if [ "$HFILES" ] then echo "\n\n Header files: \c"; PRcount=0; PRtab=''; PRlist=''; for file in $HFILES do if [ "$file" = 'sccs!' ] then continue; fi; PRlist="$PRlist $file"; PRcount=`expr $PRcount + 1`; if [ $PRcount -ge 8 ] then echo "$PRtab$PRlist"; PRcount=0; PRlist=""; PRtab="\t\t"; fi; done; if [ "$PRlist" ] then echo "$PRtab$PRlist"; fi; SCCSflag=''; for file in $HFILES do if [ "$file" = 'sccs! ' ] then SCCSflag='y'; else echo "\n\nFile $file\n"; if [ ! "$SCCSflag" ] then $COMMAND $file; else get -sp $file | $COMMAND; SCCSflag=''; fi; fi; done; fi; if [ "$CFILES" ] then echo "\n\n 'C' files: \c"; PRcount=0; PRtab=''; PRlist=''; for file in $CFILES do if [ "$file" = 'sccs!' ] then continue; fi; PRlist="$PRlist $file"; PRcount=`expr $PRcount + 1`; if [ $PRcount -ge 8 ] then echo "$PRtab$PRlist"; PRcount=0; PRlist=""; PRtab="\t\t"; fi; done; if [ "$PRlist" ] then echo "$PRtab$PRlist"; fi; SCCSflag=''; for file in $CFILES do if [ "$file" = 'sccs! ' ] then SCCSflag='y'; else echo "\n\nFile $file\n"; if [ ! "$SCCSflag" ] then $COMMAND $file; else get -sp $file | $COMMAND; SCCSflag=''; fi; fi; done; fi; if [ "$SFILES" ] then echo "\n\n Assembler Files: \c"; PRcount=0; PRtab=''; PRlist=''; for file in $SFILES do if [ "$file" = 'sccs!' ] then continue; fi; PRlist="$PRlist $file"; PRcount=`expr $PRcount + 1`; if [ $PRcount -ge 8 ] then echo "$PRtab$PRlist"; PRcount=0; PRlist=""; PRtab="\t\t"; fi; done; if [ "$PRlist" ] then echo "$PRtab$PRlist"; fi; SCCSflag=''; for file in $SFILES do if [ "$file" = 'sccs! ' ] then SCCSflag='y'; else echo "\n\nFile $file\n"; if [ ! "$SCCSflag" ] then $COMMAND $file; else get -sp $file | $COMMAND; SCCSflag=''; fi; fi; done; fi; if [ "$RESTFILES" ] then echo "\n\n Unidentified Files: \c"; PRcount=0; PRtab=''; PRlist=''; for file in $RESTFILES do if [ "$file" = 'sccs!' ] then continue; fi; PRlist="$PRlist $file"; PRcount=`expr $PRcount + 1`; if [ $PRcount -ge 8 ] then echo "$PRtab$PRlist"; PRcount=0; PRlist=""; PRtab="\t\t"; fi; done; if [ "$PRlist" ] then echo "$PRtab$PRlist"; fi; SCCSflag=''; for file in $RESTFILES do if [ "$file" = 'sccs! ' ] then SCCSflag='y'; else echo "\n\nFile $file\n"; if [ ! "$SCCSflag" ] then $COMMAND $file; else get -sp $file | $COMMAND; SCCSflag=''; fi; fi; done; fi; if [ "$WARN" ] then echo "\f$WARN"; fi; if [ "$DIRECTORIES" ] then for dir in $DIRECTORIES do $INVOKED `pwd`/$dir; done; fi; if [ "$WKDIR" ] then cd $WKDIR; fi; # # End of shellscript