Date: Tue, 05 Aug 1997 11:37:03 -0600 From: Warner Losh <imp@rover.village.org> To: VaX#n8 <vax@linkdead.paranoia.com> Cc: netbsd-users@netbsd.org, freebsd-current@freebsd.org, misc@openbsd.org, mail2news@news.news.demon.net Subject: Re: configuration file tricks of the masters Message-ID: <E0wvnXb-000326-00@rover.village.org> In-Reply-To: Your message of "Sun, 03 Aug 1997 00:28:08 CDT." <199708030528.AAA24396@linkdead.paranoia.com> References: <199708030528.AAA24396@linkdead.paranoia.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <199708030528.AAA24396@linkdead.paranoia.com> VaX#n8 writes: : I am interested in: : o clever hacks : o generating multiple customized copies from one master : o mixing automatically-generated and user-generated data : o portable shell coding techniques : : Comments and submissions welcome. I'm not sure if this is the right forum to reply, but here are a couple of the ones that I use. I have a list of dirs that I want for my path. I don't want all of them in my path for a variety of reasons. So I use the following csh code to deal. It also shows how to have inline functions in tcsh. Kinda gross, but it does seem to do the job. set host=`uname -n` set __uname_s=`uname -s` set __uname_r=`uname -r` set os=`echo "$__uname_s-$__uname_r" | sed -e 's/\..*$//'` # This shows how to use aliases as inline functions in csh This really # should be expanded inline in the following code, but I'm leaving it # here so that I can know how to do this in the future. __maybe_add # takes two parameters: The env var to update, and the directory to # prepend if it isn't already in the path list. This is the closest # csh comes to functions... alias __maybe_add 'if ((:${\!:1}: !~ *:\!:2\:*) && -d \!:2) set \!:1=${\!:1}\:\!:2' # OK, let's try to be nice to the network and only do the rehashing # stuff once. Seems to be a tiny bit faster, but not by much in the # default case, and just as slow otherwise. We'll see if this is any # better than alternatives or not. It would appear that much of the # slowness is due to other factors (mostly the .subscriptions file that # is a little silly about some things). # # Also make sure that /usr/ucb is toward the front of the list. # set __P=/usr/ucb:`echo $PATH | sed 's=/usr/ucb==;s/::/:/;s/^://;s/:$//'` foreach i (~/bin ~/bin/$host ~/bin/$os \ ~imp/bin ~imp/bin/$host ~imp/bin/$os \ /usr/etc /usr/local/bin /usr/local/mh/bin \ /usr/local/bin/mh /usr/bin/X11 /usr/X11R6/bin \ /opt/SUNWspro/bin \ /usr/openwin/bin /usr/local/bin/X11 /usr/local/X11R6/bin \ /usr/ucb /usr/bin /bin /usr/sbin /sbin \ /usr/local/sbin /usr/ccs/bin .) __maybe_add __P $i end setenv PATH $__P unset __P unset __uname_s __uname_r unalias __maybe_add Warner
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E0wvnXb-000326-00>