#!/bin/ksh # can be ksh or bash (or sh if on Linux) # Edit this path as necessary: FPFD=/usr/appl/filepro # set to false to speed up interactive mode a little # don't use interactive mode at all for fastest operation DEBUG=true # Brian K. White - linut@squonk.net # # v 1.0 initial # v 1.1 bugfix: stop reporting lookups that only mentioned the target in # a comment but did not actually lookup to the target. # bugfix: stop using unsafe variable names like $i and $p # bugfix: handle multiple lookups to the target file from the same prc # table. # compatibility: uses terminfo for "clear to end-of-line" in # interactive mode now. # features: can now specify less than all prc tables in all other # filepro files to be searched for lookups to . # features: help/usage option -h or --help # ############################################################################## case $1 in -h|--help|"-?") cat < [ [ ] ] ] = (defaults to ask interactively) filePro file name to search other files for lookups to. = (defaults to *) filePro file name or quoted, space-seperated list of filePro file names to search in for lookups to = (defaults to *) name, or quoted, space-seperated list of names of prc files from within to search in for lookups to cannot at this time use options out of order or skip beginning options except by using "" as a place-holder for an option you wish to leave empty. you can leave options off the end without using "" ENDUSAGE exit 0 ;; esac unset FPFL FPFN PRCL PRC PCL LKP TGT EL [ -n "$BASH" ] && ECHO="echo -e" || ECHO="echo" [ -z "$1" -o ! -d $FPFD/$1 ] && { $ECHO "Scans all prc tables in all filePro files for lookups to a given file." $ECHO "( use to find out what will be affected by changes you wish to make )" $ECHO "Target file?: \c" ;read TGT ; [ -z "$TGT" ! -d $FPFD/$TGT ] && exit 1 [ -z "$2" ] && $ECHO "Source file?: \c" ;read SRC [ -z "$3" ] && $ECHO "Prc file? : \c" ;read PRC $ECHO "" $ECHO "FILE\tPRC\tLINE:LOOKUP" $ECHO "-----------------------------------------------------------------------" sc[0]="|" ;sc[1]="/" ;sc[2]="-" ;sc[3]="\\ " ;s=0 spinner () { s=$((s+1)) ;[ $s -gt 3 ] && s=0 ;$ECHO "${sc[s]}\r\c" ; } EL=`tput el ` } || { TGT=$1 ; spinner () { : ; } ; DEBUG=false ; } cd $FPFD [ -z "$SRC" ] && FPFL=* || FPFL=$2 for FPFN in $FPFL ;do cd $FPFD/$FPFN unset PRCL [ -z "$PRC" ] && PRCL=prc.* || for PLC in $PRC ; do PRCL="$PRCL prc.$PLC" ;done ls $PRCL >/dev/null 2>&1 && { for PRCN in $PRCL ; do LKP=`grep -in lookup $PRCN |cut -d: -f1,4 |grep $TGT ` [ "foo$LKP" = "foo" ] || { $ECHO "$LKP" |awk -vF=$FPFN -vP=$PRCN -vB=$EL '{ sub ("prc.","",P) print B"\r"F"\t"P"\t"$0 }' } $DEBUG && echo " searching: $FPFN/$PRCN$EL\r\c" spinner done ; } done $DEBUG && $ECHO $EL