Add bash functions
This commit is contained in:
@@ -31,12 +31,24 @@ function append_path() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function append_path_try() {
|
||||||
|
if [[ -e "$1" ]]; then
|
||||||
|
append_pat "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function prepend_path() {
|
function prepend_path() {
|
||||||
if ! in_path "$1"; then
|
if ! in_path "$1"; then
|
||||||
PATH="$1:$PATH"
|
PATH="$1:$PATH"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function prepend_path_try() {
|
||||||
|
if [[ -e "$1" ]]; then
|
||||||
|
prepend_path "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function uniq_path() {
|
function uniq_path() {
|
||||||
echo "$PATH" | tr ":" "\n" | awk '!seen[$0]++' | tr "\n" ":" | sed -r 's/:+/:/g' | sed -r 's/^:|:$//g'
|
echo "$PATH" | tr ":" "\n" | awk '!seen[$0]++' | tr "\n" ":" | sed -r 's/:+/:/g' | sed -r 's/^:|:$//g'
|
||||||
}
|
}
|
||||||
@@ -71,7 +83,7 @@ function dump_args() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function try_source() {
|
function source_try() {
|
||||||
local script="$1"
|
local script="$1"
|
||||||
if [[ -e "$script" ]]; then
|
if [[ -e "$script" ]]; then
|
||||||
source "$script"
|
source "$script"
|
||||||
|
|||||||
Reference in New Issue
Block a user