Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site hadron.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!houxm!whuxl!whuxlm!akgua!gatech!seismo!rlgvax!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.unix-wizards Subject: Re: Absolute vs. Relative paths: we use *one* absolute path here Message-ID: <164@hadron.UUCP> Date: Fri, 27-Dec-85 14:41:42 EST Article-I.D.: hadron.164 Posted: Fri Dec 27 14:41:42 1985 Date-Received: Mon, 6-Jan-86 03:42:44 EST References: <1016@sdcsla.UUCP> <1019@utcs.uucp> <1747@dciem.UUCP> <637@watmath.UUCP> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Organization: Hadron, Inc., Fairfax, VA Lines: 63 Keywords: PATH script shell searchpath Summary: OK, here's [a] searchpath(1). OK, not a bad idea: a program to generate your favourite searchpath for your favourite type of person. You say your syntax is: searchpath type=Xxxxxx ? Q&D: alias searchpath "grep \"`echo $1 | sed 's/type=//'`[ ^I]\" /etc/paths | line | sed \"s/^$1[ ^I]*//\"" I probably messed up some of the quoting, since I have not tried this. If you don't have the Korn shell (or C shell), or this doesn't work, or you want better checking: #! /bin/sh # # @(#)searchpath.sh 1.1 # PATH="/bin:/usr/bin"; export PATH # Defaults. Note no "." or user's bin -- in a system shell # script, that is n o t a good idea. defpath="/bin:/usr/bin:/usr/lbin:/usr/local/bin" deftype="user" # Where it is, man. pathfile="/etc/paths" # Input and local variables. type="$1" path="" # Get the type, unadorned with "type=", which violated # ANSI standard argument sequence anyway. ;-) if [ "" = "$type" ]; then type="$deftype" else # Note: case "") doesn't work in some states. ;-) case "$type" in type=*) type="`echo "$type" | sed 's/^type=//'`" ;; esac fi # Find that type of path in the paths file. path="`grep \"^$type[ ^I]\" $pathfile | line | sed \"s/^$type[ ^I]*//\"`" # "Dear me, I'm still not certain quite # that even now I've got it right." -- E. Lear # (Mild testing indicates this should work, tho.) # If no such type, complain and set to default. if [ "" = "$path" ]; then echo "$0: No such type in $pathfile as \"$type\"" >&2 path="$defpath" fi # Output the path name. echo "$path" exit 0 And of course /etc/paths contains something like: user /bin:/usr/bin:/usr/lbin:/usr/local/bin systems /etc:/bin:/usr/bin:/usr/lbin:/usr/local/bin acctg /usr/acctg/bin:/bin:/usr/bin:/usr/lbin:/usr/local/bin and so forth. -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}