Browse Source

Treat paths with spaces more properly

Alois Mahdal 4 years ago
parent
commit
9c27b1fb15
1 changed files with 4 additions and 1 deletions
  1. 4
    1
      dotfiles/bash/post.bashrc

+ 4
- 1
dotfiles/bash/post.bashrc View File

@@ -147,8 +147,11 @@ __bashum__shrink_relpath() {
147 147
     local frst
148 148
     local last
149 149
     local elnum
150
+    local elem
150 151
     test "${#path}" -le 7 && echo -n "$path" && return 0
151
-    elems=(${path//// }); elnum=${#elems[@]}
152
+    while IFS= read -r elem; do
153
+        elems+=("$elem"); elnum=${#elems[@]}
154
+    done <<<"$(sed 's|/|\n|' <<<"$path")"
152 155
     frst=${elems[0]}
153 156
     last=${elems[$((elnum-1))]}
154 157
     case $elnum in