Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: _most_recent_file
- X-seq: zsh-workers 14330
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx (Zsh hackers list)
- Subject: PATCH: _most_recent_file
- Date: Mon, 14 May 2001 14:18:47 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
Just noticed this is bad about quoting, both with existing quoted
characters and inserting characters which need quoting. Probably there
wasn't a way to fix this simply when I first wrote it. Don't suppose
anyone else uses it anyway.
Index: Completion/Base/Widget/_most_recent_file
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Widget/_most_recent_file,v
retrieving revision 1.1
diff -u -r1.1 _most_recent_file
--- Completion/Base/Widget/_most_recent_file 2001/04/02 11:16:36 1.1
+++ Completion/Base/Widget/_most_recent_file 2001/05/14 13:17:09
@@ -1,22 +1,24 @@
#compdef -k complete-word \C-xm
-# Complete the most recent file matching the pattern on the line so
-# far: globbing is active, i.e. *.txt will be expanded to the most recent
+# Complete the most recently modified file matching the pattern on the line
+# so far: globbing is active, i.e. *.txt will be expanded to the most recent
# file ending in .txt
#
# With a prefix argument, select the Nth most recent matching file;
# negative arguments work in the opposite direction, so for example
# `Esc - \C-x m' gets you the oldest file.
-#
-# (`Most recent' means most recently modified.)
local file tilde etilde
if [[ $PREFIX = \~*/* ]]; then
tilde=${PREFIX%%/*}
etilde=${~tilde}
- file=($~PREFIX*$~SUFFIX(om[${NUMERIC:-1}]N))
- file=(${file/#$etilde/$tilde})
+ # PREFIX and SUFFIX have full command line quoting in, but we want
+ # any globbing characters which are quoted to stay quoted.
+ eval "file=($PREFIX*$SUFFIX(om[${NUMERIC:-1}]N))"
+ file=(${file/#$etilde})
+ file=($tilde${(q)^file})
else
- file=($~PREFIX*$~SUFFIX(om[${NUMERIC:-1}]N))
+ eval "file=($PREFIX*$SUFFIX(om[${NUMERIC:-1}]N))"
+ file=(${(q)file})
fi
(( $#file )) && compadd -U -i "$IPREFIX" -I "$ISUFFIX" -f -Q $file
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR Ltd., Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
Messages sorted by:
Reverse Date,
Date,
Thread,
Author