dblume commited on 2023-01-08 21:36:40
Showing 1 changed files, with 8 additions and 2 deletions.
It is also used extensively in the WSL .localrc to remove unused paths.
... | ... |
@@ -70,13 +70,19 @@ prepend_to_path() { |
70 | 70 |
fi |
71 | 71 |
} |
72 | 72 |
|
73 |
+remove_from_path() { |
|
74 |
+ # N.B. It'll remove all instances of $1, so ensure it's a unique pathname |
|
75 |
+ PATH=${PATH//"$1"/} |
|
76 |
+} |
|
77 |
+ |
|
73 | 78 |
# if this is a CygWin .bashrc, then set CygWin's commands first in PATH |
74 | 79 |
# because link.exe and find.exe exist in Windows's path. |
75 | 80 |
# Add /usr/lib/lapack at the end so python's numpy can find lapack_lite |
76 | 81 |
# (Note: BSD bash, used by OS X doesn't have the "substr" test for expr.) |
77 | 82 |
if [[ $(uname -s) == CYGWIN* ]]; then |
78 |
- PATH=/usr/local/bin:/usr/bin:$PATH |
|
79 |
- PATH=${PATH//":/usr/local/bin:/usr/bin"/} # delete any instances in middle |
|
83 |
+ prepend_to_path /usr/bin |
|
84 |
+ prepend_to_path /usr/local/bin |
|
85 |
+ remove_from_path ":/usr/local/bin:/usr/bin" |
|
80 | 86 |
append_to_path /usr/lib/lapack |
81 | 87 |
export GIT_SSH=/cygdrive/c/cygwin64/bin/ssh |
82 | 88 |
ulimit -n 1024 # for "duplicity" |
83 | 89 |