about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2017-03-09 20:23:04 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2017-03-09 20:29:27 -0800
commit9f498643228df057f6e80babba6f9a064cb12df3 (patch)
tree888053dbdabe5701ac49ffdacb9be1ba7d3417c6
parent018992123ed10cd5d5d95d94658b95964121fde4 (diff)
downloadzsh-9f498643228df057f6e80babba6f9a064cb12df3.tar.gz
zsh-9f498643228df057f6e80babba6f9a064cb12df3.tar.xz
zsh-9f498643228df057f6e80babba6f9a064cb12df3.zip
40801: re-fix completion of mount points with spaces in the name
Turns out that work of art removed by 33963 was necessary after all
-rw-r--r--ChangeLog6
-rw-r--r--Completion/Unix/Command/_mount12
2 files changed, 15 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 9659b29f5..ac05c545c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-03-09  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 40801: Completion/Unix/Command/_mount: turns out that work of
+	art removed by 33963 was necessary after all: re-fix completion
+	of mount points with spaces in the name
+
 2017-03-09  Peter Stephenson  <p.stephenson@samsung.com>
 
 	* 40805: (combined with the previous change):
diff --git a/Completion/Unix/Command/_mount b/Completion/Unix/Command/_mount
index 9ab279d75..9a7041dee 100644
--- a/Completion/Unix/Command/_mount
+++ b/Completion/Unix/Command/_mount
@@ -959,9 +959,15 @@ udevordir)
   esac
 
   local MATCH MBEGIN MEND
-  mp_tmp=("${(@g::)mp_tmp}")
-  dpath_tmp=( "${(@Mg::)dev_tmp:#/*}" )
-  dev_tmp=( "${(@g::)dev_tmp:#/*}" )
+  # The complicated substitution for mount point names is required because
+  # characters in /etc/mtab that might confuse programs reading the names
+  # are encoded as exactly 3 octal digits, like for example \040 for space.
+  # The cleaner-looking ${(g::)mp_tmp} might consume too many digits.
+  # Both mp_tmp and dev_tmp are derived from /etc/mtab or "mount" output.
+  mp_tmp=("${(@)mp_tmp//(#m)\\[0-7](#c3)/${(#)$(( 8#${MATCH[2,-1]} ))}}")
+  dev_tmp=("${(@)dev_tmp//(#m)\\[0-7](#c3)/${(#)$(( 8#${MATCH[2,-1]} ))}}")
+  dpath_tmp=( "${(@M)dev_tmp:#/*}" )
+  dev_tmp=( "${(@)dev_tmp:#/*}" )
 
   _alternative \
     'device-labels:device label:compadd -a dev_tmp' \