This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Manipulating list-o-paths variables (base-files)

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:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]