#!/usr/local/bin/bash # swd -- # (c) Bardo,Bueno,Nemo (CLIP) # SCCS Status : @(#)swd 1.5 7/29/94 # Author : Francisco Jose Ballesteros Camara # Created On : Thu Nov 12 21:41:16 1992 # Last Modified By: Daniel Cabeza Gras # Last Modified On: Mon Feb 15 17:16:44 1993 # Update Count : 119 # Status : Quite checked. # # PURPOSE # Keep cold users with paths. # Database file export DBFILE=~/lib/swd.db export PATH=/usr/bin:/bin:/usr/ucb:/usr/etc:/etc export PRG_NAME=${0##*/} export USAGE_MSG=\ "usage: $PRG_NAME"' [-h] [-c] [-bilms [category(s)]] [-d type category]' # # Command line processing # export PNT=0 getopts bilmsdch c case $c in b) export TRG=bin if [ $# = 1 ] ; then export PNT=1 # Add a "." to the end of the whole path fi ;; i) export TRG=include ;; l) export TRG=lib ;; m) export TRG=man ;; s) export TRG=src ;; d) if [ $# -gt 2 ] ; then # Minimum 3 args shift ; export TRG="$1" fi ;; c) grep -v '^#' "$DBFILE" | cut -f1 | sort -u | grep -v '^$' exit ;; h) echo "${PRG_NAME}: show wich directory(s)" echo "$USAGE_MSG" cat <&2 exit 1 fi if [ $# = 1 ] ; then export CATEGS="X system ..." else shift ; export CATEGS="$*" fi # # Tests # if [ ! -r "$DBFILE" ] ; then echo "$PRG_NAME": cannot open "$DBFILE" >&2 exit 1 fi # # Do the work. We will no longer print error messages nor mail user # for categories not present. # awk ' BEGIN { n = split("'"$CATEGS"'", ctg) for (c in ctg) { if (ctg[c] == "left") ctg[c] = "..." if (ctg[c] == "...") { dots = c; break } } } !/^#/ && $2 == "'"$TRG"'" { for (c in ctg) if ($1 == ctg[c]) { P[ctg[c]" "(++L[c])] = $3 next } if (dots) P["... "(++L[dots])] = $3 } END { outstr=":" for (c=1; c<=n ; c++) for (i=1; i<=L[c]; i++) { qnewstr=":" P[ctg[c]" "i] ":" if (!index(outstr,qnewstr)) outstr = outstr substr(qnewstr, 2) } if ('"$PNT"') print substr(outstr, 2) "." else print substr(outstr, 2, length(outstr)-2) }' "$DBFILE"