zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: PATCH: Re: completion problem with filename including # (and pathmax stuff)
Date: Thu, 3 Aug 2000 15:30:56 +0200 (MET DST)	[thread overview]
Message-ID: <200008031330.PAA22832@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Tanaka Akira's message of 03 Aug 2000 20:47:09 +0900


Tanaka Akira wrote:

> Thanks.
> 
> > +    tmp1=( ${tmp1//(#b)([][()|*?^#~<>])/\\${match[1]}} )
> 
> I tried test some special characters other than # and found that > and
> \ has a problem.

Rats. I had tried some others, too, but missed (inter alia) these two.

> Z(2):akr@flux% Src/zsh -f
> flux% bindkey -e; autoload -U compinit; compinit -D; compdef _tst tst
> flux% mkdir -p '>aa/bb' '\cc/dd'
> flux% ls -ld '>aa' '\cc'
> drwxr-xr-x  3 akr  akr  512 Aug  3 20:46 >aa
> drwxr-xr-x  3 akr  akr  512 Aug  3 20:46 \cc
> flux% ls \>a<TAB>
> flux% ls \\c<TAB>
> 
> They completes nothing.
> 
> Although I tried to change the character range to [][()|*?^#~<\\], the
> problem is not fixed.

It's *much* worse:

  % ls
  <aa  >bb
  % a='\<*' b='\>*'
  % echo $~a
  <aa
  % echo $~b
  zsh: no match
  % setopt shglob
  % echo $~a
  zsh: no match
  % echo $~b
  zsh: no match
  %

All this is caused by tokenize() treating backslashes differently.

I wanted to not commit this patch right now, but to compile the shell
I had to fix a pathmax bug in parameter.c and that has to go in. So,
let's just try it. Most of the patch is for unsetopting shglob in
completion functions and for _expand and _path_files to get quoting
right. At least I've tried several things needing quoting and they
were all handled correctly.


There is another problem with the pathmax stuff: with the files
module, doing `mkdir foo' fails because it tries to get the pathname
length of a non-existing directory. Haven't checked if there are other 
builtins with this problem.


Bye
 Sven

Index: Completion/Commands/_bash_completions
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Commands/_bash_completions,v
retrieving revision 1.4
diff -u -r1.4 _bash_completions
--- Completion/Commands/_bash_completions	2000/06/22 08:42:36	1.4
+++ Completion/Commands/_bash_completions	2000/08/03 13:29:13
@@ -25,7 +25,7 @@
 # that will not have been overridden, so you should add '~' to the
 # list of keys at the top of the for-loop.
 
-setopt localoptions nullglob rcexpandparam extendedglob
+setopt localoptions nullglob rcexpandparam extendedglob noshglob
 unsetopt markdirs globsubst shwordsplit nounset ksharrays
 
 local key=$KEYS[-1] expl
Index: Completion/Commands/_complete_debug
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Commands/_complete_debug,v
retrieving revision 1.7
diff -u -r1.7 _complete_debug
--- Completion/Commands/_complete_debug	2000/05/31 09:56:12	1.7
+++ Completion/Commands/_complete_debug	2000/08/03 13:29:13
@@ -1,6 +1,6 @@
 #compdef -k complete-word \C-x?
 
-setopt localoptions nullglob rcexpandparam extendedglob
+setopt localoptions nullglob rcexpandparam extendedglob noshglob
 unsetopt markdirs globsubst shwordsplit nounset ksharrays
 
 setopt localtraps noerrexit ; trap - ZERR
Index: Completion/Commands/_complete_help
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Commands/_complete_help,v
retrieving revision 1.8
diff -u -r1.8 _complete_help
--- Completion/Commands/_complete_help	2000/05/23 08:54:30	1.8
+++ Completion/Commands/_complete_help	2000/08/03 13:29:13
@@ -1,7 +1,7 @@
 #compdef -k complete-word \C-xh
 
 _complete_help() {
-  setopt localoptions nullglob rcexpandparam extendedglob
+  setopt localoptions nullglob rcexpandparam extendedglob noshglob
   unsetopt markdirs globsubst shwordsplit nounset ksharrays
   exec </dev/null	# ZLE closes stdin, which can cause errors
 
Index: Completion/Commands/_correct_word
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Commands/_correct_word,v
retrieving revision 1.2
diff -u -r1.2 _correct_word
--- Completion/Commands/_correct_word	2000/06/07 06:47:40	1.2
+++ Completion/Commands/_correct_word	2000/08/03 13:29:13
@@ -7,7 +7,7 @@
 # If configurations keys with the prefix `correctword_' are
 # given they override those starting with `correct_'.
 
-setopt localoptions nullglob rcexpandparam extendedglob
+setopt localoptions nullglob rcexpandparam extendedglob noshglob
 unsetopt markdirs globsubst shwordsplit nounset ksharrays
 
 local curcontext="$curcontext"
Index: Completion/Commands/_expand_word
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Commands/_expand_word,v
retrieving revision 1.3
diff -u -r1.3 _expand_word
--- Completion/Commands/_expand_word	2000/06/07 06:47:40	1.3
+++ Completion/Commands/_expand_word	2000/08/03 13:29:13
@@ -2,7 +2,7 @@
 
 # Simple completion front-end implementing expansion.
 
-setopt localoptions nullglob rcexpandparam extendedglob
+setopt localoptions nullglob rcexpandparam extendedglob noshglob
 unsetopt markdirs globsubst shwordsplit nounset ksharrays
 
 local curcontext="$curcontext"
Index: Completion/Commands/_history_complete_word
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Commands/_history_complete_word,v
retrieving revision 1.6
diff -u -r1.6 _history_complete_word
--- Completion/Commands/_history_complete_word	2000/06/22 08:42:36	1.6
+++ Completion/Commands/_history_complete_word	2000/08/03 13:29:13
@@ -16,7 +16,7 @@
 #   range -- range of history words to complete
 
 _history_complete_word () {
-  setopt localoptions nullglob rcexpandparam extendedglob
+  setopt localoptions nullglob rcexpandparam extendedglob noshglob
   unsetopt markdirs globsubst shwordsplit nounset ksharrays
 
   local expl direction stop curcontext="$curcontext"
Index: Completion/Commands/_next_tags
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Commands/_next_tags,v
retrieving revision 1.8
diff -u -r1.8 _next_tags
--- Completion/Commands/_next_tags	2000/08/01 08:27:18	1.8
+++ Completion/Commands/_next_tags	2000/08/03 13:29:13
@@ -3,7 +3,7 @@
 # Main widget.
 
 _next_tags() {
-  setopt localoptions nullglob rcexpandparam extendedglob
+  setopt localoptions nullglob rcexpandparam extendedglob noshglob
   unsetopt markdirs globsubst shwordsplit nounset ksharrays
 
   local ins ops="$PREFIX$SUFFIX"
Index: Completion/Core/_expand
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_expand,v
retrieving revision 1.26
diff -u -r1.26 _expand
--- Completion/Core/_expand	2000/07/26 09:16:13	1.26
+++ Completion/Core/_expand	2000/08/03 13:29:13
@@ -63,7 +63,7 @@
       eval exp\=\( ${${(q)exp}:gs/\\{/\{/:gs/\\}/\}/} \)
   eval 'exp=( ${${(e)exp//\\[ 	
 ]/ }//(#b)([ 	
-])/\\$match[1]} )' 2>/dev/null
+\\])/\\$match[1]} )' 2>/dev/null
 else
   exp=( ${exp:s/\\\$/\$} )
 fi
@@ -77,7 +77,7 @@
 # Now try globbing.
 
 [[ "$force" = *g* ]] || zstyle -T ":completion:${curcontext}:" glob &&
-    eval 'exp=( ${~exp} )' 2>/dev/null
+    eval 'exp=( ${~exp} ); exp=( ${exp//(#b)([][()|*?^#~<>\\])/\\${match[1]}} )' 2>/dev/null
 
 # If we don't have any expansions or only one and that is the same
 # as the original string, we let other completers run.
Index: Completion/Core/_main_complete
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_main_complete,v
retrieving revision 1.39
diff -u -r1.39 _main_complete
--- Completion/Core/_main_complete	2000/07/27 10:59:44	1.39
+++ Completion/Core/_main_complete	2000/08/03 13:29:13
@@ -16,7 +16,7 @@
 # which makes the output of setopt and unsetopt reflect a different
 # state than the global one for which you are completing.
 
-setopt localoptions nullglob rcexpandparam extendedglob
+setopt localoptions nullglob rcexpandparam extendedglob noshglob
 unsetopt markdirs globsubst shwordsplit nounset ksharrays
 exec </dev/null	# ZLE closes stdin, which can cause errors
 
Index: Completion/Core/_path_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_path_files,v
retrieving revision 1.28
diff -u -r1.28 _path_files
--- Completion/Core/_path_files	2000/08/03 11:12:31	1.28
+++ Completion/Core/_path_files	2000/08/03 13:29:13
@@ -421,7 +421,7 @@
     # There are more components, so skip over the next components and make a
     # slash be added.
 
-    tmp1=( ${tmp1//(#b)([][()|*?^#~<>])/\\${match[1]}} )
+    tmp1=( ${tmp1//(#b)([][()|*?^#~<>\\])/\\${match[1]}} )
     tmp2="${(M)tpre##((.|..|)/)##}"
     if [[ -n "$tmp2" ]]; then
       skipped="/$tmp2"
Index: Completion/Core/compdump
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/compdump,v
retrieving revision 1.7
diff -u -r1.7 compdump
--- Completion/Core/compdump	2000/07/04 16:17:00	1.7
+++ Completion/Core/compdump	2000/08/03 13:29:13
@@ -14,7 +14,7 @@
 # to see if auto-dump should re-dump the dump-file.
 
 emulate -L zsh
-setopt extendedglob
+setopt extendedglob noshglob
 
 typeset _d_file _d_f _d_bks _d_line _d_als _d_files
 
Index: Src/glob.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/glob.c,v
retrieving revision 1.9
diff -u -r1.9 glob.c
--- Src/glob.c	2000/06/02 10:09:13	1.9
+++ Src/glob.c	2000/08/03 13:29:14
@@ -2388,6 +2388,7 @@
 	case ')':
 	    if (isset(SHGLOB))
 		break;
+	case '>':
 	case '^':
 	case '#':
 	case '~':
Index: Src/Modules/parameter.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/parameter.c,v
retrieving revision 1.13
diff -u -r1.13 parameter.c
--- Src/Modules/parameter.c	2000/08/02 14:20:42	1.13
+++ Src/Modules/parameter.c	2000/08/03 13:29:15
@@ -1465,9 +1465,9 @@
 #endif
 	    if (!(val = getstrvalue(&v)) || *val != '/' ||
 #ifdef HAVE_PATHCONF
-		strlen(val) >= PATH_MAX)
-#else
                 ((strlen(val) >= pathmax)) && pathmax != -1)
+#else
+		strlen(val) >= PATH_MAX)
 #endif
 		zwarn("invalid value: %s", val, 0);
 	    else

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


             reply	other threads:[~2000-08-03 13:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-08-03 13:30 Sven Wischnowsky [this message]
2000-08-03 14:38 ` Clint Adams
2000-08-03 14:53   ` Clint Adams
2000-08-04 21:51 ` Tanaka Akira
2000-08-04  7:01 Sven Wischnowsky
2000-08-04  7:16 ` Bart Schaefer
2000-08-04  7:38   ` Bart Schaefer
2000-08-04 10:47   ` Andrej Borsenkow
2000-08-04 13:35     ` Clint Adams
2000-08-04  7:42 Sven Wischnowsky
2000-08-04 13:38 ` Clint Adams

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=200008031330.PAA22832@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.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).