Introduce function for uniq PATH

This commit is contained in:
Martin Blazik
2022-03-18 08:03:26 +01:00
parent 47a048e669
commit cb16c948ac
2 changed files with 10 additions and 2 deletions

3
bashrc
View File

@@ -15,5 +15,4 @@ for rc_file in $WORKSPACE/rc/*.sh; do
done
append_path "$LWS/bin"
PATH="$(uniq_path)"
set_uniq_path

View File

@@ -35,7 +35,16 @@ function uniq_path() {
echo "$PATH" | tr ":" "\n" | awk '!seen[$0]++' | tr "\n" ":" | sed -r 's/:+/:/g' | sed -r 's/^:|:$//g'
}
function set_uniq_path() {
PATH="$(uniq_path)"
}
function is_alias() {
alias "$1" > /dev/null 2>&1
}
function can_run() {
local application="$1"
command -v "$application" > /dev/null
}