avoid a pipe and grep invocation in `ADDPATH`

This commit is contained in:
Connor Olding 2021-10-20 21:01:09 +02:00
parent 5c3dce9aa5
commit 1ad81ff42d
1 changed files with 4 additions and 1 deletions

View File

@ -26,7 +26,10 @@ ADDPATH() { ### @- append a directory to `$PATH` if it isn't already present.
printf 'ADDPATH: path does not exist: %s\n' "$1" >&2
return 1
fi
printf '%s' ":$PATH:" | grep -Fq ":$new:" || export PATH="$PATH:$new"
case ":$PATH:" in
(*":$new:"*) :;;
(*) export PATH="$PATH:$new";;
esac
}
# {{{1 configurations