This is the mail archive of the
mailing list for the Cygwin project.
Manipulating list-o-paths variables (base-files)
- From: "mike808" <mike808 at users dot sourceforge dot net>
- To: <john dot r dot morrison at ntlworld dot com>, <cygwin at cygwin dot com>, <cygwin-apps at cygwin dot com>
- Date: Fri, 15 Aug 2003 19:13:20 -0500 (CDT)
- Subject: Manipulating list-o-paths variables (base-files)
- Reply-to: mike808 at users dot sourceforge dot net
I also saw some thread on cygwin-app about issues when mangling with the
MANPATH, PATH, etc. variables.
Here's what I've done to alleviate the problem of every script tacking on
another copy of /usr/local/bin or whatever to PATH, but never checks to see
if it is already there, and sometimes even if the path being added exists.
So, I wrote some helper functions that will prepend or append a path to a
variable. It will do the right thing when the variable is empty, and won't
insert directories multiple times, and won't insert directories that don't
I usually have them in someplace like /etc/profile.functions and then
just source it in. That way other scripts that play with paths can
also use the functions. Perhaps they can be useful in base-files?
The functions help to preserve the existing path, setup your own, and
then go back and re-add all of the paths in the original path variable.
This way, any "extras" get included, but you get to determine the
ordering, and eliminate duplicates.
I've also created similar functions to remove paths (in case there are
multiple entries for the same directory that should be removed).
for the code.
Just create the related functions for MANPATH, LD_LIBRARY_PATH, and any
other list-of-directories type of variable, and you're done.
I just haven't gotten around to writing a function factory for this,
so that you can create these functions on-the-fly for any variable.
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html