aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/%HOME%/.bash_utils
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-05-22 08:34:52 +0000
committerEgor Tensin <Egor.Tensin@gmail.com>2023-05-22 08:34:52 +0000
commit0e68f7ef5507bba674f45cc1c004e061101d2e32 (patch)
tree15149630b1f6624289fcf9a1dc706cfa4000d53f /%HOME%/.bash_utils
parentpath.sh: append by default in path_add (diff)
downloadlinux-home-0e68f7ef5507bba674f45cc1c004e061101d2e32.tar.gz
linux-home-0e68f7ef5507bba674f45cc1c004e061101d2e32.zip
path.sh: don't canonicalize paths in path_add
Resolving symlinks is actually bad; what if the user wants to add a symlinked directory? You better make sure you pass absolute paths now though.
Diffstat (limited to '')
-rw-r--r--%HOME%/.bash_utils/path.sh10
1 files changed, 2 insertions, 8 deletions
diff --git a/%HOME%/.bash_utils/path.sh b/%HOME%/.bash_utils/path.sh
index 0661710..58707f4 100644
--- a/%HOME%/.bash_utils/path.sh
+++ b/%HOME%/.bash_utils/path.sh
@@ -23,13 +23,7 @@ path_add() (
[ "$#" -eq 0 ] && return 0
- local -a src_list
-
local path
- readlink -z --canonicalize-missing -- "$@" | while IFS= read -d '' -r path; do
- src_list+=("$path")
- done
-
for path; do
if str_contains "$path" ':'; then
echo "${FUNCNAME[0]}: mustn't contain colon (':') characters: $path" >&2
@@ -40,14 +34,14 @@ path_add() (
local -A uniq_paths
local -a new_paths current_paths
- for path in ${src_list[@]+"${src_list[@]}"}; do
+ for path; do
[ -n "${uniq_paths[$path]+x}" ] && continue
uniq_paths[$path]=1
new_paths+=("$path")
done
if [ -n "${PATH-}" ]; then
- str_split -z -- "${PATH-}" ':' | xargs -0 -- readlink -z --canonicalize-missing -- | while IFS= read -d '' -r path; do
+ str_split -z -- "${PATH-}" ':' | while IFS= read -d '' -r path; do
[ -n "${uniq_paths[$path]+x}" ] && continue
uniq_paths[$path]=1
current_paths+=("$path")