aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/%HOME%
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-11-04 02:40:53 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-11-04 02:40:53 +0300
commit0fbde6c918e7203091375b4a07d66c78c77bac00 (patch)
tree8350d8c37794a5769224e0bf988f1360d6b9fd62 /%HOME%
parentupdate_ruby_settings: fix Ruby directory paths (diff)
downloadlinux-home-0fbde6c918e7203091375b4a07d66c78c77bac00.tar.gz
linux-home-0fbde6c918e7203091375b4a07d66c78c77bac00.zip
add_missing_path: preserve order
Diffstat (limited to '%HOME%')
-rw-r--r--%HOME%/.bash_utils/path.sh14
1 files changed, 9 insertions, 5 deletions
diff --git a/%HOME%/.bash_utils/path.sh b/%HOME%/.bash_utils/path.sh
index b9e78b6..7982427 100644
--- a/%HOME%/.bash_utils/path.sh
+++ b/%HOME%/.bash_utils/path.sh
@@ -26,17 +26,21 @@ add_missing_path() (
fi
done
- local -A old_paths
+ local -A old_paths_dict
+ local -a old_paths_list
while IFS= read -d '' -r path; do
- old_paths[$path]=1
- done < <( str_split -z -- "${PATH-}" ':' | xargs --null readlink --zero --canonicalize-missing -- )
+ old_paths_dict[$path]=1
+ old_paths_list+=("$path")
+ done < <( str_split -z -- "${PATH-}" ':' | xargs -0 readlink --zero --canonicalize-missing -- )
for path in ${new_paths[@]+"${new_paths[@]}"}; do
- old_paths[$path]=1
+ [ -n "${old_paths_dict[$path]+x}" ] && continue
+ old_paths_dict[$path]=1
+ old_paths_list+=("$path")
done
- str_join ':' "${!old_paths[@]}"
+ str_join ':' ${old_paths_list[@]+"${old_paths_list[@]}"}
)
add_path() {