You should always check if the value is present in a list before adding it in.
function prepend_path () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
PATH="$1:${PATH}"
esac
}
Usage Link to heading
prepend_path ~/.local/bin
Cleanup Link to heading
unset prepend_path