* Bug in umount completion
@ 2008-01-18 22:00 Richard Hartmann
2008-01-19 19:32 ` Peter Stephenson
0 siblings, 1 reply; 3+ messages in thread
From: Richard Hartmann @ 2008-01-18 22:00 UTC (permalink / raw)
To: zsh users
Hi all,
zsh 4.3.4 fails to fully escape mounted directories.
To reproduce:
mkdir -p "/tmp/foo's bar"
mount /dev/whatever "/tmp/foo's bar" #note that completing on this will work
umount /tmp/f<tab>
this gives me:
umount /media/foo's\040bar
As you can see, the apostrophe is not escaped, thus hitting enter will get you
into quote-mode.
As an aside, the whitespace is completed as \040 which is also strange.
Richard
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Bug in umount completion
2008-01-18 22:00 Bug in umount completion Richard Hartmann
@ 2008-01-19 19:32 ` Peter Stephenson
2008-01-20 19:46 ` Richard Hartmann
0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2008-01-19 19:32 UTC (permalink / raw)
To: zsh users
On Fri, 18 Jan 2008 23:00:32 +0100
"Richard Hartmann" <richih.mailinglist@gmail.com> wrote:
> zsh 4.3.4 fails to fully escape mounted directories.
Yes, I suspect there are a lot of places where you don't usually
get special characters in names for which completions aren't quoted
properly.
> As an aside, the whitespace is completed as \040 which is also strange.
This is a low-level feature of Linux so that when the "mount" arguments
are split the space doesn't confuse matters. I've fixed this so that it
handles octal escapes generally; this may well be overkill and it would
have been much simpler and quite possibly good enough just to replace
\040. I don't know how far the \OOO trick has spread, and I've assumed
it's more useful to handle that everywhere and run the small risk of
real filenames of that form than limit the fix to Linux.
I've added the quoting to devices as well as mount points; it's unlikely
to be needed, but it's at least harmless. I haven't tried applying the
octal escape hackery to devices.
As you'll see, I've add a simplified explanation of how I fixed the
octal escapes.
Index: Completion/Unix/Command/_mount
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_mount,v
retrieving revision 1.26
diff -u -r1.26 _mount
--- Completion/Unix/Command/_mount 28 Nov 2007 17:28:57 -0000 1.26
+++ Completion/Unix/Command/_mount 19 Jan 2008 19:23:23 -0000
@@ -867,8 +867,27 @@
;;
esac
- dpath_tmp=( "${(@M)dev_tmp:#/*}" )
- dev_tmp=( "${(@)dev_tmp:#/*}" )
+ # "Mummy, why is mount point matching full of squiggles?"
+ #
+ # "Well, dear, the clever people who wrote Linux decided that some
+ # funny characters that might confuse programmes looking at the names
+ # would be encoded as octal escapes, like for example \040 for space.
+ # The clever people who wrote zsh decided that nothing would
+ # ever be quite as simple as it should be, so to substitute octal
+ # escapes everywhere in a string, even though the shell understands
+ # them natively in print escapes, needs some hackery where you match
+ # the octal number using the numeric closure syntax introduced after
+ # 4.3.4, then reinput the number in a standard math mode format as 8#OOO,
+ # and turn that into a character using the (#) parameter flag."
+ #
+ # "Mummy, why is nothing ever quite as simple as it should be?"
+ #
+ # "Well, dear, if it was then the clever people who write programmes would
+ # have been replaced by intelligent monkeys and then they'd be out
+ # of working roaming the streets, and we wouldn't want that, would we?"
+ mp_tmp=("${(@q)mp_tmp//(#m)\\[0-7](#c3)/${(#)$(( 8#${MATCH[2,-1]} ))}}")
+ dpath_tmp=( "${(@Mq)dev_tmp:#/*}" )
+ dev_tmp=( "${(@q)dev_tmp:#/*}" )
_alternative \
'device-labels:device label:compadd -a dev_tmp' \
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Bug in umount completion
2008-01-19 19:32 ` Peter Stephenson
@ 2008-01-20 19:46 ` Richard Hartmann
0 siblings, 0 replies; 3+ messages in thread
From: Richard Hartmann @ 2008-01-20 19:46 UTC (permalink / raw)
To: Peter Stephenson; +Cc: zsh users
On Jan 19, 2008 8:32 PM, Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> I've added the quoting to devices as well as mount points; it's unlikely
> to be needed, but it's at least harmless. I haven't tried applying the
> octal escape hackery to devices.
Thanks!
Richard
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-01-20 19:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-18 22:00 Bug in umount completion Richard Hartmann
2008-01-19 19:32 ` Peter Stephenson
2008-01-20 19:46 ` Richard Hartmann
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).