zsh-workers
 help / color / mirror / code / Atom feed
* BARE_GLOB_QUAL
       [not found]                       ` <20011005172343.A2872@fysh.org>
@ 2001-10-05 16:45                         ` Bart Schaefer
  2001-10-05 16:56                           ` BARE_GLOB_QUAL Zefram
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2001-10-05 16:45 UTC (permalink / raw)
  To: zsh-workers

On Oct 5,  5:23pm, Zefram wrote:
}
} Bart Schaefer wrote:
} >Should we make BARE_GLOB_QUAL a bit smarter so that it knows about
} >KSH_GLOB and looks back one more character to see if what precedes the
} >open-paren token is one of the ksh-glob-chars?
} 
} With your proposed change, you'd have to think about the opposite
} ambiguity too -- a set of glob qualifiers might be interpreted as part of
} a pattern, and you'd sometimes need extra effort to force interpretation
} as glob qualifiers.  I recommend sticking with the current, simpler, rule.

That sounds fine to me.  In that case the doc for one or both of KSH_GLOB
and BARE_GLOB_QUAL should mention this.

} This is why we made the BARE_GLOB_QUAL option -- we wanted an unambiguous
} syntax for glob qualifiers, that wouldn't get in the way of globbing
} syntax at all.  Unfortunately no one's yet come up with a really good
} suggestion.

Hm.  We're using (#x) for various values of x to introduce things like
approximate completion, case-insensitive matching, and backrefs.  How
about (#q...) for qualifiers?  Also (#Q-) could turn off BARE_GLOB_QUAL,
and (#Q+) could turn it on.  (I can't decide which of those just (#Q)
should do.)

That would introduce the possibility of having different qualifiers for
different parts of the glob pattern, e.g. `*(#qG)/*(#q.^G)' would list
all plain files not owned by the current effective group that are in
directories that are owned by the current effective group.

Although implementation of that latter suggestion might be rather hairy.
For now, all (#q...) should simply be gathered up and applied at the end
as if they appeared in a single list.

-- 
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   


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: BARE_GLOB_QUAL
  2001-10-05 16:45                         ` BARE_GLOB_QUAL Bart Schaefer
@ 2001-10-05 16:56                           ` Zefram
  2001-10-05 17:20                             ` BARE_GLOB_QUAL Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Zefram @ 2001-10-05 16:56 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

Bart Schaefer wrote:
>Hm.  We're using (#x) for various values of x to introduce things like
>approximate completion, case-insensitive matching, and backrefs.  How
>about (#q...) for qualifiers?

Ah, that only works when EXTENDED_GLOB is on -- AIR, we wanted a syntax
that would work without EXTENDED_GLOB.  However, on thinking about
it now, I don't see any pressing need for that.  It seems reasonable
to have a system where the BARE_GLOB_QUAL option provides access
to an EXTENDED_GLOB feature in non-EXTENDED_GLOB globbing syntaxes.
(#q...) looks like a good choice.

>                               Also (#Q-) could turn off BARE_GLOB_QUAL,
>and (#Q+) could turn it on.  (I can't decide which of those just (#Q)
>should do.)

That's silly.  "(#Q+)" is a lot more characters than just adding "#q"
at the beginning of the qualifiers group.  Similarly, "(#Q-)" is more
typing than adding an extra pair of parens around the non-qualifier group.

We should just have "(#q...)" for qualifiers, and encourage people to
turn off BARE_GLOB_QUAL.

>That would introduce the possibility of having different qualifiers for
>different parts of the glob pattern, e.g. `*(#qG)/*(#q.^G)' would list
>all plain files not owned by the current effective group that are in
>directories that are owned by the current effective group.

That's a neat idea, but, as you say, hairy.

>For now, all (#q...) should simply be gathered up and applied at the end
>as if they appeared in a single list.

No.  To retain upward compatibility with the hairy idea, qualifiers
embedded within a pattern should be an error.  We should require
qualifiers to appear at the end, where they'll still mean the same thing
when we do implement embedded qualifiers.

-zefram


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: BARE_GLOB_QUAL
  2001-10-05 16:56                           ` BARE_GLOB_QUAL Zefram
@ 2001-10-05 17:20                             ` Bart Schaefer
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2001-10-05 17:20 UTC (permalink / raw)
  To: zsh-workers

On Oct 5,  5:56pm, Zefram wrote:
}
} >                               Also (#Q-) could turn off BARE_GLOB_QUAL,
} >and (#Q+) could turn it on.  (I can't decide which of those just (#Q)
} >should do.)
} 
} That's silly.  "(#Q+)" is a lot more characters than just adding "#q"
} at the beginning of the qualifiers group.  Similarly, "(#Q-)" is more
} typing than adding an extra pair of parens around the non-qualifier group.

I wasn't thinking of typing them.  I was thinking of e.g. the completion
function system, where it wants to (in shell code) build complex patterns
from user input plus things it adds on its own.  It might be useful for
it to be able to turn on qualfiers for some sections of the pattern, and
then turn them off in a section where it wanted to append other stuff.
This might reduce the need to parse the user input and try to figure out 
how to merge it with other qualifiers.

} >For now, all (#q...) should simply be gathered up and applied at the end
} >as if they appeared in a single list.
} 
} No.  To retain upward compatibility with the hairy idea, qualifiers
} embedded within a pattern should be an error.  We should require
} qualifiers to appear at the end, where they'll still mean the same thing
} when we do implement embedded qualifiers.

That would be OK, but it'd have to work to use (#qG)(#q.) etc. at the
end -- and, again thinking of the completion system, in an expression
such as `*(.)(#qG)' there's the issue of whether (.) is a qualifier.

-- 
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   


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: compctl -g not working
       [not found]                     ` <1011005161336.ZM32521@candle.brasslantern.com>
       [not found]                       ` <20011005172343.A2872@fysh.org>
@ 2001-10-08 12:31                       ` Sven Wischnowsky
  2001-10-14  1:45                         ` Bart Schaefer
  1 sibling, 1 reply; 5+ messages in thread
From: Sven Wischnowsky @ 2001-10-08 12:31 UTC (permalink / raw)
  To: zsh-workers


[ moved to -workers ]

Bart Schaefer wrote:

> ...
> 
> The reason that "some other places" does not include `compctl -s' is
> because -s actually *does* pass the string through the lexer again,
> whereas -g passes it only through the tokenizer.
> 
> So the questions (hey, zsh-workers) are:
> 
> Should we fix `compctl -g' so that it behaves like "ordinary" globbing?
> (I have a suggested implementation that I won't go into here.)

Would be fine with me. (I really don't care about compctl anymore ;-)

> Should we make BARE_GLOB_QUAL a bit smarter so that it knows about
> KSH_GLOB and looks back one more character to see if what precedes the
> open-paren token is one of the ksh-glob-chars?  (It already treats a
> `|' inside the parens as indicative of a glob alternation rather than
> a list of qualifiers.)

I'm with Zefram here.


Bye
  Sven

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: compctl -g not working
  2001-10-08 12:31                       ` compctl -g not working Sven Wischnowsky
@ 2001-10-14  1:45                         ` Bart Schaefer
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2001-10-14  1:45 UTC (permalink / raw)
  To: zsh-workers

On Oct 8,  2:31pm, Sven Wischnowsky wrote:
} Subject: Re: compctl -g not working
}
} [ moved to -workers ]
} 
} Bart Schaefer wrote:
} 
} > Should we fix `compctl -g' so that it behaves like "ordinary" globbing?
} > (I have a suggested implementation that I won't go into here.)
} 
} Would be fine with me. (I really don't care about compctl anymore ;-)

This affects compcore as well, though, and everywhere else that zsh uses
tokenize().  That doesn't affect compsys much because we force SH_GLOB
off via $_comp_options, but it could affect other completion widgets.

Here's a patch for consideration.  It renames tokenize() as shtokenize(),
and then makes tokenize() a wrapper for shtokenize() that always turns
off SH_GLOB.  Then shtokenize() is called selectively in the places where
(as best I can tell) we really want SH_GLOB behavior to apply.

Obviously this is a little inefficient, since tokenize() is used a lot
more often than shtokenize().  There are several ways to improve this,
but this way lets us test the new behavior with a minimum of rewriting.

Of course, you shouldn't see any change in behavior unless you were using
SH_GLOB in the first place ...

Index: Src/exec.c
--- zsh-forge/current/Src/exec.c	Thu Oct 11 11:11:07 2001
+++ zsh-4.0/Src/exec.c	Sat Oct 13 12:58:11 2001
@@ -2794,7 +2794,7 @@
 
 	while (*words) {
 	    if (isset(GLOBSUBST))
-		tokenize(*words);
+		shtokenize(*words);
 	    addlinknode(ret, *words++);
 	}
     }
Index: Src/glob.c
--- zsh-forge/current/Src/glob.c	Mon Oct  8 03:04:01 2001
+++ zsh-4.0/Src/glob.c	Sat Oct 13 12:57:27 2001
@@ -2329,6 +2329,16 @@
 mod_export void
 tokenize(char *s)
 {
+    char shglob = opts[SHGLOB];
+    opts[SHGLOB] = 0;
+    shtokenize(s);
+    opts[SHGLOB] = shglob;
+}
+
+/**/
+mod_export void
+shtokenize(char *s)
+{
     char *t;
     int bslash = 0;
 
Index: Src/subst.c
--- zsh-forge/current/Src/subst.c	Mon Oct  8 03:04:01 2001
+++ zsh-4.0/Src/subst.c	Sat Oct 13 12:58:13 2001
@@ -190,7 +190,7 @@
 		continue;
 	    }
 	    if (!qt && ssub && isset(GLOBSUBST))
-		tokenize(s);
+		shtokenize(s);
 	    l1 = str2 - str3;
 	    l2 = strlen(s);
 	    if (nonempty(pl)) {
@@ -441,14 +441,14 @@
     if (!pl && (!s || !*s)) {
 	*d = dest = (copied ? src : dupstring(src));
 	if (glbsub)
-	    tokenize(dest);
+	    shtokenize(dest);
     } else {
 	*d = dest = hcalloc(pl + l + (s ? strlen(s) : 0) + 1);
 	strncpy(dest, pb, pl);
 	dest += pl;
 	strcpy(dest, src);
 	if (glbsub)
-	    tokenize(dest);
+	    shtokenize(dest);
 	dest += l;
 	if (s)
 	    strcpy(dest, s);
@@ -1509,7 +1509,7 @@
 		if (!quoteerr) {
 		    errflag = oef;
 		    if (haserr)
-			tokenize(s);
+			shtokenize(s);
 		} else if (haserr || errflag) {
 		    zerr("parse error in ${...%c...} substitution",
 			 NULL, s[-1]);
@@ -1955,7 +1955,7 @@
 		else {
 		    y = dupstring(x);
 		    if (globsubst)
-			tokenize(y);
+			shtokenize(y);
 		}
 		insertlinknode(l, n, (void *) y), incnode(n);
 	    }

-- 
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   


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-10-14  1:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20011002225307.A13954@astaroth.sweth.net>
     [not found] ` <87adz976ru.fsf@ceramic.fifi.org>
     [not found]   ` <20011002231841.B14325@astaroth.sweth.net>
     [not found]     ` <1011003040449.ZM25370@candle.brasslantern.com>
     [not found]       ` <20011003001256.B14675@astaroth.sweth.net>
     [not found]         ` <1011003060441.ZM25764@candle.brasslantern.com>
     [not found]           ` <20011003021524.A15356@astaroth.sweth.net>
     [not found]             ` <1011003162422.ZM29481@candle.brasslantern.com>
     [not found]               ` <20011003142330.A16765@astaroth.sweth.net>
     [not found]                 ` <1011004042305.ZM30162@candle.brasslantern.com>
     [not found]                   ` <20011004004307.C18930@astaroth.sweth.net>
     [not found]                     ` <1011005161336.ZM32521@candle.brasslantern.com>
     [not found]                       ` <20011005172343.A2872@fysh.org>
2001-10-05 16:45                         ` BARE_GLOB_QUAL Bart Schaefer
2001-10-05 16:56                           ` BARE_GLOB_QUAL Zefram
2001-10-05 17:20                             ` BARE_GLOB_QUAL Bart Schaefer
2001-10-08 12:31                       ` compctl -g not working Sven Wischnowsky
2001-10-14  1:45                         ` Bart Schaefer

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).