about summary refs log tree commit diff
path: root/Completion/Unix
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Unix')
-rw-r--r--Completion/Unix/Type/_list_files13
1 files changed, 8 insertions, 5 deletions
diff --git a/Completion/Unix/Type/_list_files b/Completion/Unix/Type/_list_files
index bd5c1fa62..5e745d9d1 100644
--- a/Completion/Unix/Type/_list_files
+++ b/Completion/Unix/Type/_list_files
@@ -8,7 +8,7 @@
 # Sets array listfiles to the display strings and the array
 # listopts appropriately to be added to the compadd command line.
 
-local stat f elt what
+local stat f elt what dir
 local -a stylevals
 integer ok
 
@@ -48,14 +48,17 @@ done
 
 zmodload -i zsh/stat 2>/dev/null || return 1
 
-for f in ${(P)1}; do
-  if [[ ! -e "${2:+$2/}$f" ]]; then
-    listfiles+=("${2:+$2/}$f")
+dir=${2:+$2/}
+dir=${(Q)dir}
+
+for f in ${(PQ)1}; do
+  if [[ ! -e "$dir$f" ]]; then
+    listfiles+=("$dir$f")
     continue
   fi
 
   # Borrowed from Functions/Example/zls
-  stat -s -H stat -F "%b %e %H:%M" - "${2:+$2/}$f" >/dev/null 2>&1
+  stat -s -H stat -F "%b %e %H:%M" - "$dir$f" >/dev/null 2>&1
 
   listfiles+=("$stat[mode] ${(l:3:)stat[nlink]} ${(r:8:)stat[uid]} \
  ${(r:8:)stat[gid]} ${(l:8:)stat[size]} $stat[mtime] $f")