瀏覽代碼

Treat paths with spaces more properly

Alois Mahdal 5 年之前
父節點
當前提交
9c27b1fb15
共有 1 個檔案被更改,包括 4 行新增1 行删除
  1. 4
    1
      dotfiles/bash/post.bashrc

+ 4
- 1
dotfiles/bash/post.bashrc 查看文件

@@ -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