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

PATCH (?): Re: Automatic hash -d



On Apr 13,  3:38pm, Bart Schaefer wrote:
}
} Perhaps backticks should be treated like $(...) and therefore passed
} through the parameter expansion branch in _path_files?  The expression
} would be something like:
} 
}     if [[ "$pre" = *(\`[^\`]#\`|\$)*/* && ...

On Apr 17, 11:04am, Sven Wischnowsky wrote:
} 
} It's probably ok to use eval there, ensuring that it doesn't print error
} messages, because that seems to have been the reason for all that code
} (added in 9880).

So how's this look?  I'm a little worried about "$compstate[quote]" != \"
but that's what was there before, and I don't really understand why I'm
worried (nor why it's there, for that matter; the -z "$compstate[quote]"
test in the next branch makes more sense to me).

One further note about this:  If you complete

	% ls ~notauser/<TAB>
	Completing unknown user `notauser'

If instead you complete

	% var=notadir
	% ls ~notauser/$var/<TAB>
	No matches for `files', `file', or `corrections'

But if you then immediately hit RET, you see

	zsh: no such user or named directory: notauser

Ideally, the code in _path_files would first peel off the ~notauser and
check that for errors, and then discover that the prefix still contains
an expansion and try to shift more of it into linepath and realpath and
check *that* for errors; but I wasn't prepared to do that much violence
to _path_files.

I'll wait for Sven to either commit something or to tell me to go ahead
and commit the following patch (which, BTW, is *instead* of the patch in
13974).

Index: Completion/Unix/Type/_path_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_files,v
retrieving revision 1.2
diff -u -r1.2 _path_files
--- Completion/Unix/Type/_path_files	2001/04/13 16:31:39	1.2
+++ Completion/Unix/Type/_path_files	2001/04/18 05:40:46
@@ -190,7 +190,7 @@
 
 # Now let's have a closer look at the string to complete.
 
-if [[ "$pre" = *\$*/* && "$compstate[quote]" != \" ]]; then
+if [[ "$pre" = *(\`[^\`]#\`|\$)*/* && "$compstate[quote]" != \" ]]; then
 
   # If there is a parameter expansion in the word from the line, we try
   # to complete the beast by expanding the prefix and completing anything
@@ -207,6 +207,7 @@
   donepath=
   prepaths=( '' )
 elif [[ "$pre[1]" = \~ && -z "$compstate[quote]" ]]; then
+
   # It begins with `~', so remember anything before the first slash to be able
   # to report it to the completion code. Also get an expanded version of it
   # (in `realpath'), so that we can generate the matches. Then remove that
@@ -217,10 +218,6 @@
   linepath="${pre[2,-1]%%/*}"
   if [[ -z "$linepath" ]]; then
     realpath="${HOME%/}/"
-  elif (( $+userdirs[$linepath] )); then
-    realpath="${userdirs[$linepath]%/}/"
-  elif (( $+nameddirs[$linepath] )); then
-    realpath="${nameddirs[$linepath]%/}/"
   elif [[ "$linepath" = ([-+]|)[0-9]## ]]; then
     if [[ "$linepath" != [-+]* ]]; then
       if [[ -o pushdminus ]]; then
@@ -248,8 +245,11 @@
   elif [[ "$linepath" = [-+] ]]; then
     realpath=${~:-\~$linepath}/
   else
-    _message "unknown user \`$linepath'"
-    return 1
+    eval "realpath=~${linepath}/" 2>/dev/null
+    if [[ -z "$realpath" ]]; then
+      _message "unknown user \`$linepath'"
+      return 1
+    fi
   fi
   linepath="~${linepath}/"
   [[ "$realpath" = "$linepath" ]] && return 1

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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