diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2017-10-01 19:15:07 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2017-10-01 19:15:07 +0300 |
commit | 1459a7651d27a43f9350cbc69dd9a01369c3e5d5 (patch) | |
tree | 876780004214ff0b9c9843924839eb582c5d7d16 /%HOME% | |
parent | remove configure_git.sh (diff) | |
download | linux-home-1459a7651d27a43f9350cbc69dd9a01369c3e5d5.tar.gz linux-home-1459a7651d27a43f9350cbc69dd9a01369c3e5d5.zip |
path_add: prepend
Diffstat (limited to '')
-rw-r--r-- | %HOME%/.bash_utils/path.sh | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/%HOME%/.bash_utils/path.sh b/%HOME%/.bash_utils/path.sh index 9a0e1a2..9f1fdd4 100644 --- a/%HOME%/.bash_utils/path.sh +++ b/%HOME%/.bash_utils/path.sh @@ -29,19 +29,20 @@ path_add() ( local -A dest_dict local -a dest_list + for path in ${src_list[@]+"${src_list[@]}"}; do + [ -n "${dest_dict[$path]+x}" ] && continue + dest_dict[$path]=1 + dest_list+=("$path") + done + if [ -n "${PATH-}" ]; then while IFS= read -d '' -r path; do + [ -n "${dest_dict[$path]+x}" ] && continue dest_dict[$path]=1 dest_list+=("$path") done < <( str_split -z -- "${PATH-}" ':' | xargs -0 -- readlink -z --canonicalize-missing -- ) fi - for path in ${src_list[@]+"${src_list[@]}"}; do - [ -n "${dest_dict[$path]+x}" ] && continue - dest_dict[$path]=1 - dest_list+=("$path") - done - str_join ':' ${dest_list[@]+"${dest_list[@]}"} ) |