zsh-workers
 help / color / mirror / code / Atom feed
* Bug
@ 1996-06-20 15:26 Ray Van_Tassle
  0 siblings, 0 replies; 8+ messages in thread
From: Ray Van_Tassle @ 1996-06-20 15:26 UTC (permalink / raw)
  To: expansion, filename, in, zsh-workers

I do this:
>ls zz*                                                                  ~/temp
zzayy  zzbyy  zzxyy
>ls zz(a|b)yy                                                            ~/temp
zzayy  zzbyy
>ls zz^(a|b)yy                                                           ~/temp
zsh: no match

Seems wrong.  According to the man pages, the 2nd command should give me
the files that start with "zz", then have either "a" or "b", and end with "yy".
OK.
But the 3rd command should give me the files that start with "zz", then have
a character OTHER than "a" or "b", and end with "yy".
It should give me "zzxyy", but it doesn't.

This is with zsh-2.6-beta20

Thanks,
Ray Van Tassle
rayvt@comm.mot.com



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

* Re: bug
  2011-12-21  3:05 ` bug Bart Schaefer
@ 2011-12-21 22:32   ` Peter Stephenson
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Stephenson @ 2011-12-21 22:32 UTC (permalink / raw)
  To: zsh-workers

On Tue, 20 Dec 2011 19:05:11 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Dec 20,  6:08pm, Ray Andrews wrote:
> }
> } function z
> } {
> } var=$1
> } echo "var:/${1:0:1}/${1:1:1}/${1:2:1}/"
> } }
> } 
> } $ z abcde
> } var: /a/a/b/
> 
>      For further compatibility with other shells there is a special case
>      for array offset 0.  This usually accesses to the first element of
>      the array.  However, if the substitution refers the positional
>      parameter array, e.g. $@ or $*, then offset 0 instead refers to
>      $0, offset 1 refers to $1, and so on.  In other words, the
>      positional parameter array is effectively extended by prepending
>      $0.  Hence ${*:0:1} substitutes $0 and ${*:1:1} substitutes $1.
> 
> So :0:1 is acting on the invisible $0 even though the reference is to
> an individual positional parameter rather than to the positional array.

Yes, it should only be doing that for array values.

Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.129
diff -p -u -r1.129 subst.c
--- Src/subst.c	28 Nov 2011 09:48:22 -0000	1.129
+++ Src/subst.c	21 Dec 2011 22:31:35 -0000
@@ -2878,24 +2878,26 @@ paramsubst(LinkList l, LinkNode n, char 
 			    return NULL;
 		    }
 		}
-		if (horrible_offset_hack) {
-		    /*
-		     * As part of the 'orrible hoffset 'ack,
-		     * (what hare you? Han 'orrible hoffset 'ack,
-		     * sergeant major), if we are given a ksh/bash/POSIX
-		     * style positional parameter array which includes
-		     * offset 0, we use $0.
-		     */
-		    if (offset == 0 && isarr) {
-			offset_hack_argzero = 1;
-		    } else if (offset > 0) {
-			offset--;
-		    }
-		}
 		if (isarr) {
-		    int alen = arrlen(aval), count;
+		    int alen, count;
 		    char **srcptr, **dstptr, **newarr;
 
+		    if (horrible_offset_hack) {
+			/*
+			 * As part of the 'orrible hoffset 'ack,
+			 * (what hare you? Han 'orrible hoffset 'ack,
+			 * sergeant major), if we are given a ksh/bash/POSIX
+			 * style positional parameter array which includes
+			 * offset 0, we use $0.
+			 */
+			if (offset == 0) {
+			    offset_hack_argzero = 1;
+			} else if (offset > 0) {
+			    offset--;
+			}
+		    }
+
+		    alen = arrlen(aval);
 		    if (offset < 0) {
 			offset += alen;
 			if (offset < 0)


-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


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

* Re: bug
  2011-12-21  2:08 bug Ray Andrews
@ 2011-12-21  3:05 ` Bart Schaefer
  2011-12-21 22:32   ` bug Peter Stephenson
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2011-12-21  3:05 UTC (permalink / raw)
  To: zsh-workers

On Dec 20,  6:08pm, Ray Andrews wrote:
}
} function z
} {
} var=$1
} echo "var:/${1:0:1}/${1:1:1}/${1:2:1}/"
} echo "var:/${var:0:1}/${var:1:1}/${var:2:1}/"
} 
} }
} 
} $ z abcde
} 
} var: /a/a/b/
} var: /a/b/c/
} 
} How can that be correct?

I'm still not sure it's correct, but this explains why it happens:

     For further compatibility with other shells there is a special case
     for array offset 0.  This usually accesses to the first element of
     the array.  However, if the substitution refers the positional
     parameter array, e.g. $@ or $*, then offset 0 instead refers to
     $0, offset 1 refers to $1, and so on.  In other words, the
     positional parameter array is effectively extended by prepending
     $0.  Hence ${*:0:1} substitutes $0 and ${*:1:1} substitutes $1.

So :0:1 is acting on the invisible $0 even though the reference is to
an individual positional parameter rather than to the positional array.


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

* bug
@ 2011-12-21  2:08 Ray Andrews
  2011-12-21  3:05 ` bug Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Ray Andrews @ 2011-12-21  2:08 UTC (permalink / raw)
  To: zsh-workers


function z
{
var=$1
echo "var:/${1:0:1}/${1:1:1}/${1:2:1}/"
echo "var:/${var:0:1}/${var:1:1}/${var:2:1}/"

}

$ z abcde

var: /a/a/b/
var: /a/b/c/

How can that be correct?


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

* Re: BUG
@ 1999-08-20  8:17 Sven Wischnowsky
  0 siblings, 0 replies; 8+ messages in thread
From: Sven Wischnowsky @ 1999-08-20  8:17 UTC (permalink / raw)
  To: zsh-workers; +Cc: Brian Harvell


Brian Harvell wrote:

> > I guess you are using the complist module (probably statically linked
> > in?). Then the `$<2>' strings would either come from the value of
> > ZLS_COLORS or ZLS_COLOURS if one of them is set, or -- more probably,
> > as I think you don't have them set -- it would come zsh's attempt to
> > find out the terminal code for end-of-standout-mode.
> 
> Yes I am using complist and I don't have any of the color stuff set. It is 
> related to the term since it only happens when the term is set to vt100 (vt220
> and xterm seem fine)

I still suspect a broken term{cap,info} entry, although...

> > Could you tell us what `print -P "%s"' gives you? If it gives you
> > `$<2>' then it is indeed that zsh thinks that this is the terminal
> > code mentioned above. If you get something different and you don't
> > have any of those parameters set, it must be something else -- and I
> > don't know what.
> > 
> 
> print -P "%s" just prints a blank line.

...this irritates me (but `print -P' may print delay characters as far 
as I remember, while complist doesn't, maybe it's this what makes the
difference).

We could try the patch below...

Does this work? Do you need to set your TERM to vt100, or can you live
with the working xterm/vt220?

Bye
 Sven

diff -u os/Zle/complist.c Src/Zle/complist.c
--- os/Zle/complist.c	Thu Aug 19 16:00:04 1999
+++ Src/Zle/complist.c	Fri Aug 20 10:14:29 1999
@@ -194,13 +194,17 @@
     }
 }
 
+/* Combined length of LC and RC, maximum length of capability strings. */
+
+static int lr_caplen, max_caplen;
+
 /* This initializes the given terminal color structure. */
 
 static void
 getcols(Listcols c)
 {
     char *s;
-    int i;
+    int i, l;
 
     if (!(s = getsparam("ZLS_COLORS")) &&
 	!(s = getsparam("ZLS_COLOURS"))) {
@@ -222,9 +226,15 @@
 	s = getcoldef(c, s);
 
     /* Use default values for those that aren't set explicitly. */
-    for (i = 0; i < NUM_COLS; i++)
+    max_caplen = lr_caplen = 0;
+    for (i = 0; i < NUM_COLS; i++) {
 	if (!c->cols[i])
 	    c->cols[i] = defcols[i];
+	if ((l = (c->cols[i] ? strlen(c->cols[i]) : 0)) > max_caplen)
+	    max_caplen = l;
+    }
+    lr_caplen = strlen(c->cols[COL_LC]) + strlen(c->cols[COL_RC]);
+
     /* Default for missing files. */
     if (!c->cols[COL_MI])
 	c->cols[COL_MI] = c->cols[COL_FI];
@@ -235,14 +245,24 @@
 static int last_col = COL_NO;
 
 static void
+zlrputs(Listcols c, char *cap)
+{
+    VARARR(char, buf, lr_caplen + max_caplen + 1);
+
+    strcpy(buf, c->cols[COL_LC]);
+    strcat(buf, cap);
+    strcat(buf, c->cols[COL_RC]);
+
+    tputs(buf, 1, putshout);
+}
+
+static void
 zcputs(Listcols c, int colour)
 {
     if (colour != last_col
 	&& (last_col < COL_NO
 	    || strcmp(c->cols[last_col], c->cols[colour]))) {
-	fputs(c->cols[COL_LC], shout);
-	fputs(c->cols[colour], shout);
-	fputs(c->cols[COL_RC], shout);
+	zlrputs(c, c->cols[colour]);
 	last_col = colour;
     }
     return;
@@ -260,11 +280,9 @@
     for (e = c->exts; e; e = e->next)
 	if (strsfx(e->ext, n)) {	/* XXX: unoptimised if used */
 	    if (last_col < COL_NO
-		|| strcmp(c->cols[last_col], e->col)) {
-		fputs(c->cols[COL_LC], shout);
-		fputs(e->col, shout);
-		fputs(c->cols[COL_RC], shout);
-	    }
+		|| strcmp(c->cols[last_col], e->col))
+		zlrputs(c, e->col);
+
 	    last_col = COL_NO - 1;
 	    return;
 	}
@@ -565,7 +583,7 @@
 			while (a--)
 			    putc(' ', shout);
 			if (col.cols[COL_EC])
-			    fputs(col.cols[COL_EC], shout);
+			    tputs(col.cols[COL_EC], 1, putshout);
 			else
 			    zcputs(&col, COL_NO);
 			break;
@@ -614,14 +632,14 @@
 		    while (a--)
 			putc(' ', shout);
 		    if (col.cols[COL_EC])
-			fputs(col.cols[COL_EC], shout);
+			tputs(col.cols[COL_EC], 1, putshout);
 		    else
 			zcputs(&col, COL_NO);
 		    if (i) {
 			zcputs(&col, COL_NO);
 			fputs("  ", shout);
 			if (col.cols[COL_EC])
-			    fputs(col.cols[COL_EC], shout);
+			    tputs(col.cols[COL_EC], 1, putshout);
 			else
 			    zcputs(&col, COL_NO);
 		    }
@@ -636,7 +654,7 @@
 		    while (a--)
 			putc(' ', shout);
 		    if (col.cols[COL_EC])
-			fputs(col.cols[COL_EC], shout);
+			tputs(col.cols[COL_EC], 1, putshout);
 		    else
 			zcputs(&col, COL_NO);
 		}

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


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

* Re: BUG
  1999-08-19  7:16 BUG Sven Wischnowsky
@ 1999-08-19 15:32 ` Brian Harvell
  0 siblings, 0 replies; 8+ messages in thread
From: Brian Harvell @ 1999-08-19 15:32 UTC (permalink / raw)
  To: Sven Wischnowsky; +Cc: zsh-workers

On Thu, 19 Aug 1999, Sven Wischnowsky wrote:

> 
> Brian Harvell wrote:
> 
> > When I hit tab I see the following in 3.1.6. This does not happen with 3.1.5
> > 
> > TT_DB/     $<2>  $<2>dev/       $<2>  $<2>floppy/    $<2>  $<2>lost+found/$<2>  $<2>opt/       $<2>  $<2>tmp/       $<2>  $<2>           $<2>
> > WS.tar     $<2>  $<2>devices/   $<2>  $<2>foo/       $<2>  $<2>mail/      $<2>  $<2>platform/  $<2>  $<2>usr/       $<2>  $<2>           $<2>
> > bin@       $<2>  $<2>e/         $<2>  $<2>home/      $<2>  $<2>mnt/       $<2>  $<2>prefs      $<2>  $<2>var/       $<2>  $<2>           $<2>
> > cdrom/     $<2>  $<2>etc/       $<2>  $<2>kernel/    $<2>  $<2>net/       $<2>  $<2>proc/      $<2>  $<2>vol/       $<2>  $<2>           $<2>
> > data/      $<2>  $<2>export/    $<2>  $<2>lib@       $<2>  $<2>ogp@       $<2>  $<2>sbin/      $<2>  $<2>xfn/       $<2>  $<2>           $<2>
> 
> Some more information would have been nice...

Sorry.

> I guess you are using the complist module (probably statically linked
> in?). Then the `$<2>' strings would either come from the value of
> ZLS_COLORS or ZLS_COLOURS if one of them is set, or -- more probably,
> as I think you don't have them set -- it would come zsh's attempt to
> find out the terminal code for end-of-standout-mode.

Yes I am using complist and I don't have any of the color stuff set. It is 
related to the term since it only happens when the term is set to vt100 (vt220
and xterm seem fine)

> Could you tell us what `print -P "%s"' gives you? If it gives you
> `$<2>' then it is indeed that zsh thinks that this is the terminal
> code mentioned above. If you get something different and you don't
> have any of those parameters set, it must be something else -- and I
> don't know what.
> 

print -P "%s" just prints a blank line.

Brian


Brian Harvell                harvell@aol.net             http://ToolBoy.com/
echo '[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq'|dc




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

* Re: BUG
@ 1999-08-19  7:16 Sven Wischnowsky
  1999-08-19 15:32 ` BUG Brian Harvell
  0 siblings, 1 reply; 8+ messages in thread
From: Sven Wischnowsky @ 1999-08-19  7:16 UTC (permalink / raw)
  To: zsh-workers; +Cc: Brian Harvell


Brian Harvell wrote:

> When I hit tab I see the following in 3.1.6. This does not happen with 3.1.5
> 
> TT_DB/     $<2>  $<2>dev/       $<2>  $<2>floppy/    $<2>  $<2>lost+found/$<2>  $<2>opt/       $<2>  $<2>tmp/       $<2>  $<2>           $<2>
> WS.tar     $<2>  $<2>devices/   $<2>  $<2>foo/       $<2>  $<2>mail/      $<2>  $<2>platform/  $<2>  $<2>usr/       $<2>  $<2>           $<2>
> bin@       $<2>  $<2>e/         $<2>  $<2>home/      $<2>  $<2>mnt/       $<2>  $<2>prefs      $<2>  $<2>var/       $<2>  $<2>           $<2>
> cdrom/     $<2>  $<2>etc/       $<2>  $<2>kernel/    $<2>  $<2>net/       $<2>  $<2>proc/      $<2>  $<2>vol/       $<2>  $<2>           $<2>
> data/      $<2>  $<2>export/    $<2>  $<2>lib@       $<2>  $<2>ogp@       $<2>  $<2>sbin/      $<2>  $<2>xfn/       $<2>  $<2>           $<2>

Some more information would have been nice...

I guess you are using the complist module (probably statically linked
in?). Then the `$<2>' strings would either come from the value of
ZLS_COLORS or ZLS_COLOURS if one of them is set, or -- more probably,
as I think you don't have them set -- it would come zsh's attempt to
find out the terminal code for end-of-standout-mode.

Of course, I don't get it, so all this is guessing.

Could you tell us what `print -P "%s"' gives you? If it gives you
`$<2>' then it is indeed that zsh thinks that this is the terminal
code mentioned above. If you get something different and you don't
have any of those parameters set, it must be something else -- and I
don't know what.

Bye
 Sven


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


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

* BUG
@ 1999-08-19  2:51 Brian Harvell
  0 siblings, 0 replies; 8+ messages in thread
From: Brian Harvell @ 1999-08-19  2:51 UTC (permalink / raw)
  To: zsh-workers


When I hit tab I see the following in 3.1.6. This does not happen with 3.1.5

TT_DB/     $<2>  $<2>dev/       $<2>  $<2>floppy/    $<2>  $<2>lost+found/$<2>  $<2>opt/       $<2>  $<2>tmp/       $<2>  $<2>           $<2>
WS.tar     $<2>  $<2>devices/   $<2>  $<2>foo/       $<2>  $<2>mail/      $<2>  $<2>platform/  $<2>  $<2>usr/       $<2>  $<2>           $<2>
bin@       $<2>  $<2>e/         $<2>  $<2>home/      $<2>  $<2>mnt/       $<2>  $<2>prefs      $<2>  $<2>var/       $<2>  $<2>           $<2>
cdrom/     $<2>  $<2>etc/       $<2>  $<2>kernel/    $<2>  $<2>net/       $<2>  $<2>proc/      $<2>  $<2>vol/       $<2>  $<2>           $<2>
data/      $<2>  $<2>export/    $<2>  $<2>lib@       $<2>  $<2>ogp@       $<2>  $<2>sbin/      $<2>  $<2>xfn/       $<2>  $<2>           $<2>

Brian



Brian Harvell                harvell@aol.net             http://ToolBoy.com/
echo '[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq'|dc




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

end of thread, other threads:[~2011-12-21 22:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-06-20 15:26 Bug Ray Van_Tassle
1999-08-19  2:51 BUG Brian Harvell
1999-08-19  7:16 BUG Sven Wischnowsky
1999-08-19 15:32 ` BUG Brian Harvell
1999-08-20  8:17 BUG Sven Wischnowsky
2011-12-21  2:08 bug Ray Andrews
2011-12-21  3:05 ` bug Bart Schaefer
2011-12-21 22:32   ` bug Peter Stephenson

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