git://git.iain.cx/iain
/
profile.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
become overhaul.
[profile.git]
/
.profile.d
/
PATH.bashrc
diff --git
a/.profile.d/PATH.bashrc
b/.profile.d/PATH.bashrc
index
ab57aaa
..
0b82245
100644
(file)
--- a/
.profile.d/PATH.bashrc
+++ b/
.profile.d/PATH.bashrc
@@
-6,7
+6,7
@@
#
# Location of the XXXdirs files.
#
# Location of the XXXdirs files.
-DIR=
"$HOME/.PATH"
+DIR=
${PROFILE_HOME:-~}/.PATH
# Paths to set and the file to get them from @variable to copy from.
PATHS="
# Paths to set and the file to get them from @variable to copy from.
PATHS="
@@
-49,6
+49,19
@@
function copypath() {
[ -z "$path" ] || eval "export $newpath='$path'"
}
[ -z "$path" ] || eval "export $newpath='$path'"
}
+# Helper.
+function addpath() {
+ local path="$1"; shift
+ local dir="$1"; shift
+
+ dir=$(eval echo "$dir")
+ if [ -d "$dir" ]; then
+ echo "$path:$dir"
+ else
+ echo "$path"
+ fi
+}
+
# Set a path from directories.
function makepath() {
local newpath="$1"; shift
# Set a path from directories.
function makepath() {
local newpath="$1"; shift
@@
-61,10
+74,11
@@
function makepath() {
# Read them.
local path=
while read dir; do
# Read them.
local path=
while read dir; do
- local dir=$(eval echo "$dir")
- [ -d "$dir" ] || continue
-
- path="$path:$dir"
+ path=$(addpath "$path" "$dir")
+ if [ -n "$PROFILE_HOME" -a ! "${dir#\$HOME}" = "$dir" ]; then
+ dir="$PROFILE_HOME${dir#\$HOME}"
+ path=$(addpath "$path" "$dir")
+ fi
done < "$dirs"
# Restore IFS.
done < "$dirs"
# Restore IFS.
@@
-115,4
+129,4
@@
for path in $PATHS; do
done
done
-unset DIR PATHS dir dirs path var source sanitisepath copypath makepath newpath
setpaths
+unset DIR PATHS dir dirs path var source sanitisepath copypath makepath newpath
addpath