Blob core/init.bash
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# Basic functions and settings _bashd_error() { echo "[ERROR] $*" >&2 } pathremove() { local IFS=':' local NEWPATH local DIR local PATHVARIABLE=${2:-PATH} for DIR in ${!PATHVARIABLE} ; do if [ "$DIR" != "$1" ] ; then NEWPATH=${NEWPATH:+$NEWPATH:}$DIR fi done export $PATHVARIABLE="$NEWPATH" } _unckecked_pathappend() { pathremove "$1" "$2" local PATHVARIABLE=${2:-PATH} export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1" } pathprepend() { test ! -d "${1}" && return 0 pathremove "$1" "$2" local PATHVARIABLE=${2:-PATH} export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}" } pathappend() { test ! -d "${1}" && return 0 _unckecked_pathappend "$1" "$2" } pwdappend() { pathappend "$(pwd)" } bashd_source() { for file in ${@}; do test ! -f ${file} -o ! -x ${file} && continue . ${file} || _bashd_error "Unable to load ${file}" done } |