From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19404 invoked from network); 14 May 2001 13:19:25 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 14 May 2001 13:19:25 -0000 Received: (qmail 11526 invoked by alias); 14 May 2001 13:19:17 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 14330 Received: (qmail 11511 invoked from network); 14 May 2001 13:19:16 -0000 Message-ID: To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: PATCH: _most_recent_file Date: Mon, 14 May 2001 14:18:47 +0100 From: Peter Stephenson 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 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. **********************************************************************