1 |
I have inherited some pretty gnarly dotfiles that I don't really want to |
2 |
fool with too much, |
3 |
but I'm also unhappy with what they do to my environment. They keep adding |
4 |
the |
5 |
same things over and over to some of the variables. |
6 |
|
7 |
Does anyone know a nice little idiom for de-duping a colon-list like PATH or |
8 |
MANPATH? |
9 |
It has to retain one copy of each duplicate, preserving the order of *first* |
10 |
appearances. |
11 |
I know how to avoid duplicates when I do the coding myself: |
12 |
case :$PATH: in |
13 |
*:mynewthing:*) ;; |
14 |
*) export PATH=$PATH:mynewthing |
15 |
esac |
16 |
|
17 |
I'm just not sure how best to turn the colon-list into something I can |
18 |
iterate over. |
19 |
|
20 |
Obviously, I use bash. |
21 |
|
22 |
++ kevin |
23 |
|
24 |
-- |
25 |
Kevin O'Gorman, PhD |