zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: Zsh Workers <zsh-workers@sunsite.dk>
Subject: PATCH (?): Re: Automatic hash -d
Date: Wed, 18 Apr 2001 05:56:33 +0000	[thread overview]
Message-ID: <1010418055634.ZM28577@candle.brasslantern.com> (raw)
In-Reply-To: <1010413153830.ZM1837@candle.brasslantern.com>
In-Reply-To: <200104170904.LAA05143@beta.informatik.hu-berlin.de>

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   


  reply	other threads:[~2001-04-18  6:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-13  2:08 Wayne Davison
2001-04-13  2:30 ` "keep-prefix true" feature request Wayne Davison
2001-04-13  4:50   ` Bart Schaefer
2001-04-13  5:09     ` Automatic hash -d Bart Schaefer
2001-04-13  8:01       ` Wayne Davison
2001-04-13 15:38         ` Bart Schaefer
2001-04-13 16:47       ` Bart Schaefer
2001-04-17  9:04         ` Sven Wischnowsky
2001-04-18  5:56           ` Bart Schaefer [this message]
2001-04-18  8:29             ` PATCH (?): " Sven Wischnowsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1010418055634.ZM28577@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).