Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Umount completion fails when mount point or dev node contains spaces



On Linux at least, non-straightforward characters are encoded with the
\NNN notation in /etc/mtab, with NNN being the octal ASCII code of the
character.

Our current umount completer does not handle it.

  # mkdir /mnt/mount\ point\[\\
  # mount --bind /tmp /mnt/mount\ point\[\\
  # umount /mnt/mount<TAB>

yields

  # umount /mnt/mount\\040point\[\\134

The enclosed patch takes care of the problem by unescaping octal
sequences.

Please note that I've assumed that all unices escape spaces and other
unprintable characters this way.  If it's not the case, then the
mp_tmp and dev_tmp assignments should be moved to the Linux branch of
the case.

Can anyone confirm other unices behavior?

Phil.

Changelog entry:

2005-01-31  Philippe Troin  <phil@xxxxxxxx>

       * Completion/Unix/Command/_mount: Unescape mtab octal sequences.

Index: Completion/Unix/Command/_mount
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_mount,v
retrieving revision 1.18
diff -b -u -r1.18 _mount
--- Completion/Unix/Command/_mount	20 Feb 2004 10:57:11 -0000	1.18
+++ Completion/Unix/Command/_mount	1 Feb 2005 01:01:32 -0000
@@ -794,7 +794,7 @@
   esac
   ;;
 udevordir)
-  local dev_tmp mp_tmp mline
+  local dev_tmp mp_tmp mline match
 
   case "$OSTYPE" in
   linux*|irix*)
@@ -810,6 +810,9 @@
     ;;
   esac
 
+  mp_tmp=(${mp_tmp//(#b)(\\([0-7]##|\\))/$(print $match[1])})
+  dev_tmp=(${dev_tmp//(#b)(\\([0-7]##|\\))/$(print $match[1])})
+
   _alternative \
     'devices:device:compadd -a dev_tmp' \
     'directories:mount point:compadd -a mp_tmp' && ret=0


Messages sorted by: Reverse Date, Date, Thread, Author