Browse Source

Treat paths with spaces more properly

Alois Mahdal 5 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
     local frst
147
     local frst
148
     local last
148
     local last
149
     local elnum
149
     local elnum
150
+    local elem
150
     test "${#path}" -le 7 && echo -n "$path" && return 0
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
     frst=${elems[0]}
155
     frst=${elems[0]}
153
     last=${elems[$((elnum-1))]}
156
     last=${elems[$((elnum-1))]}
154
     case $elnum in
157
     case $elnum in