From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18103 invoked from network); 18 Apr 2001 06:31:24 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 18 Apr 2001 06:31:24 -0000 Received: (qmail 25547 invoked by alias); 18 Apr 2001 06:31:10 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 14004 Received: (qmail 25490 invoked from network); 18 Apr 2001 06:31:08 -0000 From: "Bart Schaefer" Message-Id: <1010418055634.ZM28577@candle.brasslantern.com> Date: Wed, 18 Apr 2001 05:56:33 +0000 In-Reply-To: <1010413153830.ZM1837@candle.brasslantern.com> Comments: In reply to "Bart Schaefer" "Re: Automatic hash -d" (Apr 13, 3:38pm) References: <1010413153830.ZM1837@candle.brasslantern.com> <200104170904.LAA05143@beta.informatik.hu-berlin.de> In-Reply-To: <200104170904.LAA05143@beta.informatik.hu-berlin.de> Comments: In reply to Sven Wischnowsky "Re: Automatic hash -d" (Apr 17, 11:04am) X-Mailer: Z-Mail (5.0.0 30July97) To: Zsh Workers Subject: PATCH (?): Re: Automatic hash -d MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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/ Completing unknown user `notauser' If instead you complete % var=notadir % ls ~notauser/$var/ 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