Skip to content

Commit 0c77892

Browse files
committed
profile: Use OS X-like paths instead of ash-incomp impl from BLFS
1 parent ad4a8e1 commit 0c77892

File tree

2 files changed

+15
-31
lines changed

2 files changed

+15
-31
lines changed

profile

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,21 @@
1010
# ~/.bash_profile. Personal aliases and functions should go into
1111
# ~/.bashrc.
1212

13-
# Functions to help us manage paths. Second argument is the name of the
14-
# path variable to be modified (default: PATH)
15-
pathremove () {
16-
local IFS=':'
17-
local NEWPATH
18-
local DIR
19-
local PATHVARIABLE=${2:-PATH}
20-
for DIR in ${!PATHVARIABLE} ; do
21-
if [ "$DIR" != "$1" ] ; then
22-
NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
23-
fi
24-
done
25-
export $PATHVARIABLE="$NEWPATH"
26-
}
27-
28-
pathprepend () {
29-
pathremove $1 $2
30-
local PATHVARIABLE=${2:-PATH}
31-
export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
32-
}
33-
34-
pathappend () {
35-
pathremove $1 $2
36-
local PATHVARIABLE=${2:-PATH}
37-
export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
38-
}
13+
_IFS="$IFS" IFS='
14+
'
15+
export PATH MANPATH
3916

17+
for pth in $(cat /etc/paths.d/._* /etc/paths /etc/paths.d/*); do
18+
PATH="$PATH:$pth"
19+
done 2>/dev/null
4020

41-
# Set the initial path
42-
export PATH=/bin:/usr/bin
21+
for pth in $(cat /etc/manpaths.d/._* /etc/manpaths /etc/manpaths.d/*); do
22+
MANPATH="$MANPATH:$pth"
23+
done 2>/dev/null
24+
: ${PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin}
25+
: ${MANPATH=/usr/share/man:/usr/local/share/man}
4326

27+
# Set the initial path
4428
if [ $EUID -eq 0 ] ; then
4529
pathappend /sbin:/usr/sbin
4630
unset HISTFILE
@@ -57,6 +41,6 @@ for script in /etc/profile.d/*.sh ; do
5741
done
5842

5943
# Now to clean up
60-
unset pathremove pathprepend pathappend script
61-
44+
unset pth script
45+
IFS="$_IFS"
6246
# End /etc/profile

profile.d/extrapaths

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
if [ -d ~/bin ]; then
2-
pathprepend ~/bin
2+
PATH="$HOME/bin:$PATH"
33
fi

0 commit comments

Comments
 (0)