Archived
3
0

rc: /etc/profile

This commit is contained in:
Philippe PITTOLI 2019-11-05 02:12:01 +01:00
parent b7159a4e93
commit 00ad07673c
2 changed files with 58 additions and 1 deletions

56
rc/profile Normal file
View File

@ -0,0 +1,56 @@
#!/bin/sh
path_sanitize() {
echo "${1}" | /bin/sed 's|//|/|g'
}
path_add() {
path="$1"
entry="$(path_sanitize "$2")"
if [ -z "$path" ]; then
echo "$entry"
else
echo "$path:$entry"
fi
}
path_remove() {
path="$1"
entry="$(path_sanitize "$2")"
# If $entry is the last entry.
if [ "${path##*:}" = "$entry" ]; then
echo "${path%:*}"
return 0
fi
echo "$path" | /bin/sed "s|$entry:||"
}
prefix_add() {
prefix="$1"
PATH="$(path_add "$PATH" "$prefix/bin")"
PATH="$(path_add "$PATH" "$prefix/sbin")"
}
prefix_remove() {
prefix="$1"
PATH="$(path_remove "$PATH" "$prefix/bin")"
PATH="$(path_remove "$PATH" "$prefix/sbin")"
}
PATH=
# Latest will usually be used first. More can be added with new calls
# to prefix_add.
prefix_add /
prefix_add /usr/weirdos
prefix_add /usr/local
# Use these instructions to remove already defined prefixes.
#prefix_remove /usr/weirdos
#prefix_remove /usr/local

View File

@ -1,5 +1,5 @@
name: rc
version: 0.0.2
version: 0.0.3
release: 1
sources:
- group
@ -15,6 +15,7 @@ sources:
- rc.shutdown
- rc.single
- sysctl.conf
- profile
@configure
true