From 00ad07673cc52f8489d31bf83702f43923c331ce Mon Sep 17 00:00:00 2001 From: Philippe PITTOLI Date: Tue, 5 Nov 2019 02:12:01 +0100 Subject: [PATCH] rc: /etc/profile --- rc/profile | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ rc/recipe.spec | 3 ++- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 rc/profile diff --git a/rc/profile b/rc/profile new file mode 100644 index 0000000..2085e1e --- /dev/null +++ b/rc/profile @@ -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 + diff --git a/rc/recipe.spec b/rc/recipe.spec index e92041a..5289da5 100644 --- a/rc/recipe.spec +++ b/rc/recipe.spec @@ -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