zsh-workers
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* zsh regards reserved word as candidate for alias substitution
@ 2009-02-25  0:17  4% Vincent Lefevre
  2009-03-03 17:23  0% ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Vincent Lefevre @ 2009-02-25  0:17 UTC (permalink / raw)
  To: zsh-workers

I've reported the following bug on

  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=516998

POSIX.1-2008 says[*]:

  2.3.1 Alias Substitution
  [...] However, reserved words in correct grammatical context
  shall not be candidates for alias substitution.

[*] http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_03_01

but zsh gives:

vin% emulate sh
vin% alias !="echo OK"
vin% ! foo
OK foo
vin% 

instead of running command "foo". ksh93, pdksh, dash and bash
in POSIX mode all behave correctly.

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)


^ permalink raw reply	[relevance 4%]

* PATCH: add -t <fmt> option to history
@ 2009-02-26 15:52  1% Peter Stephenson
       [not found]     ` <20090226163512.GA5181@sc.homeunix.net>
  0 siblings, 1 reply; 200+ results
From: Peter Stephenson @ 2009-02-26 15:52 UTC (permalink / raw)
  To: Zsh hackers list

I needed a new strftime extension for months without a leading blank or
zero; does anyone know if %N is used elsewhere as an extension (it's not
in POSIX)?

Index: Doc/Zsh/builtins.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v
retrieving revision 1.120
diff -u -r1.120 builtins.yo
--- Doc/Zsh/builtins.yo	12 Feb 2009 09:56:26 -0000	1.120
+++ Doc/Zsh/builtins.yo	26 Feb 2009 15:49:40 -0000
@@ -484,7 +484,9 @@
 findex(fc)
 cindex(history, editing)
 cindex(editing history)
-xitem(tt(fc) [ tt(-e) var(ename) ] [ tt(-nlrdDfEim) ] [ var(old)tt(=)var(new) ... ] [ var(first) [ var(last) ] ])
+xitem(tt(fc) [ tt(-e) var(ename) ] [ tt(-m) var(match) ] [ var(old)tt(=)var(new) ... ] [ var(first) [ var(last) ] ])
+xitem(tt(fc) tt(-l) [ tt(-nrdfEiD) ] [ tt(-t) var(timefmt) ] [ tt(-m) var(match) ])
+xitem(      [ var(old)tt(=)var(new) ... ] [ var(first) [ var(last) ] ])
 xitem(tt(fc) tt(-p) [ tt(-a) ] [ var(filename) [ var(histsize) [ var(savehistsize) ] ] ])
 xitem(tt(fc) tt(-P))
 item(tt(fc) tt(-ARWI) [ var(filename) ])(
@@ -517,13 +519,26 @@
 
 The flag tt(-r) reverses the order of the commands and the
 flag tt(-n) suppresses command numbers when listing.
-Also when listing, tt(-d) prints timestamps for each command, and
-tt(-f) prints full time-date stamps.  Adding the tt(-E) flag
-causes the dates to be printed as `var(dd)tt(.)var(mm)tt(.)var(yyyy)',
-instead of the default `var(mm)tt(/)var(dd)tt(/)var(yyyy)'.
-Adding the tt(-i) flag causes the dates to be printed in ISO8601
-`var(yyyy)tt(-)var(mm)tt(-)var(dd)' format.
-With the tt(-D) flag, tt(fc) prints elapsed times.
+
+Also when listing,
+startsitem()
+sitem(tt(-d))(prints timestamps for each command)
+sitem(tt(-f))(prints full time-date stamps in the US
+`var(MM)tt(/)var(DD)tt(/)var(YY) var(hh):var(mm)' format)
+sitem(tt(-E))(prints full time-date stamps in the European
+`var(dd)tt(.)var(mm)tt(.)var(yyyy) var(hh):var(mm)' format)
+sitem(tt(-i))(prints full time-date stamps in ISO8601
+`var(yyyy)tt(-)var(mm)tt(-)var(dd) var(hh):var(mm)' format)
+sitem(tt(-t) var(fmt))(prints time and date stamps in the given format;
+var(fmt) is formatted with the strftime function with the zsh extensions
+described for the tt(%D{)var(string)tt(}) prompt format in
+ifzman(the section EXPANSION OF PROMPT SEQUENCES in zmanref(zshmisc))\
+ifnzman(noderef(Prompt Expansion)).  The resulting formatted string must be
+no more than 256 characters or will not be printed.
+)
+sitem(tt(-D))(prints elapsed times; may be combined with one of the
+options above.)
+endsitem()
 
 cindex(history, stack)
 cindex(stack, history)
Index: Doc/Zsh/calsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/calsys.yo,v
retrieving revision 1.15
diff -u -r1.15 calsys.yo
--- Doc/Zsh/calsys.yo	10 Dec 2008 13:30:27 -0000	1.15
+++ Doc/Zsh/calsys.yo	26 Feb 2009 15:49:40 -0000
@@ -613,9 +613,11 @@
 kindex(date-format)
 item(tt(date-format))(
 A tt(strftime) format string (see manref(strftime)(3)) with the zsh
-extensions tt(%f) for a day of the month with no leading zero or space
-for single digits, and tt(%k) or tt(%l) for the hour of the day on the 24-
-or 12-hour clock, again with no leading zero or space for single digits.
+extensions providing various numbers with no leading zero or space
+if the number is a single digit as described for the
+tt(%D{)var(string)tt(}) prompt format in
+ifzman(the section EXPANSION OF PROMPT SEQUENCES in zmanref(zshmisc))\
+ifnzman(noderef(Prompt Expansion)).
 
 This is used for outputting dates in tt(calendar), both to support
 the tt(-v) option and when adding recurring events back to the calendar
Index: Doc/Zsh/prompt.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/prompt.yo,v
retrieving revision 1.16
diff -u -r1.16 prompt.yo
--- Doc/Zsh/prompt.yo	16 Sep 2008 15:04:44 -0000	1.16
+++ Doc/Zsh/prompt.yo	26 Feb 2009 15:49:40 -0000
@@ -171,11 +171,16 @@
 )
 item(tt(%D{)var(string)tt(}))(
 var(string) is formatted using the tt(strftime) function.
-See manref(strftime)(3) for more details.  Three additional codes are
-available:  tt(%f) prints the day of the month, like tt(%e) but
-without any preceding space if the day is a single digit, and
-tt(%K)/tt(%L) correspond to tt(%k)/tt(%l) for the hour of the day
-(24/12 hour clock) in the same way.
+See manref(strftime)(3) for more details.  Various zsh
+extensions provide numbers with no leading zero or space
+if the number is a single digit:
+
+startsitem()
+sitem(tt(%f))(a day of the month)
+sitem(tt(%k))(the hour of the day on the 24-hour clock)
+sitem(tt(%l))(the hour of the day on the 12-hour clock)
+sitem(tt(%N))(the month where January is 1.)
+endsitem()
 )
 enditem()
 
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.221
diff -u -r1.221 builtin.c
--- Src/builtin.c	25 Feb 2009 10:24:01 -0000	1.221
+++ Src/builtin.c	26 Feb 2009 15:49:40 -0000
@@ -69,7 +69,7 @@
      * But that's actually not useful, so it's more consistent to
      * cause an error.
      */
-    BUILTIN("fc", 0, bin_fc, 0, -1, BIN_FC, "nlre:IRWAdDfEimpPa", NULL),
+    BUILTIN("fc", 0, bin_fc, 0, -1, BIN_FC, "aAdDe:EfiIlmnpPrRt:W", NULL),
     BUILTIN("fg", 0, bin_fg, 0, -1, BIN_FG, NULL, NULL),
     BUILTIN("float", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "E:%F:%HL:%R:%Z:%ghlprtux", "E"),
     BUILTIN("functions", BINF_PLUSOPTS, bin_functions, 0, -1, 0, "kmMtuUz", NULL),
@@ -81,7 +81,7 @@
     BUILTIN("hashinfo", 0, bin_hashinfo, 0, 0, 0, NULL, NULL),
 #endif
 
-    BUILTIN("history", 0, bin_fc, 0, -1, BIN_FC, "nrdDfEimpPa", "l"),
+    BUILTIN("history", 0, bin_fc, 0, -1, BIN_FC, "adDEfimnpPrt:", "l"),
     BUILTIN("integer", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "HL:%R:%Z:%ghi:%lprtux", "i"),
     BUILTIN("jobs", 0, bin_fg, 0, -1, BIN_JOBS, "dlpZrs", NULL),
     BUILTIN("kill", BINF_HANDLES_OPTS, bin_kill, 0, -1, 0, NULL, NULL),
@@ -1599,7 +1599,7 @@
 {
     int fclistdone = 0;
     zlong tmp;
-    char *s;
+    char *s, *tdfmt, *timebuf;
     Histent ent;
 
     /* reverse range if required */
@@ -1625,6 +1625,25 @@
 	return 1;
     }
 
+    if (OPT_ISSET(ops,'d') || OPT_ISSET(ops,'f') ||
+	OPT_ISSET(ops,'E') || OPT_ISSET(ops,'i') ||
+	OPT_ISSET(ops,'t')) {
+	if (OPT_ISSET(ops,'t')) {
+	    tdfmt = OPT_ARG(ops,'t');
+	} else if (OPT_ISSET(ops,'i')) {
+	    tdfmt = "%Y-%m-%d %H:%M";
+	} else if (OPT_ISSET(ops,'E')) {
+	    tdfmt = "%f.%N.%Y %H:%M";
+	} else if (OPT_ISSET(ops,'f')) {
+	    tdfmt = "%N/%f/%Y %H:%M";
+	} else {
+	    tdfmt = "%H:%M";
+	}
+	timebuf = zhalloc(256);
+    } else {
+	tdfmt = timebuf = NULL;
+    }
+
     for (;;) {
 	s = dupstring(ent->node.nam);
 	/* this if does the pattern matching, if required */
@@ -1641,24 +1660,11 @@
 	    }
 	    /* output actual time (and possibly date) of execution of the
 	       command, if required */
-	    if (OPT_ISSET(ops,'d') || OPT_ISSET(ops,'f') ||
-		OPT_ISSET(ops,'E') || OPT_ISSET(ops,'i')) {
+	    if (tdfmt != NULL) {
 		struct tm *ltm;
 		ltm = localtime(&ent->stim);
-		if (OPT_ISSET(ops,'i')) {
-		    fprintf(f, "%d-%02d-%02d ",
-			    ltm->tm_year + 1900,
-			    ltm->tm_mon + 1, ltm->tm_mday);
-		} else if (OPT_ISSET(ops,'E')) {
-		    fprintf(f, "%d.%d.%d ",
-			    ltm->tm_mday, ltm->tm_mon + 1,
-			    ltm->tm_year + 1900);
-		} else if (OPT_ISSET(ops,'f')) {
-		    fprintf(f, "%d/%d/%d ",
-			    ltm->tm_mon + 1, ltm->tm_mday,
-			    ltm->tm_year + 1900);
-		}
-		fprintf(f, "%02d:%02d  ", ltm->tm_hour, ltm->tm_min);
+		if (ztrftime(timebuf, 256, tdfmt, ltm))
+		    fprintf(f, "%s  ", timebuf);
 	    }
 	    /* display the time taken by the command, if required */
 	    if (OPT_ISSET(ops,'D')) {
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.209
diff -u -r1.209 utils.c
--- Src/utils.c	19 Feb 2009 10:15:10 -0000	1.209
+++ Src/utils.c	26 Feb 2009 15:49:40 -0000
@@ -2486,7 +2486,9 @@
 		*buf++ = '0' + (hr12 % 10);
 		break;
 	    case 'm':
-		*buf++ = '0' + (tm->tm_mon + 1) / 10;
+	    case 'N':
+		if (tm->tm_mon > 8 || fmt[-1] == 'm')
+		    *buf++ = '0' + (tm->tm_mon + 1) / 10;
 		*buf++ = '0' + (tm->tm_mon + 1) % 10;
 		break;
 	    case 'M':

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[relevance 1%]

* Re: PATCH: add -t <fmt> option to history
       [not found]     ` <20090226163512.GA5181@sc.homeunix.net>
@ 2009-02-26 17:15  0%   ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2009-02-26 17:15 UTC (permalink / raw)
  To: Zsh hackers list

On Thu, 26 Feb 2009 16:35:12 +0000
Stephane Chazelas <Stephane_Chazelas@yahoo.fr> wrote:
> On Thu, Feb 26, 2009 at 03:52:46PM +0000, Peter Stephenson wrote:
> > I needed a new strftime extension for months without a leading blank or
> > zero; does anyone know if %N is used elsewhere as an extension (it's not
> > in POSIX)?
> [...]
> 
> GNU strftime has %-<x> to remove the 0 padding, as in %-m.
> See
> info libc --index-search=strftime
> for more.

We might as well support that extension, so we don't need a new character.
I haven't bothered with the other extensions---it's hardly worth the effort
to support them natively, and if we don't we get more system dependent
behaviour than is really good for us.

Index: Doc/Zsh/builtins.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v
retrieving revision 1.120
diff -u -r1.120 builtins.yo
--- Doc/Zsh/builtins.yo	12 Feb 2009 09:56:26 -0000	1.120
+++ Doc/Zsh/builtins.yo	26 Feb 2009 17:13:20 -0000
@@ -484,7 +484,9 @@
 findex(fc)
 cindex(history, editing)
 cindex(editing history)
-xitem(tt(fc) [ tt(-e) var(ename) ] [ tt(-nlrdDfEim) ] [ var(old)tt(=)var(new) ... ] [ var(first) [ var(last) ] ])
+xitem(tt(fc) [ tt(-e) var(ename) ] [ tt(-m) var(match) ] [ var(old)tt(=)var(new) ... ] [ var(first) [ var(last) ] ])
+xitem(tt(fc) tt(-l) [ tt(-nrdfEiD) ] [ tt(-t) var(timefmt) ] [ tt(-m) var(match) ])
+xitem(      [ var(old)tt(=)var(new) ... ] [ var(first) [ var(last) ] ])
 xitem(tt(fc) tt(-p) [ tt(-a) ] [ var(filename) [ var(histsize) [ var(savehistsize) ] ] ])
 xitem(tt(fc) tt(-P))
 item(tt(fc) tt(-ARWI) [ var(filename) ])(
@@ -517,13 +519,26 @@
 
 The flag tt(-r) reverses the order of the commands and the
 flag tt(-n) suppresses command numbers when listing.
-Also when listing, tt(-d) prints timestamps for each command, and
-tt(-f) prints full time-date stamps.  Adding the tt(-E) flag
-causes the dates to be printed as `var(dd)tt(.)var(mm)tt(.)var(yyyy)',
-instead of the default `var(mm)tt(/)var(dd)tt(/)var(yyyy)'.
-Adding the tt(-i) flag causes the dates to be printed in ISO8601
-`var(yyyy)tt(-)var(mm)tt(-)var(dd)' format.
-With the tt(-D) flag, tt(fc) prints elapsed times.
+
+Also when listing,
+startsitem()
+sitem(tt(-d))(prints timestamps for each command)
+sitem(tt(-f))(prints full time-date stamps in the US
+`var(MM)tt(/)var(DD)tt(/)var(YY) var(hh):var(mm)' format)
+sitem(tt(-E))(prints full time-date stamps in the European
+`var(dd)tt(.)var(mm)tt(.)var(yyyy) var(hh):var(mm)' format)
+sitem(tt(-i))(prints full time-date stamps in ISO8601
+`var(yyyy)tt(-)var(mm)tt(-)var(dd) var(hh):var(mm)' format)
+sitem(tt(-t) var(fmt))(prints time and date stamps in the given format;
+var(fmt) is formatted with the strftime function with the zsh extensions
+described for the tt(%D{)var(string)tt(}) prompt format in
+ifzman(the section EXPANSION OF PROMPT SEQUENCES in zmanref(zshmisc))\
+ifnzman(noderef(Prompt Expansion)).  The resulting formatted string must be
+no more than 256 characters or will not be printed.
+)
+sitem(tt(-D))(prints elapsed times; may be combined with one of the
+options above.)
+endsitem()
 
 cindex(history, stack)
 cindex(stack, history)
Index: Doc/Zsh/calsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/calsys.yo,v
retrieving revision 1.15
diff -u -r1.15 calsys.yo
--- Doc/Zsh/calsys.yo	10 Dec 2008 13:30:27 -0000	1.15
+++ Doc/Zsh/calsys.yo	26 Feb 2009 17:13:20 -0000
@@ -613,9 +613,11 @@
 kindex(date-format)
 item(tt(date-format))(
 A tt(strftime) format string (see manref(strftime)(3)) with the zsh
-extensions tt(%f) for a day of the month with no leading zero or space
-for single digits, and tt(%k) or tt(%l) for the hour of the day on the 24-
-or 12-hour clock, again with no leading zero or space for single digits.
+extensions providing various numbers with no leading zero or space
+if the number is a single digit as described for the
+tt(%D{)var(string)tt(}) prompt format in
+ifzman(the section EXPANSION OF PROMPT SEQUENCES in zmanref(zshmisc))\
+ifnzman(noderef(Prompt Expansion)).
 
 This is used for outputting dates in tt(calendar), both to support
 the tt(-v) option and when adding recurring events back to the calendar
Index: Doc/Zsh/prompt.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/prompt.yo,v
retrieving revision 1.16
diff -u -r1.16 prompt.yo
--- Doc/Zsh/prompt.yo	16 Sep 2008 15:04:44 -0000	1.16
+++ Doc/Zsh/prompt.yo	26 Feb 2009 17:13:20 -0000
@@ -171,11 +171,23 @@
 )
 item(tt(%D{)var(string)tt(}))(
 var(string) is formatted using the tt(strftime) function.
-See manref(strftime)(3) for more details.  Three additional codes are
-available:  tt(%f) prints the day of the month, like tt(%e) but
-without any preceding space if the day is a single digit, and
-tt(%K)/tt(%L) correspond to tt(%k)/tt(%l) for the hour of the day
-(24/12 hour clock) in the same way.
+See manref(strftime)(3) for more details.  Various zsh
+extensions provide numbers with no leading zero or space
+if the number is a single digit:
+
+startsitem()
+sitem(tt(%f))(a day of the month)
+sitem(tt(%k))(the hour of the day on the 24-hour clock)
+sitem(tt(%l))(the hour of the day on the 12-hour clock)
+endsitem()
+
+The GNU extension that a `tt(-)' between the tt(%) and the
+format character causes a leading zero or space to be stripped
+is handled directly by the shell for the format characters tt(d), tt(f),
+tt(H), tt(K), tt(L), tt(m), tt(M), tt(S) and tt(y); any other format
+characters are provided to tt(strftime()) with any leading `tt(-)',
+present, so the handling is system dependent.  Further GNU
+extensions are not supported at present.
 )
 enditem()
 
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.221
diff -u -r1.221 builtin.c
--- Src/builtin.c	25 Feb 2009 10:24:01 -0000	1.221
+++ Src/builtin.c	26 Feb 2009 17:13:20 -0000
@@ -69,7 +69,7 @@
      * But that's actually not useful, so it's more consistent to
      * cause an error.
      */
-    BUILTIN("fc", 0, bin_fc, 0, -1, BIN_FC, "nlre:IRWAdDfEimpPa", NULL),
+    BUILTIN("fc", 0, bin_fc, 0, -1, BIN_FC, "aAdDe:EfiIlmnpPrRt:W", NULL),
     BUILTIN("fg", 0, bin_fg, 0, -1, BIN_FG, NULL, NULL),
     BUILTIN("float", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "E:%F:%HL:%R:%Z:%ghlprtux", "E"),
     BUILTIN("functions", BINF_PLUSOPTS, bin_functions, 0, -1, 0, "kmMtuUz", NULL),
@@ -81,7 +81,7 @@
     BUILTIN("hashinfo", 0, bin_hashinfo, 0, 0, 0, NULL, NULL),
 #endif
 
-    BUILTIN("history", 0, bin_fc, 0, -1, BIN_FC, "nrdDfEimpPa", "l"),
+    BUILTIN("history", 0, bin_fc, 0, -1, BIN_FC, "adDEfimnpPrt:", "l"),
     BUILTIN("integer", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "HL:%R:%Z:%ghi:%lprtux", "i"),
     BUILTIN("jobs", 0, bin_fg, 0, -1, BIN_JOBS, "dlpZrs", NULL),
     BUILTIN("kill", BINF_HANDLES_OPTS, bin_kill, 0, -1, 0, NULL, NULL),
@@ -1599,7 +1599,7 @@
 {
     int fclistdone = 0;
     zlong tmp;
-    char *s;
+    char *s, *tdfmt, *timebuf;
     Histent ent;
 
     /* reverse range if required */
@@ -1625,6 +1625,25 @@
 	return 1;
     }
 
+    if (OPT_ISSET(ops,'d') || OPT_ISSET(ops,'f') ||
+	OPT_ISSET(ops,'E') || OPT_ISSET(ops,'i') ||
+	OPT_ISSET(ops,'t')) {
+	if (OPT_ISSET(ops,'t')) {
+	    tdfmt = OPT_ARG(ops,'t');
+	} else if (OPT_ISSET(ops,'i')) {
+	    tdfmt = "%Y-%m-%d %H:%M";
+	} else if (OPT_ISSET(ops,'E')) {
+	    tdfmt = "%f.%-m.%Y %H:%M";
+	} else if (OPT_ISSET(ops,'f')) {
+	    tdfmt = "%-m/%f/%Y %H:%M";
+	} else {
+	    tdfmt = "%H:%M";
+	}
+	timebuf = zhalloc(256);
+    } else {
+	tdfmt = timebuf = NULL;
+    }
+
     for (;;) {
 	s = dupstring(ent->node.nam);
 	/* this if does the pattern matching, if required */
@@ -1641,24 +1660,11 @@
 	    }
 	    /* output actual time (and possibly date) of execution of the
 	       command, if required */
-	    if (OPT_ISSET(ops,'d') || OPT_ISSET(ops,'f') ||
-		OPT_ISSET(ops,'E') || OPT_ISSET(ops,'i')) {
+	    if (tdfmt != NULL) {
 		struct tm *ltm;
 		ltm = localtime(&ent->stim);
-		if (OPT_ISSET(ops,'i')) {
-		    fprintf(f, "%d-%02d-%02d ",
-			    ltm->tm_year + 1900,
-			    ltm->tm_mon + 1, ltm->tm_mday);
-		} else if (OPT_ISSET(ops,'E')) {
-		    fprintf(f, "%d.%d.%d ",
-			    ltm->tm_mday, ltm->tm_mon + 1,
-			    ltm->tm_year + 1900);
-		} else if (OPT_ISSET(ops,'f')) {
-		    fprintf(f, "%d/%d/%d ",
-			    ltm->tm_mon + 1, ltm->tm_mday,
-			    ltm->tm_year + 1900);
-		}
-		fprintf(f, "%02d:%02d  ", ltm->tm_hour, ltm->tm_min);
+		if (ztrftime(timebuf, 256, tdfmt, ltm))
+		    fprintf(f, "%s  ", timebuf);
 	    }
 	    /* display the time taken by the command, if required */
 	    if (OPT_ISSET(ops,'D')) {
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.209
diff -u -r1.209 utils.c
--- Src/utils.c	19 Feb 2009 10:15:10 -0000	1.209
+++ Src/utils.c	26 Feb 2009 17:13:20 -0000
@@ -2436,14 +2436,19 @@
      "Aug", "Sep", "Oct", "Nov", "Dec"};
 #endif
     char *origbuf = buf;
-    char tmp[3];
+    char tmp[4];
 
 
-    tmp[0] = '%';
-    tmp[2] = '\0';
     while (*fmt)
 	if (*fmt == '%') {
+	    int strip;
+
 	    fmt++;
+	    if (*fmt == '-') {
+		strip = 1;
+		fmt++;
+	    } else
+		strip = 0;
 	    /*
 	     * Assume this format will take up at least two
 	     * characters.  Not always true, but if that matters
@@ -2454,51 +2459,67 @@
 		return -1;
 	    switch (*fmt++) {
 	    case 'd':
-		*buf++ = '0' + tm->tm_mday / 10;
+		if (strip || tm->tm_mday > 9)
+		    *buf++ = '0' + tm->tm_mday / 10;
 		*buf++ = '0' + tm->tm_mday % 10;
 		break;
 	    case 'e':
+		strip = 1;
+		/* FALLTHROUGH */
 	    case 'f':
 		if (tm->tm_mday > 9)
 		    *buf++ = '0' + tm->tm_mday / 10;
-		else if (fmt[-1] == 'e')
+		else if (!strip)
 		    *buf++ = ' ';
 		*buf++ = '0' + tm->tm_mday % 10;
 		break;
 	    case 'k':
+		strip = 1;
+		/* FALLTHROUGH */
+	    case 'H':
 	    case 'K':
 		if (tm->tm_hour > 9)
 		    *buf++ = '0' + tm->tm_hour / 10;
-		else if (fmt[-1] == 'k')
-		    *buf++ = ' ';
+		else if (!strip) {
+		    if (fmt[-1] == 'H')
+			*buf++ = '0';
+		    else
+			*buf++ = ' ';
+		}
 		*buf++ = '0' + tm->tm_hour % 10;
 		break;
 	    case 'l':
+		strip = 1;
+		/* FALLTHROUGH */
 	    case 'L':
 		hr12 = tm->tm_hour % 12;
 		if (hr12 == 0)
 		    hr12 = 12;
 	        if (hr12 > 9)
 		    *buf++ = '1';
-		else if (fmt[-1] == 'l')
+		else if (!strip)
 		    *buf++ = ' ';
 
 		*buf++ = '0' + (hr12 % 10);
 		break;
 	    case 'm':
-		*buf++ = '0' + (tm->tm_mon + 1) / 10;
+		if (tm->tm_mon > 8 || !strip)
+		    *buf++ = '0' + (tm->tm_mon + 1) / 10;
 		*buf++ = '0' + (tm->tm_mon + 1) % 10;
 		break;
 	    case 'M':
-		*buf++ = '0' + tm->tm_min / 10;
+		if (tm->tm_min > 9 || !strip)
+		    *buf++ = '0' + tm->tm_min / 10;
 		*buf++ = '0' + tm->tm_min % 10;
 		break;
 	    case 'S':
-		*buf++ = '0' + tm->tm_sec / 10;
+		if (tm->tm_sec > 9 || !strip)
+		    *buf++ = '0' + tm->tm_sec / 10;
 		*buf++ = '0' + tm->tm_sec % 10;
 		break;
 	    case 'y':
-		*buf++ = '0' + (tm->tm_year / 10) % 10;
+		if (tm->tm_year > 9 || !strip)
+		    *buf++ = '0' + (tm->tm_year / 10) % 10;
 		*buf++ = '0' + tm->tm_year % 10;
 		break;
 	    case '\0':
@@ -2507,6 +2528,26 @@
 		fmt--;
 		break;
 #ifndef HAVE_STRFTIME
+	    case 'Y':
+	    {
+		/*
+		 * Not worth handling this natively if
+		 * strftime has it.
+		 */
+		int year, digits, testyear;
+		year = tm->tm_year + 1900;
+		digits = 1;
+		testyear = year;
+		while (testyear > 9) {
+		    digits++;
+		    testyear /= 10;
+		}
+		if (ztrftimebuf(&bufsize, digits))
+		    return -1;
+		sprintf(buf, "%d", year);
+		buf += digits;
+		break;
+	    }
 	    case 'a':
 		if (ztrftimebuf(&bufsize, strlen(astr[tm->tm_wday]) - 2))
 		    return -1;
@@ -2532,7 +2573,7 @@
 		 * in the accounting in bufsize (but nowhere else).
 		 */
 		*buf = '\1';
-		tmp[1] = fmt[-1];
+		sprintf(tmp, strip ? "%%-%c" : "%%%c", fmt[-1]);
 		if (!strftime(buf, bufsize + 2, tmp, tm))
 		{
 		    if (*buf) {


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[relevance 0%]

* Re: Echoing of 8-bit-characters broken after 4.3.2?
@ 2009-02-28 19:52  3% Wolfgang Hukriede
  2009-02-28 20:40  3% ` Andrey Borzenkov
  0 siblings, 1 reply; 200+ results
From: Wolfgang Hukriede @ 2009-02-28 19:52 UTC (permalink / raw)
  To: zsh-workers

Bart wrote:
> Try
>
> export LANG=is_IS.ISO8859-1
>
> I discovered this by tab-completing values for LANG.

Ok, many thanks, this works so far. I had to change the export to
LANG=IS.ISO8859-1 though since otherwise `date' talks in a language
which is unknown to me:

  > date
  lau 28 feb 2009 19:40:54 CET

No, this isn't OSX, but Freebsd-6.4 (with newest ports though by a few
days).

> The multibyte character handling on OSX appears to be particularly
> sensitive to the LANG setting (see my previous mail to Wolfgang).
> At the same time, OSX doesn't appear to export a LANG value (or at
> least it doesn't on my iMac at work).

Freebsd does not export the variable either, but why should it?

> I can't precisely reproduce the above; I get things like
>
> schaefer<263> touch x<00c3><00c3><00c3>x
>
> or
>
> schaefer<263> touch xinsert-composed-char:180: character not in range
>
> before I ever get as far as creating the file.  Maybe there's some
> additional character munging happening in transit of the email so
> I'm not using the correct input.

This is not so here. Only just the echoing of the character fails
unless LANG is set.
Tab completion worked in 4.3.2 and works with LANG set.

> Wolfgang, if you're reading this, something that I forgot to mention in
> my reply to you is that sometime during 4.3.x zsh began to pay closer
> attention to characters that are absent from the declared LANG character
> set and to either refuse to process them at all, or to render them as
> digits surrounded by angle brackets.  It no longer blindly passes those
> characters around unprocessed, so things that "worked" before because
> xterm dealt with the processing will now appear to "fail" because the
> shell is trying harder to do the right thing internally.

Yes, I suspected so. But what is the benefit of it? Perhaps to make
certain the shell can assume unicode as the default? Would an explicit
setopt (to remove the ambiguity) not be a viable/better alternative?

Looking up "man 1 locale" I found the bug section below. Might this be
significant?

  DESCRIPTION
       ...
       -m      Print names of all available charmaps.

  BUGS
       Since FreeBSD does not support charmaps in their POSIX meaning, locale
       emulates the -m option using the CODESETs listing of all available
       locales.


^ permalink raw reply	[relevance 3%]

* Re: Echoing of 8-bit-characters broken after 4.3.2?
  2009-02-28 19:52  3% Echoing of 8-bit-characters broken after 4.3.2? Wolfgang Hukriede
@ 2009-02-28 20:40  3% ` Andrey Borzenkov
  0 siblings, 0 replies; 200+ results
From: Andrey Borzenkov @ 2009-02-28 20:40 UTC (permalink / raw)
  To: zsh-workers; +Cc: Wolfgang Hukriede

[-- Attachment #1: Type: text/plain, Size: 1561 bytes --]

On 28 февраля 2009 22:52:33 Wolfgang Hukriede wrote:
> > At the same time, OSX doesn't appear to export a LANG value (or at
> > least it doesn't on my iMac at work).
>
> Freebsd does not export the variable either, but why should it?
>

Because this is established standard to define your character set 
properties. Without it applications should assume C (or POSIX) locale 
that basically corresponds to standard ASCII. So I would be surprised if 
zsh were the only program that had issues with non-ASCII characters.

FreeBSD could provide some other means to define local though.

>
> > Wolfgang, if you're reading this, something that I forgot to
> > mention in my reply to you is that sometime during 4.3.x zsh began
> > to pay closer attention to characters that are absent from the
> > declared LANG character set and to either refuse to process them at
> > all, or to render them as digits surrounded by angle brackets.  It
> > no longer blindly passes those characters around unprocessed, so
> > things that "worked" before because xterm dealt with the processing
> > will now appear to "fail" because the shell is trying harder to do
> > the right thing internally.
>
> Yes, I suspected so. But what is the benefit of it?

Because blindly emitting arbitrary character sequence to terminal may 
have completely undefined effects and screw up display to the point that 
you need hard reset (town legend also is that you can cause you terminal 
to echo back any sequence like "rm -rf" as input back to shell ...)



[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[relevance 3%]

* Re: Echoing of 8-bit-characters broken after 4.3.2?
@ 2009-02-28 22:00  0% Wolfgang Hukriede
  2009-03-01  0:12  0% ` Phil Pennock
  0 siblings, 1 reply; 200+ results
From: Wolfgang Hukriede @ 2009-02-28 22:00 UTC (permalink / raw)
  To: zsh-workers

Andrey wrote:
> Because this is established standard to define your character set
> properties. Without it applications should assume C (or POSIX) locale
> that basically corresponds to standard ASCII.

Should the character set properties not be set by LC_CTYPE? As far as
I can tell LANG sets more than that? Do I understand correctly that
LANG is zsh-specific? (On my box, man 3 setlocale does not have it.)

> So I would be surprised if
> zsh were the only program that had issues with non-ASCII characters.

At least emacs passes them through without ado. There's only one other
program that I had problems with in that respect. (That's unicode
only.) Looks like more will come...

> FreeBSD could provide some other means to define local though.

Not that I know of.

> Because blindly emitting arbitrary character sequence to terminal may
> have completely undefined effects and screw up display to the point that
> you need hard reset (town legend also is that you can cause you terminal
> to echo back any sequence like "rm -rf" as input back to shell ...)

Urban legends aside, this may be. Otoh... I've been using zsh since at
least 10 years almost exclusively and quite intensely and have used
8-bit-characters all the time (all on xterms), but any display
distortion never happened to me. This is probably due to the fact that
filenames are mostly under ones own control. I suffered display
distortion from reading emails though, but the shell could not have
done anything about that. Correctness of vt100-control-sequences
cannot be monitored either.

Therefore I think passing-through of eight bit characters should be
configurable. But I still do not understand how am I supposed to do
that (without triggering side effects). Why is PRINT_EIGHT_BIT
constricted to affect tab-completion only?


^ permalink raw reply	[relevance 0%]

* Re: Echoing of 8-bit-characters broken after 4.3.2?
  2009-02-28 22:00  0% Wolfgang Hukriede
@ 2009-03-01  0:12  0% ` Phil Pennock
  0 siblings, 0 replies; 200+ results
From: Phil Pennock @ 2009-03-01  0:12 UTC (permalink / raw)
  To: zsh-workers

On 2009-02-28 at 23:00 +0100, Wolfgang Hukriede wrote:
> Andrey wrote:
> > Because this is established standard to define your character set
> > properties. Without it applications should assume C (or POSIX) locale
> > that basically corresponds to standard ASCII.
> 
> Should the character set properties not be set by LC_CTYPE? As far as
> I can tell LANG sets more than that? Do I understand correctly that
> LANG is zsh-specific? (On my box, man 3 setlocale does not have it.)

LANG is not zsh-specific.

LANG sets defaults, the LC_* settings override those and LC_ALL
overrides everything, if memory serves.

On FreeBSD, running "locale" on its own reports all the relevant
variables, including LANG.  "locale charmap" is useful to see the
current charmap.

BTW, are you from Iceland?  is_IS means Icelandic, Iceland variant.
en_GB and en_US for English are common, and de_DE for German.

So I run with en_US.UTF-8 on FreeBSD and LANG=<tab> will show you all
the options.  For LC_CTYPE it doesn't matter so much which language you
choose.

To test an "unset" variable, set it to the value "C", which is the
default and roughly means 7-bit ASCII.

So, I just installed luit on my laptop and ssh'd to my private box,
which is normally UTF-8, with:
  luit -encoding iso8859-1 ssh
luit is a wrapper which lets you translate foreign character sets back
to UTF-8, so you can connect to non-UTF-8 systems from a UTF-8 system.

If I set:
  LC_CTYPE=C
and type <Compose><L><-> to see £ (should be POUND SIGN, Sterling, for
the British currency) then I get <00a3>.

If I set:
  LC_CTYPE=en_US.ISO8859-15
then I see the "£" as I should.

These days, you probably want to use the -15 variant instead of the -1
variant, to get Latin 9, which has a few small changes from Latin 1;
most noticeably for many, the international currency symbol is replaced
with the EURO SIGN.  Except that on the FreeBSD (7.0) system, it doesn't
appear to work in ISO8859-15.  Strange.  I'd never noticed before
because I use UTF-8 and frankly I don't care enough to chase down the
cause.

Regards,
-Phil


^ permalink raw reply	[relevance 0%]

* Re: zsh regards reserved word as candidate for alias substitution
  2009-02-25  0:17  4% zsh regards reserved word as candidate for alias substitution Vincent Lefevre
@ 2009-03-03 17:23  0% ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2009-03-03 17:23 UTC (permalink / raw)
  To: zsh-workers

On Wed, 25 Feb 2009 01:17:17 +0100
Vincent Lefevre <vincent@vinc17.org> wrote:
> I've reported the following bug on
> 
>   http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=516998
> 
> POSIX.1-2008 says[*]:
> 
>   2.3.1 Alias Substitution
>   [...] However, reserved words in correct grammatical context
>   shall not be candidates for alias substitution.

It's hardly worth an option, but it's best to keep options doing what they
say...

Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.76
diff -u -r1.76 options.yo
--- Doc/Zsh/options.yo	14 Feb 2009 13:35:37 -0000	1.76
+++ Doc/Zsh/options.yo	3 Mar 2009 17:22:02 -0000
@@ -1708,6 +1708,43 @@
 This option is for compatibility with older versions of the shell and
 is not recommended in new code.
 )
+pindex(POSIX_ALIASES)
+pindex(NO_POSIX_ALIASES)
+pindex(POSIXALIASES)
+pindex(NOPOSIXALIASES)
+item(tt(POSIX_ALIASES) <K> <S>)(
+When this option is set, reserved words are not candidates for
+alias expansion:  it is still possible to declare any of them as an alias,
+but the alias will never be expanded.  Reserved words are
+tt(!),
+tt([[),
+tt({),
+tt(}),
+tt(case),
+tt(coproc),
+tt(do),
+tt(done),
+tt(elif),
+tt(else),
+tt(end),
+tt(esac),
+tt(fi),
+tt(for),
+tt(foreach),
+tt(function),
+tt(if),
+tt(nocorrect),
+tt(repeat),
+tt(select),
+tt(then),
+tt(time),
+tt(until),
+tt(while).
+
+Alias expansion takes place while text is being read; hence when this
+option is set it does not take effect until the end of any function or
+other piece of shell code evaluated as one unit.
+)
 pindex(POSIX_BUILTINS)
 pindex(NO_POSIX_BUILTINS)
 pindex(POSIXBUILTINS)
Index: Src/lex.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/lex.c,v
retrieving revision 1.51
diff -u -r1.51 lex.c
--- Src/lex.c	27 Feb 2009 10:24:16 -0000	1.51
+++ Src/lex.c	3 Mar 2009 17:22:02 -0000
@@ -1748,9 +1748,11 @@
 
 	if (tok == STRING) {
 	    /* Check for an alias */
-	    if (!noaliases && isset(ALIASESOPT)) {
+	    if (!noaliases && isset(ALIASESOPT) &&
+		(!isset(POSIXALIASES) ||
+		 !reswdtab->getnode(reswdtab, zshlextext))) {
 		char *suf;
-		
+
 		an = (Alias) aliastab->getnode(aliastab, zshlextext);
 		if (an && !an->inuse &&
 		    ((an->node.flags & ALIAS_GLOBAL) || incmdpos || inalmore)) {
Index: Src/options.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/options.c,v
retrieving revision 1.47
diff -u -r1.47 options.c
--- Src/options.c	11 Feb 2009 20:42:16 -0000	1.47
+++ Src/options.c	3 Mar 2009 17:22:02 -0000
@@ -198,6 +198,7 @@
 {{NULL, "octalzeroes",        OPT_EMULATE|OPT_SH},	 OCTALZEROES},
 {{NULL, "overstrike",	      0},			 OVERSTRIKE},
 {{NULL, "pathdirs",	      OPT_EMULATE},		 PATHDIRS},
+{{NULL, "posixaliases",       OPT_EMULATE|OPT_BOURNE},	 POSIXALIASES},
 {{NULL, "posixbuiltins",      OPT_EMULATE|OPT_BOURNE},	 POSIXBUILTINS},
 {{NULL, "posixidentifiers",   OPT_EMULATE|OPT_BOURNE},	 POSIXIDENTIFIERS},
 {{NULL, "printeightbit",      0},                        PRINTEIGHTBIT},
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.153
diff -u -r1.153 zsh.h
--- Src/zsh.h	19 Feb 2009 10:12:39 -0000	1.153
+++ Src/zsh.h	3 Mar 2009 17:22:02 -0000
@@ -1933,6 +1933,7 @@
     OCTALZEROES,
     OVERSTRIKE,
     PATHDIRS,
+    POSIXALIASES,
     POSIXBUILTINS,
     POSIXIDENTIFIERS,
     PRINTEIGHTBIT,
Index: Test/A02alias.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A02alias.ztst,v
retrieving revision 1.6
diff -u -r1.6 A02alias.ztst
--- Test/A02alias.ztst	27 Mar 2008 09:41:13 -0000	1.6
+++ Test/A02alias.ztst	3 Mar 2009 17:22:02 -0000
@@ -25,3 +25,14 @@
   \bar \bar
 0:Aliasing with a backslash
 >bar
+
+  (alias '!=echo This command has the argument'
+  eval 'print Without
+  ! true'
+  setopt posixaliases
+  eval 'print With
+  ! true')
+1:POSIX_ALIASES option
+>Without
+>This command has the argument true
+>With

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[relevance 0%]

* Re: Modules/attr.c compile error on Mac OS X
  @ 2009-03-08  9:10  3% ` François Revol
  0 siblings, 0 replies; 200+ results
From: François Revol @ 2009-03-08  9:10 UTC (permalink / raw)
  To: Taro M; +Cc: zsh-workers

> The new Modules/attr.c does not compile on Mac OS X (and probably
> others):
> gcc -c -I.  -DHAVE_CONFIG_H -DMODULE -Wall -Wmissing-prototypes -O2
> -fno-common -o attr..o attr.c
> attr.c: In function 'bin_getattr':
> attr.c:45: error: too few arguments to function 'listxattr'
> attr.c:46: error: too few arguments to function 'getxattr'
> attr.c: In function 'bin_setattr':
> attr.c:70: error: too few arguments to function 'setxattr'
> attr.c: In function 'bin_delattr':
> attr.c:84: error: too few arguments to function 'removexattr'
> attr.c: In function 'bin_listattr':
> attr.c:99: error: too few arguments to function 'listxattr'

Likely the xattr API OSX supports isn't compatible with the withdrawn-
POSIX-draft implemented in Linux...

Generally speaking xattrs are very different from one OS to another,
and aren't compatible on all API, storage and semantics level.

For example, BeOS has made pervasive use of xattrs for over a decade,
though its are typed (uint32 4CC code) and indexable on BFS, and the
API also allows for a 64bit offset inside it, though it wasn't
implemented in BFS, cf.
http://www.beos.tarman.pl/teksty/bebookpl/The%20Storage%20Kit/AttrFuncs.html

Even on Linux I recall finding 3 different API, some taking void * for
the value field, others using char *...

cf. Linux manpage:
http://linux.die.net/man/2/getxattr

     ssize_t getxattr (const char *path, const char *name,
     void *value, size_t size);
(though the kernel API is different, and there are/were other APIs)

cf. BSD manpage:
http://www.manpagez.com/man/2/getxattr/
     ssize_t
     getxattr(const char *path, const char *name, void *value, size_t
size,
         u_int32_t position, int options);

The OSX ones likely use the BSD API, and should map quite well 1:1 at
the API level to the Linux ones, but I'm not sure about the storage
level though, on Linux the user-accessible namespace is restricted to
"user.*".
Not even mentionning the different semantics of walking interaction
(NOFOLLOW...), or value interpretation (void * vs char * that can be
binary vs char * that means string, vs typed binary value..., or even a
full directory tree as it's possible on Solaris)

Ideally a mangling scheme onto a common name/value space would be
designed to allow mapping every OS xattrs in such a way that the scheme
is idempotent (can be reused on itself multiple times through different
protocols (NFS,extended FTP,...), OS and file system (NTFS, ext2,
BFS...) and still keeping the initial information usable to the
originator).

But that will need a cross-OS coordination, and a lot of work to make
people agree. Been thinking about this for quite some time...

As for zsh, at least it should probably have a separate backend for
each platform for clarity, until such a mangling scheme is devised.

François.


^ permalink raw reply	[relevance 3%]

* Re: Bug#516998: zsh regards reserved word as candidate for alias substitution
       [not found]     <20090224231846.GA15279@vin.lip.ens-lyon.fr>
@ 2009-03-25 14:49  0% ` Clint Adams
  2009-03-25 16:23  0%   ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Clint Adams @ 2009-03-25 14:49 UTC (permalink / raw)
  To: Vincent Lefevre, 516998; +Cc: zsh-workers

On Wed, Feb 25, 2009 at 12:18:46AM +0100, Vincent Lefevre wrote:
> POSIX.1-2008 says[*]:
> 
>   2.3.1 Alias Substitution
>   [...] However, reserved words in correct grammatical context
>   shall not be candidates for alias substitution.
> 
> [*] http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_03_01
> 
> but zsh gives:
> 
> vin% emulate sh
> vin% alias !="echo OK"
> vin% ! foo
> OK foo
> vin% 
> 
> instead of running command "foo". ksh93, pdksh, dash and bash
> in POSIX mode all behave correctly.

Where it seems that "correctly" means that setting the alias
succeeds, but ! is never substituted.


^ permalink raw reply	[relevance 0%]

* Re: Bug#517008: alias not expanded with zsh -c
       [not found]     <20090225022850.GA4841@vin.lip.ens-lyon.fr>
@ 2009-03-25 14:54  0% ` Clint Adams
  2009-03-25 16:30  0%   ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Clint Adams @ 2009-03-25 14:54 UTC (permalink / raw)
  To: Vincent Lefevre, 517008; +Cc: zsh-workers

On Wed, Feb 25, 2009 at 03:28:50AM +0100, Vincent Lefevre wrote:
> Aliases are not expanded with the -c option, as shown below.
> 
> vin% cmd=$(printf "emulate sh\nalias a='echo OK >&2'\na")
> vin% printf "%s\n" "$cmd"
> emulate sh
> alias a='echo OK >&2'
> a
> vin% printf "%s" "$cmd" | zsh -f
> OK
> vin% zsh -fc "$cmd"
> zsh:3: command not found: a
> vin% 
> 
> There's no such problem with ksh93, bash in POSIX mode, and dash
> (pdksh has the same bug).

That does appear to be the behavior.


^ permalink raw reply	[relevance 0%]

* Re: Bug#514857: zsh -c 'set -e; ! true; echo OK' fails
       [not found]       ` <20090211123454.GA20425@vin.lip.ens-lyon.fr>
@ 2009-03-25 14:57  0%     ` Clint Adams
  0 siblings, 0 replies; 200+ results
From: Clint Adams @ 2009-03-25 14:57 UTC (permalink / raw)
  To: Vincent Lefevre, 514857, 519571, 520101; +Cc: zsh-workers

A trio regarding set -e:

On Wed, Feb 11, 2009 at 01:34:54PM +0100, Vincent Lefevre wrote:
> The command
> 
>   zsh -c 'set -e; ! true; echo OK'
> 
> fails to output OK, thus does not conform to POSIX:
> 
>    -e When this option is on, if a simple command fails for any of the
>       reasons listed in Section 2.8.1 (on page 2315) or returns an exit
>       status value >0, and is not part of the compound list following a
>       while, until, or if keyword, and is not a part of an AND or OR
>       list, and is not a pipeline preceded by the ! reserved word, then
>       the shell shall immediately exit.
> 
> bash, dash and ksh93 are correct (but not pdksh, posh and zsh).
> 
> There's currently a discussion about "set -e" in the austin group
> mailing-list, but there does not seem to be any ambiguity on the
> above point, as only "! true" returns an exit status value >0 but
> this is not a simple command. And concerning historical behavior,
> both ksh93 and bash output OK. So, I think that pdksh, posh and
> zsh should follow.

On Fri, Mar 13, 2009 at 03:51:34PM +0100, Vincent Lefevre wrote:
> According to the new "set -e" proposal
> 
>   http://www.opengroup.org/austin/mailarchives/ag/msg18258.html
> 
> zsh -c 'set -e; ! if true; then false; fi; echo $?'
> 
> should output 0, i.e. "false" should not make the shell exit, because
> it is under a "!" context (even though "!" doesn't apply on the "false"
> command directly).
> 
> Note that every other shell (bash, ksh93, pdksh, dash, posh) output 0.

On Tue, Mar 17, 2009 at 12:46:20PM +0100, Vincent Lefevre wrote:
> POSIX shells (bash, dash, ksh93, pdksh, posh) return with no output
> and an exit status equal to 1 on:
> 
>   sh -c 'set -e; foo() { false && false; }; foo; echo $?'
> 
> but zsh doesn't, even with "emulate sh":
> 
> $ zsh -fc 'emulate sh; set -e; foo() { false && false; }; foo; echo $?'
> 1
> 
> zsh should match the existing practice (perhaps even without
> "emulate sh", unless this can break too many zsh scripts).


^ permalink raw reply	[relevance 0%]

* Re: Bug#516998: zsh regards reserved word as candidate for alias substitution
  2009-03-25 14:49  0% ` Bug#516998: zsh regards reserved word as candidate for alias substitution Clint Adams
@ 2009-03-25 16:23  0%   ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2009-03-25 16:23 UTC (permalink / raw)
  To: 516998, zsh-workers

Clint Adams wrote:
> On Wed, Feb 25, 2009 at 12:18:46AM +0100, Vincent Lefevre wrote:
> > POSIX.1-2008 says[*]:
> > 
> >   2.3.1 Alias Substitution
> >   [...] However, reserved words in correct grammatical context
> >   shall not be candidates for alias substitution.
> > 
> > [*] http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
> #tag_18_03_01
> > 
> > but zsh gives:
> > 
> > vin% emulate sh
> > vin% alias !="echo OK"
> > vin% ! foo
> > OK foo
> > vin% 
> > 
> > instead of running command "foo". ksh93, pdksh, dash and bash
> > in POSIX mode all behave correctly.
> 
> Where it seems that "correctly" means that setting the alias
> succeeds, but ! is never substituted.

This was fixed in 26675.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[relevance 0%]

* Re: Bug#517008: alias not expanded with zsh -c
  2009-03-25 14:54  0% ` Bug#517008: alias not expanded with zsh -c Clint Adams
@ 2009-03-25 16:30  0%   ` Peter Stephenson
  2009-03-25 17:25  0%     ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Peter Stephenson @ 2009-03-25 16:30 UTC (permalink / raw)
  To: 517008, zsh-workers

Clint Adams wrote:
> On Wed, Feb 25, 2009 at 03:28:50AM +0100, Vincent Lefevre wrote:
> > Aliases are not expanded with the -c option, as shown below.
> > 
> > vin% cmd=$(printf "emulate sh\nalias a='echo OK >&2'\na")
> > vin% printf "%s\n" "$cmd"
> > emulate sh
> > alias a='echo OK >&2'
> > a
> > vin% printf "%s" "$cmd" | zsh -f
> > OK
> > vin% zsh -fc "$cmd"
> > zsh:3: command not found: a
> > vin% 
> > 
> > There's no such problem with ksh93, bash in POSIX mode, and dash
> > (pdksh has the same bug).
> 
> That does appear to be the behavior.

Yes, at least as far as native zsh mode goes this isn't a bug.  The
command passed is treated as a single piece of text that's parsed in one
go, so the alias isn't available until afterwards (by which time the
shell has exited).  This is the same behaviour as other chunks of code
read in one go.  To get script-like behaviour, don't use "-c", use a
script argument.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[relevance 0%]

* Re: Bug#517008: alias not expanded with zsh -c
  2009-03-25 16:30  0%   ` Peter Stephenson
@ 2009-03-25 17:25  0%     ` Peter Stephenson
  2009-03-25 18:11  3%       ` Bart Schaefer
  0 siblings, 1 reply; 200+ results
From: Peter Stephenson @ 2009-03-25 17:25 UTC (permalink / raw)
  To: zsh-workers; +Cc: 517008

On Wed, 25 Mar 2009 16:30:08 +0000
Peter Stephenson <pws@csr.com> wrote:
>Clint Adams wrote:
>>On Wed, Feb 25, 2009 at 03:28:50AM +0100, Vincent Lefevre wrote:
>>> Aliases are not expanded with the -c option, as shown below.
>>>
>>> vin% cmd=$(printf "emulate sh\nalias a='echo OK >&2'\na")
>>> vin% printf "%s\n" "$cmd"
>>> emulate sh
>>> alias a='echo OK >&2'
>>> a
>>> vin% printf "%s" "$cmd" | zsh -f
>>> OK
>>> vin% zsh -fc "$cmd"
>>> zsh:3: command not found: a
>>> vin% 
>>>
>>> There's no such problem with ksh93, bash in POSIX mode, and dash
>>> (pdksh has the same bug).
>>
>> That does appear to be the behavior.
>
> Yes, at least as far as native zsh mode goes this isn't a bug.

I should also have pointed out that the "emulate sh" doesn't make any
difference, it only takes effect after the string for -c has already been
parsed---it's basically the same issue as the alias expansion one itself.
You would need to start the shell in the appropriate mode.  I don't think
that's an unreasonable requirement.

Is the fix as simple as the following?  This is not a trick question, I
could very easily have missed something.

Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.100
diff -u -r1.100 init.c
--- Src/init.c	9 Mar 2009 15:57:59 -0000	1.100
+++ Src/init.c	25 Mar 2009 17:19:57 -0000
@@ -1038,9 +1038,32 @@
     if (cmd) {
 	if (SHIN >= 10)
 	    fclose(bshin);
-	SHIN = movefd(open("/dev/null", O_RDONLY | O_NOCTTY));
-	bshin = fdopen(SHIN, "r");
-	execstring(cmd, 0, 1);
+	if (isset(POSIXALIASES)) {
+	    /*
+	     * We need to process input one line at a time to
+	     * ensure aliases are available.
+	     */
+	    char *fil;
+	    int tempfd = gettempfile(NULL, 1, &fil);
+
+	    if (tempfd < 0) {
+		zerr("fc", "can't open temp file: %e", errno);
+		lastval = 1;
+	    } else {
+		int cmdlen;
+		unmetafy(cmd, &cmdlen);
+		write(tempfd, cmd, cmdlen);
+		lseek(tempfd, 0, SEEK_SET);
+		SHIN = tempfd;
+		bshin = fdopen(SHIN, "r");
+		loop(1, 0);
+	    }
+	    unlink(fil);
+	} else {
+	    SHIN = movefd(open("/dev/null", O_RDONLY | O_NOCTTY));
+	    bshin = fdopen(SHIN, "r");
+	    execstring(cmd, 0, 1);
+	}
 	stopmsg = 1;
 	zexit(lastval, 0);
     }
Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.78
diff -u -r1.78 options.yo
--- Doc/Zsh/options.yo	3 Mar 2009 17:35:29 -0000	1.78
+++ Doc/Zsh/options.yo	25 Mar 2009 17:19:57 -0000
@@ -1719,6 +1719,20 @@
 ifnzman(noderef(Reserved Words))\
 ifzman(the section RESERVED WORDS in zmanref(zshmisc)).
 
+Another effect of this option, provided it is set at shell start up,
+is to cause the shell's tt(-c) option to save commands to a temporary file
+and read them line by line to ensure aliases are expanded.  For example,
+
+example(zsh -fc 'alias o="echo Hello"
+o')
+
+reports a `command not found' error, while
+
+example(zsh -o posixaliases -fc 'alias o="echo Hello"
+o')
+
+outputs `Hello'.
+
 Alias expansion takes place while text is being read; hence when this
 option is set it does not take effect until the end of any function or
 other piece of shell code evaluated as one unit.


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[relevance 0%]

* Re: Bug#517008: alias not expanded with zsh -c
  2009-03-25 17:25  0%     ` Peter Stephenson
@ 2009-03-25 18:11  3%       ` Bart Schaefer
  2009-03-25 23:35  0%         ` Vincent Lefevre
  0 siblings, 1 reply; 200+ results
From: Bart Schaefer @ 2009-03-25 18:11 UTC (permalink / raw)
  To: zsh-workers; +Cc: 517008

On Mar 25,  5:25pm, Peter Stephenson wrote:
} Subject: Re: Bug#517008: alias not expanded with zsh -c
}
} > Yes, at least as far as native zsh mode goes this isn't a bug.
} 
} I should also have pointed out that the "emulate sh" doesn't make any
} difference, it only takes effect after the string for -c has already been
} parsed---it's basically the same issue as the alias expansion one itself.

It's my recollection that the discussion of this on the austin-group list
led to the conclusion that zsh's native behavior in this case is within
the allowed variation in the POSIX spec.  Vincent, if you're reading this, 
do you disagree, and can you point out why?

My personal feeling is that aliases are an interactive convenience that
should never be used in scripts (including "sh -c") in the first place.

} You would need to start the shell in the appropriate mode.  I don't think
} that's an unreasonable requirement.

Especially considering that now you can do
	emulate sh -c "..."
which is admittedly a little clumsy to use as in
	zsh -c 'emulate sh -c "..."'
but nevertheless is available to get the desired effect.

} Is the fix as simple as the following?  This is not a trick question, I
} could very easily have missed something.

Will this cover "emulate -c"?

I'm a bit leery of even starting down this road, because it still fails
to make any difference if the alias definition and use are on the same
line (separated with ";" or "&&" etc.).

-- 


^ permalink raw reply	[relevance 3%]

* Re: Bug#517008: alias not expanded with zsh -c
  2009-03-25 18:11  3%       ` Bart Schaefer
@ 2009-03-25 23:35  0%         ` Vincent Lefevre
  0 siblings, 0 replies; 200+ results
From: Vincent Lefevre @ 2009-03-25 23:35 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers, 517008

On 2009-03-25 11:11:28 -0700, Bart Schaefer wrote:
> On Mar 25,  5:25pm, Peter Stephenson wrote:
> } Subject: Re: Bug#517008: alias not expanded with zsh -c
> }
> } > Yes, at least as far as native zsh mode goes this isn't a bug.
> } 
> } I should also have pointed out that the "emulate sh" doesn't make any
> } difference, it only takes effect after the string for -c has already been
> } parsed---it's basically the same issue as the alias expansion one itself.
> 
> It's my recollection that the discussion of this on the austin-group list
> led to the conclusion that zsh's native behavior in this case is within
> the allowed variation in the POSIX spec.  Vincent, if you're reading this, 
> do you disagree, and can you point out why?

Yes, this is allowed: David Korn said that the standard doesn't
explain how the shell reads and processes commands. See:

  https://www.opengroup.org/sophocles/show_mail.tpl?CALLER=show_archive.tpl&source=L&listname=austin-group-l&id=12011

All on this subject:

  https://www.opengroup.org/sophocles/show_archive.tpl?source=L&listname=austin-group-l&first=1&pagesize=20&searchstring=alias+substitution+--+shells+differ&zone=G

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)


^ permalink raw reply	[relevance 0%]

* Re: Bug#527171: [zsh] segfaults on long environment variables
  @ 2009-05-06 19:41  3%   ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2009-05-06 19:41 UTC (permalink / raw)
  To: zsh-workers; +Cc: 527171

On Wed, 6 May 2009 01:38:28 +0000
Clint Adams <schizo@debian.org> wrote:
> On Wed, May 06, 2009 at 02:35:05AM +0200, Nico Golde wrote:
> > export BLA=$(perl -e "print 'A' x 100000000;")
> > 
> > results in zsh segfaulting:
> > [335969.515454] zsh[29005]: segfault at 7fff1b357858 ip 7fb5184a5855 sp 7fff1b357860 error 6 in libc-2.9.so[7fb518471000+149000]
> 
> The segfault is not in the assignment but in the export (zputenv).

This appears to be failing within setenv() which (as far as I can tell)
is being passed a perfectly valid string.  setenv() is supposed to fail
gracefully and set errno to ENOMEM if it doesn't fit in the environment
but apparently isn't.  I believe the environment size is limited by
ARG_MAX on POSIX-like systems, but it's not usually tested by the caller
(which doesn't know how much space is left).

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


^ permalink raw reply	[relevance 3%]

* Here-docs and $(...)
@ 2009-05-27 15:54  3% Bart Schaefer
  0 siblings, 0 replies; 200+ results
From: Bart Schaefer @ 2009-05-27 15:54 UTC (permalink / raw)
  To: zsh-workers

Discussion on the austin-group (POSIX) list indicates that this:

echo $(
cat <<\)
hello
)
)

Should be parsed as a here-document up through the second close paren, so
that the third close-paren matches the open paren to end the substitution.

Zsh gets this wrong, ending the command substitution at the second close.
There's probably no easy fix for this, as the here-document parser is not
invoked during scanning of the command substitution.


^ permalink raw reply	[relevance 3%]

* zsh bug in . builtin
@ 2009-07-01 13:14  4% Eric Blake
  0 siblings, 0 replies; 200+ results
From: Eric Blake @ 2009-07-01 13:14 UTC (permalink / raw)
  To: zsh-workers

According to POSIX,

A syntax error in a special built-in utility may cause a shell executing
that utility to abort, while a syntax error in a regular built-in utility
shall not cause a shell executing that utility to abort. (See Consequences
of Shell Errors for the consequences of errors on interactive and
non-interactive shells.) If a special built-in utility encountering a
syntax error does not abort the shell, its exit value shall be non-zero.
http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_14

However, zsh fails to recognize syntax errors encountered when sourcing a
file (tested with zsh 4.3.9):

$ echo 'if' > tmp
$ zsh -c '. ./tmp; echo $?'
0
$ zsh -c 'emulate sh; . ./tmp; echo $?'
./tmp:2: parse error near `\n'
0
$ zsh -c 'emulate sh; (. ./tmp); echo $?'
./tmp:2: parse error near `\n'
0

For the first test, you can do whatever (since zsh is not in sh-mode, so
it doesn't have to follow POSIX rules).  For the second line, it would be
feasible if $? is not echoed (because the entire shell was aborted), but
it is not acceptable to print 0.  And for the third line, the echo $?
should always be reached (regardless of whether the subshell aborted or
exited with failure), but again it is not acceptable to print 0.

-- 
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@byu.net


^ permalink raw reply	[relevance 4%]

* non-interactive set -m
@ 2009-07-07 21:08  5% Eric Blake
  2009-07-08  8:58  0% ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Eric Blake @ 2009-07-07 21:08 UTC (permalink / raw)
  To: zsh-workers

As far as I can tell, POSIX requires 'set -m' to work even in non-interactive 
shells, if the shell implements the User Portability Utilities (UP) option.  
POSIX is also explicit that 'set -b' shall default to disabled.  Therefore, I 
claim that this demonstrates two bugs:

$ zsh -c 'emulate sh; echo $-; set -m && set +m'
b
zsh:set:1: can't change option: -m
$ echo 1

Of course, being a non-interactive environment, there are no prompts printed, 
so the rules about 'set -m' printing status changes prior to a prompt are 
ignored; and since 'set -b' should be disabled, no asynchronous status messages 
would be printed either.  But the important part is that 'set -m' also controls 
the fact that background jobs are created in their own process group, which IS 
something that a non-interactive script can usefully exploit.  Besides, POSIX 
is eplicit that jobs also work even when 'set +m' is in effect. 

Autoconf would LOVE to implement parallel testsuite support, but supporting 
clean signal-based testsuite abortion at the parent level without leaving hung 
children and without tickling fork bomb bugs in various ksh clones requires the 
use of job control in a non-interactive environment.  Thus, at the moment, bash 
appears to be the only shell capable of reliably running a parallel testsuite:
http://thread.gmane.org/gmane.comp.sysutils.autoconf.bugs/6776

-- 
Eric Blake



^ permalink raw reply	[relevance 5%]

* Re: non-interactive set -m
  2009-07-07 21:08  5% non-interactive set -m Eric Blake
@ 2009-07-08  8:58  0% ` Peter Stephenson
  2009-07-08 13:26  5%   ` Eric Blake
  0 siblings, 1 reply; 200+ results
From: Peter Stephenson @ 2009-07-08  8:58 UTC (permalink / raw)
  To: zsh-workers

Eric Blake wrote:
> As far as I can tell, POSIX requires 'set -m' to work even in non-interactive
>  
> shells, if the shell implements the User Portability Utilities (UP) option.  
> POSIX is also explicit that 'set -b' shall default to disabled.  Therefore, I
>  
> claim that this demonstrates two bugs:
> 
> $ zsh -c 'emulate sh; echo $-; set -m && set +m'
> b
> zsh:set:1: can't change option: -m
> $ echo 1

The -b behaviour isn't a bug: use "emulate -R sh" to get all options,
including ones that don't affect syntax, reset to the emulation
defaults.  However, making the shell start up in zsh mode and switching
is increasing the complexity of what's going on; something like

  ARGV0=sh zsh -c 'echo $-'

is easier and the output should be empty.  (Alternatively, if you're not
starting from zsh, use a symbolic link to zsh.)

Part of my reason for suggesting that is the following.  It's true you
can't change the MONITOR option after the shell starts.  It's probably
fixable, but being able to switch back and forth might be complicated
(though I haven't looked in detail).  However, making MONITOR work at
startup isn't so hard: the following simple patch stops it being tied to
interactive mode.  As this has no effect unless you request MONITOR, it
won't cause problems elsewhere.  This would mean that

  ARGV0=sh zsh -mc '...'

will enable monitor mode at startup.  Note that you do need a tty or pty
of some sort (that's what SHTTY != -1 is testing), but that's probably
obvious from the way job control works.

What I don't know and haven't tested is whether MONITOR actually works
in a non-interative shell.  A simple test suggested it was basically OK.
If someone can investigate whether there are any problems with the
following patch I will see if they are easy to fix.

Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.101
diff -u -r1.101 init.c
--- Src/init.c	1 Jul 2009 15:07:33 -0000	1.101
+++ Src/init.c	8 Jul 2009 08:49:21 -0000
@@ -486,7 +486,7 @@
      * process group leader.
      */
     mypid = (zlong)getpid();
-    if (opts[MONITOR] && interact && (SHTTY != -1)) {
+    if (opts[MONITOR] && (SHTTY != -1)) {
 	origpgrp = GETPGRP();
         acquire_pgrp(); /* might also clear opts[MONITOR] */
     } else


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[relevance 0%]

* Re: non-interactive set -m
  2009-07-08  8:58  0% ` Peter Stephenson
@ 2009-07-08 13:26  5%   ` Eric Blake
  2009-07-08 13:49  4%     ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Eric Blake @ 2009-07-08 13:26 UTC (permalink / raw)
  To: zsh-workers

Peter Stephenson <pws <at> csr.com> writes:

> Part of my reason for suggesting that is the following.  It's true you
> can't change the MONITOR option after the shell starts.  It's probably
> fixable, but being able to switch back and forth might be complicated
> (though I haven't looked in detail).

POSIX requires that 'set -m'/'set -o monitor' be switchable on the fly, without
regards to whether the shell is interactive.  And your claim that MONITOR
cannot be changed on the fly is false: zsh already handles this for interactive
shells, with knock-on effects that fg and bg change behavior depending on the
current state of MONITOR (also as specified by POSIX).

$ ARGV0=sh zsh -ci 'echo $-; set +m; sleep 1& fg; echo $-; set -m; echo $-'
569XZim
zsh:fg:1: no job control in this shell.
569XZi
569XZim

>  However, making MONITOR work at
> startup isn't so hard: the following simple patch stops it being tied to
> interactive mode.  As this has no effect unless you request MONITOR, it
> won't cause problems elsewhere.  This would mean that
> 
>   ARGV0=sh zsh -mc '...'
> 
> will enable monitor mode at startup.

Unfortunately, for autoconf's purposes, that is not possible without
contortions of re-starting a script if it is detected that zsh is running the
script but not in sh mode.  Autoconf does not have control over how the user
started a script, but wants the shell to be in POSIX mode after the point that
the script is already started, as part of sanitizing the environment to be
portable across as many shells as possible, so autoconf is forced to use
'emulate sh' (although we may switch it to use 'emulate -R sh', based on your
advice).

>  Note that you do need a tty or pty
> of some sort (that's what SHTTY != -1 is testing), but that's probably
> obvious from the way job control works.

You are correct that you can't change interactive mode on the fly - whether $-
prints i is fixed from the moment the shell starts up.  You are also correct
that the initial state of MONITOR depends on whether the shell is interactive,
and that whether a shell is interactive depends, in part, on whether there is a
tty: POSIX requires that interactive shells start with 'set -m' and
non-interactive shells start with 'set +m' unless specified differently by
other command line options, so at startup, $- will usually contain either both
or neither of 'im'.  But while the presence of a tty is a factor for
determining whether the shell is interactive, it is NOT a factor in determining
whether job control works.  Job control works just fine without a tty, as
proved by bash and ksh.  Meanwhile, the presence of a tty is not the ONLY way
to get an interactive shell; POSIX requires that even without a tty, a shell
started with an explicit -i must be interactive (although in this condition,
the shell need not print prompts).

According to POSIX, job control does two things - it changes messages printed
before a prompt (related to interactivity and the presence of a tty), and it
makes it possible to spawn asynchronous processes in separate process groups
for independent tracking.  It is the latter part (separate process groups) that
autoconf wants to use to enable parallel testsuites, and which is unrelated to
whether there is a tty.  And in a non-interactive shell, the former part
(printing a message before prompts) does not matter, since non-interactive
shells never print prompts in the first place.

Basically, zsh cannot be used for parallel autoconf tests unless you fix the
bug of allowing job control support to be changed on the fly for non-interactive
shells.

-- 
Eric Blake



^ permalink raw reply	[relevance 5%]

* Re: non-interactive set -m
  2009-07-08 13:26  5%   ` Eric Blake
@ 2009-07-08 13:49  4%     ` Peter Stephenson
  2009-07-09 14:03  0%       ` Eric Blake
    0 siblings, 2 replies; 200+ results
From: Peter Stephenson @ 2009-07-08 13:49 UTC (permalink / raw)
  To: zsh-workers

Eric Blake wrote:
> POSIX requires that 'set -m'/'set -o monitor' be switchable on the fly

Unfortunately I have limited time even for fixing real bugs in the
shell, which was not originally designed to be a POSIX shell and is not
your best bet if POSIX compatibility is your bottom line, and we have
very few volunteers for fixing stuff in the core shell.  So arguments of
this kind on their own tend to fall a bit flat in these parts, for
purely practical reasons (we're not actually against providing POSIX
compatibility, of course).

"It'll work if you change *this*" is a much more enticing argument...

> And your claim that MONITOR
> cannot be changed on the fly is false: zsh already handles this for
> interactive shells

You're right---there's another test of the same kind there (i.e. that
we're interactive).  This removes it.  Let me know if you run up against
more, or if there's some hidden interaction with the
interactive/non-interactive mode (I wouldn't bet against it).

I think the code that does the run-time switching is a late addition,
but I haven't checked the history.

Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.101
diff -u -r1.101 init.c
--- Src/init.c	1 Jul 2009 15:07:33 -0000	1.101
+++ Src/init.c	8 Jul 2009 13:36:58 -0000
@@ -486,7 +486,7 @@
      * process group leader.
      */
     mypid = (zlong)getpid();
-    if (opts[MONITOR] && interact && (SHTTY != -1)) {
+    if (opts[MONITOR] && (SHTTY != -1)) {
 	origpgrp = GETPGRP();
         acquire_pgrp(); /* might also clear opts[MONITOR] */
     } else
Index: Src/options.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/options.c,v
retrieving revision 1.48
diff -u -r1.48 options.c
--- Src/options.c	3 Mar 2009 17:26:08 -0000	1.48
+++ Src/options.c	8 Jul 2009 13:36:58 -0000
@@ -730,7 +730,7 @@
     } else if (!force && optno == MONITOR && value) {
 	if (opts[optno] == value)
 	    return 0;
-	if (interact && (SHTTY != -1)) {
+	if (SHTTY != -1) {
 	    origpgrp = GETPGRP();
 	    acquire_pgrp();
 	} else


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[relevance 4%]

* bug: $? after empty command
@ 2009-07-09 13:12  3% Eric Blake
  2009-07-09 14:41  0% ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Eric Blake @ 2009-07-09 13:12 UTC (permalink / raw)
  To: zsh-workers

POSIX requires that the execution of an empty command change $? to 0, as shown
here with bash:

$ zsh -c 'foo=; false; $foo; echo $?'
1
$ bash -c 'foo=; false; $foo; echo $?'
0

-- 
Eric Blake



^ permalink raw reply	[relevance 3%]

* Re: non-interactive set -m
  2009-07-08 13:49  4%     ` Peter Stephenson
@ 2009-07-09 14:03  0%       ` Eric Blake
  2009-07-09 14:13  0%         ` Peter Stephenson
    1 sibling, 1 reply; 200+ results
From: Eric Blake @ 2009-07-09 14:03 UTC (permalink / raw)
  To: zsh-workers

Peter Stephenson <pws <at> csr.com> writes:

> > POSIX requires that 'set -m'/'set -o monitor' be switchable on the fly
> 
> You're right---there's another test of the same kind there (i.e. that
> we're interactive).  This removes it.  Let me know if you run up against
> more, or if there's some hidden interaction with the
> interactive/non-interactive mode (I wouldn't bet against it).

I'd love to test this.  However, I'm behind a firewall, and can't access CVS. 
Is there a snapshot available? 
http://zsh.sourceforge.net/zsh-4.3-daily-snapshot.tar.bz2 appears to be a dead
link.  Or are there any plans for moving to a newer VCS, such as git, which
makes http access much easier?

-- 
Eric Blake



^ permalink raw reply	[relevance 0%]

* Re: non-interactive set -m
  2009-07-09 14:03  0%       ` Eric Blake
@ 2009-07-09 14:13  0%         ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2009-07-09 14:13 UTC (permalink / raw)
  To: zsh-workers

Eric Blake wrote:
> Peter Stephenson <pws <at> csr.com> writes:
> 
> > > POSIX requires that 'set -m'/'set -o monitor' be switchable on the fly
> > 
> > You're right---there's another test of the same kind there (i.e. that
> > we're interactive).  This removes it.  Let me know if you run up against
> > more, or if there's some hidden interaction with the
> > interactive/non-interactive mode (I wouldn't bet against it).
> 
> I'd love to test this.  However, I'm behind a firewall, and can't access CVS.
>  
> Is there a snapshot available? 
> http://zsh.sourceforge.net/zsh-4.3-daily-snapshot.tar.bz2 appears to be a dea
> d
> link.  Or are there any plans for moving to a newer VCS, such as git, which
> makes http access much easier?

There's an almost up-to-date git mirror available; see

http://www.zsh.org/mla/workers/2009/msg00516.html

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[relevance 0%]

* Re: bug: $? after empty command
  2009-07-09 13:12  3% bug: $? after empty command Eric Blake
@ 2009-07-09 14:41  0% ` Peter Stephenson
  2009-07-09 21:17  3%   ` Eric Blake
  0 siblings, 1 reply; 200+ results
From: Peter Stephenson @ 2009-07-09 14:41 UTC (permalink / raw)
  To: zsh-workers

On Thu, 9 Jul 2009 13:12:20 +0000 (UTC)
Eric Blake <ebb9@byu.net> wrote:
> POSIX requires that the execution of an empty command change $? to 0, as shown
> here with bash:
> 
> $ zsh -c 'foo=; false; $foo; echo $?'
> 1

I'm not aware that that's deliberate shell behaviour, and indeed I
wouldn't have expected it.  It *is* deliberate behaviour that the status is
not reset simply by hitting return at the interactive prompt, but that's
actually a different issue, not affected by the following.

The fix for this is quite subtle because of the case

  zsh -c 'false; $(exit 3); echo $?'

which should print 3, but I think I've finally found a way that handles
both.

Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.165
diff -u -r1.165 exec.c
--- Src/exec.c	15 Mar 2009 01:04:50 -0000	1.165
+++ Src/exec.c	9 Jul 2009 14:38:41 -0000
@@ -151,6 +151,15 @@
 /**/
 int cmdoutval;
 
+/*
+ * This is set by an exiting $(...) substitution to indicate we need
+ * to retain the status.  We initialize it to zero if we think we need
+ * to reset the status for a command.
+ */
+
+/**/
+int use_cmdoutval;
+
 /* The context in which a shell function is called, see SFC_* in zsh.h. */ 
 
 /**/
@@ -2262,6 +2271,14 @@
      */
     if (!args && varspc)
 	lastval = errflag ? errflag : cmdoutval;
+    /*
+     * If there are arguments, we should reset the status for the
+     * command before execution---unless we are using the result of a
+     * command substitution, which will be indicated by setting
+     * use_cmdoutval to 1.  We haven't kicked those off yet, so
+     * there's no race.
+     */
+    use_cmdoutval = !args;
 
     for (i = 0; i < 10; i++) {
 	save[i] = -2;
@@ -2478,7 +2495,12 @@
 		    lastval = 0;
 		    return;
 		} else {
-		    cmdoutval = lastval;
+		    /*
+		     * No arguments.  Reset the status if there were
+		     * arguments before and no command substitution
+		     * has provided a status.
+		     */
+		    cmdoutval = use_cmdoutval ? lastval : 0;
 		    if (varspc)
 			addvars(state, varspc, 0);
 		    if (errflag)
@@ -4674,6 +4696,7 @@
     es->badcshglob = badcshglob;
     es->cmdoutpid = cmdoutpid;
     es->cmdoutval = cmdoutval;
+    es->use_cmdoutval = use_cmdoutval;
     es->trap_return = trap_return;
     es->trap_state = trap_state;
     es->trapisfunc = trapisfunc;
@@ -4704,6 +4727,7 @@
     badcshglob = exstack->badcshglob;
     cmdoutpid = exstack->cmdoutpid;
     cmdoutval = exstack->cmdoutval;
+    use_cmdoutval = exstack->use_cmdoutval;
     trap_return = exstack->trap_return;
     trap_state = exstack->trap_state;
     trapisfunc = exstack->trapisfunc;
Index: Src/signals.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/signals.c,v
retrieving revision 1.54
diff -u -r1.54 signals.c
--- Src/signals.c	11 Feb 2009 20:42:16 -0000	1.54
+++ Src/signals.c	9 Jul 2009 14:38:41 -0000
@@ -494,6 +494,7 @@
 			*procsubval = (0200 | WTERMSIG(status));
 		    else
 			*procsubval = WEXITSTATUS(status);
+		    use_cmdoutval = 1;
 		    get_usage();
 		    cont = 1;
 		    break;
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.158
diff -u -r1.158 zsh.h
--- Src/zsh.h	2 Jul 2009 13:48:36 -0000	1.158
+++ Src/zsh.h	9 Jul 2009 14:38:41 -0000
@@ -930,6 +930,7 @@
     int badcshglob;
     pid_t cmdoutpid;
     int cmdoutval;
+    int use_cmdoutval;
     int trap_return;
     int trap_state;
     int trapisfunc;
Index: Test/A01grammar.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A01grammar.ztst,v
retrieving revision 1.22
diff -u -r1.22 A01grammar.ztst
--- Test/A01grammar.ztst	6 Jul 2009 20:44:29 -0000	1.22
+++ Test/A01grammar.ztst	9 Jul 2009 14:38:41 -0000
@@ -23,6 +23,10 @@
   true | false
 1:Exit status of pipeline with builtins (false)
 
+  false
+  $nonexistent_variable
+0:Executing command that evaluates to empty resets status
+
   fn() { local foo; read foo; print $foo; }
   coproc fn
   print -p coproc test output


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[relevance 0%]

* Re: bug: $? after empty command
  2009-07-09 14:41  0% ` Peter Stephenson
@ 2009-07-09 21:17  3%   ` Eric Blake
  2009-07-09 21:41  3%     ` Eric Blake
  0 siblings, 1 reply; 200+ results
From: Eric Blake @ 2009-07-09 21:17 UTC (permalink / raw)
  To: zsh-workers

Peter Stephenson <pws <at> csr.com> writes:

> > POSIX requires that the execution of an empty command change $? to 0, as
> > shown here with bash:
> > 
> > $ zsh -c 'foo=; false; $foo; echo $?'
> > 1
> 
> I'm not aware that that's deliberate shell behaviour, and indeed I
> wouldn't have expected it.  It *is* deliberate behaviour that the status is
> not reset simply by hitting return at the interactive prompt, but that's
> actually a different issue, not affected by the following.

Good point about making the behavior dependent on a non-empty command line, and
that the exit status of command substitution is still important.  I don't see
your patch in CVS yet, so I haven't played with it.  But just from inspection,
it looks like it does not cover these related issues, which are both required by
POSIX to output 0:

$ zsh -c 'false; . /dev/null; echo $?'
1
$ zsh -c 'false; ``; echo $?'
1

-- 
Eric Blake



^ permalink raw reply	[relevance 3%]

* Re: non-interactive set -m
  @ 2009-07-09 21:40  4%           ` Eric Blake
  2009-07-10  8:58  0%             ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Eric Blake @ 2009-07-09 21:40 UTC (permalink / raw)
  To: zsh-workers

Peter Stephenson <p.w.stephenson <at> ntlworld.com> writes:

> > It looks like the fg activated the sleep process, because it took five
> > seconds for the Stopped message to appear, but fg failed to print to stdout
> > the process that it just activated.
> 
> ... and the third part: this seems to be another question of testing if
> MONITOR is set (jobbing---I wish we didn't those #define's) but not if
> INTERACTIVE is set (interact).  Also need to fix up the output to go to
> stderr instead of the file (not) opened to the terminal.

POSIX states that fg output goes to stdout, not stderr.  Thus, I should have a
silent wait for 5 seconds with the following command; although with this latest
round of patches, things are still noisy:

$ Src/zsh -c 'set -m; sleep 5& fg >/dev/null'
[1] 5804
[1]  + running    sleep 5
$

It looks like two different sources of noise - creating the background task is
outputting information about the job just created, which should really be
conditional on being interactive (a non-interactive shell will use 'jobs' to
learn this information, rather than having it printed to stderr).  The other
source of noise is that fg is writing to stderr instead of the required stdout.

Also, POSIX states that fg output should be the name of the command that was
brought into the foreground, and not the 'jobs' output describing that command.

Notice how bash does it:
$ bash -ci 'set -m; sleep 5& fg >/dev/null'
[1] 21428
$ bash -c 'set -m; sleep 5& fg'
sleep 5
$ bash -c 'set -m; sleep 5& fg >/dev/null'
$

> I've done the same thing at another point, where the status of a job
> changes.  You're the guinea pig so if you think this output should or
> shouldn't be there I can leave it or change it.

Not a problem - I'm actually having fun trying to test this.  At any rate, given
my (lack of) familiarity with the zsh code layout, reporting my tests is easier
than trying to propose patches, although I'll do what I can.

-- 
Eric Blake



^ permalink raw reply	[relevance 4%]

* Re: bug: $? after empty command
  2009-07-09 21:17  3%   ` Eric Blake
@ 2009-07-09 21:41  3%     ` Eric Blake
  2009-07-10  9:02  3%       ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Eric Blake @ 2009-07-09 21:41 UTC (permalink / raw)
  To: zsh-workers

Eric Blake <ebb9 <at> byu.net> writes:

> But just from inspection,
> it looks like it does not cover these related issues, which are both required
> by POSIX to output 0:
> 
> $ zsh -c 'false; . /dev/null; echo $?'
> 1
> $ zsh -c 'false; ``; echo $?'
> 1

And another one that POSIX requires to output 0:

$ zsh -c 'false; sleep& echo $?'
1

-- 
Eric Blake



^ permalink raw reply	[relevance 3%]

* Re: non-interactive set -m
  2009-07-09 21:40  4%           ` Eric Blake
@ 2009-07-10  8:58  0%             ` Peter Stephenson
  2009-07-10 10:53  6%               ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Peter Stephenson @ 2009-07-10  8:58 UTC (permalink / raw)
  To: zsh-workers

On Thu, 9 Jul 2009 21:40:19 +0000 (UTC)
Eric Blake <ebb9@byu.net> wrote:
> POSIX states that fg output goes to stdout, not stderr.
>...
> It looks like two different sources of noise - creating the background task is
> outputting information about the job just created, which should really be
> conditional on being interactive (a non-interactive shell will use 'jobs' to
> learn this information, rather than having it printed to stderr).  The
> other source of noise is that fg is writing to stderr instead of the
> required stdout.

It looks like you didn't want the other "if (interact)" removing.  This
should fix these two.

> Also, POSIX states that fg output should be the name of the command that was
> brought into the foreground, and not the 'jobs' output describing that
> command.

Haven't looked at this, but as an annoying fiddly difference it probably
needs to be an option.

Index: Src/jobs.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v
retrieving revision 1.67
diff -u -r1.67 jobs.c
--- Src/jobs.c	9 Jul 2009 20:33:56 -0000	1.67
+++ Src/jobs.c	10 Jul 2009 08:56:26 -0000
@@ -828,7 +828,7 @@
     int job, len = 9, sig, sflag = 0, llen;
     int conted = 0, lineleng = columns, skip = 0, doputnl = 0;
     int doneprint = 0;
-    FILE *fout = (synch == 2) ? stdout : shout ? shout : stderr;
+    FILE *fout = (synch == 2 || !shout) ? stdout : shout;
 
     if (oldjobtab != NULL)
 	job = jn - oldjobtab;
@@ -886,8 +886,8 @@
 
 /* print if necessary: ignore option state on explicit call to `jobs'. */
 
-    if (synch == 2 || 
-	(jobbing &&
+    if (synch == 2 ||
+	(interact && jobbing &&
 	 ((jn->stat & STAT_STOPPED) || sflag || job != thisjob))) {
 	int len2, fline = 1;
 	/* use special format for current job, except in `jobs' */
@@ -1380,7 +1380,7 @@
 	} else if (prevjob == -1 || !(jobtab[prevjob].stat & STAT_STOPPED))
 	    prevjob = thisjob;
 	if (jobbing && jobtab[thisjob].procs) {
-	    FILE *fout = shout ? shout : stderr;
+	    FILE *fout = shout ? shout : stdout;
 	    fprintf(fout, "[%d]", thisjob);
 	    for (pn = jobtab[thisjob].procs; pn; pn = pn->next)
 		fprintf(fout, " %ld", (long) pn->pid);
@@ -1908,8 +1908,7 @@
 		printjob(jobtab + job, (stopped) ? -1 : lng, 1);
 	    if (func != BIN_BG) {		/* fg or wait */
 		if (jobtab[job].pwd && strcmp(jobtab[job].pwd, pwd)) {
-		    FILE *fout = (func == BIN_JOBS) ? stdout : shout ?
-			shout : stderr;
+		    FILE *fout = (func == BIN_JOBS || !shout) ? stdout : shout;
 		    fprintf(fout, "(pwd : ");
 		    fprintdir(jobtab[job].pwd, fout);
 		    fprintf(fout, ")\n");


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[relevance 0%]

* Re: bug: $? after empty command
  2009-07-09 21:41  3%     ` Eric Blake
@ 2009-07-10  9:02  3%       ` Peter Stephenson
  2009-07-10 22:05  0%         ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Peter Stephenson @ 2009-07-10  9:02 UTC (permalink / raw)
  To: zsh-workers

On Thu, 9 Jul 2009 21:41:51 +0000 (UTC)
Eric Blake <ebb9@byu.net> wrote:
> Eric Blake <ebb9 <at> byu.net> writes:
> 
> > But just from inspection,
> > it looks like it does not cover these related issues, which are both required
> > by POSIX to output 0:
> > 
> > $ zsh -c 'false; . /dev/null; echo $?'
> > 1
> > $ zsh -c 'false; ``; echo $?'
> > 1
> 
> And another one that POSIX requires to output 0:
> 
> $ zsh -c 'false; sleep& echo $?'
> 1

These still need fixing.

Also, I don't think it affects POSIX, because empty functions aren't
required to work, but in zsh, "fn() { }" is valid, and I suspect "fn"
logically ought to reset the status, too---basically anywhere where you've
run a complex command with an empty list of commands in it.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[relevance 3%]

* Re: non-interactive set -m
  2009-07-10  8:58  0%             ` Peter Stephenson
@ 2009-07-10 10:53  6%               ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2009-07-10 10:53 UTC (permalink / raw)
  To: zsh-workers

On Fri, 10 Jul 2009 09:58:13 +0100
Peter Stephenson <pws@csr.com> wrote:
> On Thu, 9 Jul 2009 21:40:19 +0000 (UTC)
> > Also, POSIX states that fg output should be the name of the command that was
> > brought into the foreground, and not the 'jobs' output describing that
> > command.
> 
> Haven't looked at this, but as an annoying fiddly difference it probably
> needs to be an option.

Straightforward if an annoying increase in mess.

I've partly gone back on the previous going back on the previous patch that
printed a message if non-interactive but with job-control---I think we need
to do it if synchronous, so we get the output from "fg" and "bg".

Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.82
diff -u -r1.82 options.yo
--- Doc/Zsh/options.yo	17 May 2009 18:23:10 -0000	1.82
+++ Doc/Zsh/options.yo	10 Jul 2009 10:48:57 -0000
@@ -1274,6 +1274,17 @@
 Report the status of background jobs immediately, rather than
 waiting until just before printing a prompt.
 )
+pindex(POSIX_JOBS)
+pindex(POSIXJOBS)
+pindex(NO_POSIX_JOBS)
+pindex(NOPOSIXJOBS)
+cindex(bg, output in POSIX format)
+cindex(fg, output in POSIX format)
+item(tt(POSIX_JOBS) <K> <S>)(
+When putting jobs in the background or foreground with tt(bg) or tt(fg),
+just print the text of the job as required by POSIX,
+rather than the full information that would be output by tt(jobs).
+)
 enditem()
 
 subsect(Prompting)
Index: Src/jobs.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v
retrieving revision 1.68
diff -u -r1.68 jobs.c
--- Src/jobs.c	10 Jul 2009 09:11:12 -0000	1.68
+++ Src/jobs.c	10 Jul 2009 10:48:57 -0000
@@ -813,6 +813,7 @@
  * synch = 0 means asynchronous
  * synch = 1 means synchronous
  * synch = 2 means called synchronously from jobs
+ * synch = 3 means called synchronously from bg or fg
  *
  * Returns 1 if some output was done.
  *
@@ -884,12 +885,18 @@
 	}
     }
 
-/* print if necessary: ignore option state on explicit call to `jobs'. */
-
+    /*
+     * - Always print if called from jobs
+     * - Otherwise, require MONITOR option ("jobbing") and some
+     *   change of state
+     * - also either the shell is interactive or this is synchronous.
+     */
     if (synch == 2 ||
-	(interact && jobbing &&
+	((interact || synch) && jobbing &&
 	 ((jn->stat & STAT_STOPPED) || sflag || job != thisjob))) {
 	int len2, fline = 1;
+	/* POSIX requires just the job text for bg and fg */
+	int plainfmt = (synch == 3) && isset(POSIXJOBS);
 	/* use special format for current job, except in `jobs' */
 	int thisfmt = job == thisjob && synch != 2;
 	Process qn;
@@ -908,54 +915,60 @@
 		for (qn = pn->next; qn; qn = qn->next) {
 		    if (qn->status != pn->status)
 			break;
-		    if ((int)strlen(qn->text) + len2 + ((qn->next) ? 3 : 0) > lineleng)
+		    if ((int)strlen(qn->text) + len2 + ((qn->next) ? 3 : 0)
+			> lineleng)
 			break;
 		    len2 += strlen(qn->text) + 2;
 		}
 	    doneprint = 1;
-	    if (!thisfmt || lng) {
-		if (fline)
-		    fprintf(fout, "[%ld]  %c ",
-			    (long)job,
-			    (job == curjob) ? '+'
-			    : (job == prevjob) ? '-' : ' ');
-		else
-		    fprintf(fout, (job > 9) ? "        " : "       ");
-	    } else
-		fprintf(fout, "zsh: ");
-	    if (lng & 1)
-		fprintf(fout, "%ld ", (long) pn->pid);
-	    else if (lng & 2) {
-		pid_t x = jn->gleader;
-
-		fprintf(fout, "%ld ", (long) x);
-		do
+	    if (!plainfmt) {
+		if (!thisfmt || lng) {
+		    if (fline)
+			fprintf(fout, "[%ld]  %c ",
+				(long)job,
+				(job == curjob) ? '+'
+				: (job == prevjob) ? '-' : ' ');
+		    else
+			fprintf(fout, (job > 9) ? "        " : "       ");
+		} else
+		    fprintf(fout, "zsh: ");
+		if (lng & 1)
+		    fprintf(fout, "%ld ", (long) pn->pid);
+		else if (lng & 2) {
+		    pid_t x = jn->gleader;
+
+		    fprintf(fout, "%ld ", (long) x);
+		    do
+			skip++;
+		    while ((x /= 10));
 		    skip++;
-		while ((x /= 10));
-		skip++;
-		lng &= ~3;
-	    } else
-		fprintf(fout, "%*s", skip, "");
-	    if (pn->status == SP_RUNNING) {
-		if (!conted)
-		    fprintf(fout, "running%*s", len - 7 + 2, "");
+		    lng &= ~3;
+		} else
+		    fprintf(fout, "%*s", skip, "");
+		if (pn->status == SP_RUNNING) {
+		    if (!conted)
+			fprintf(fout, "running%*s", len - 7 + 2, "");
+		    else
+			fprintf(fout, "continued%*s", len - 9 + 2, "");
+		}
+		else if (WIFEXITED(pn->status)) {
+		    if (WEXITSTATUS(pn->status))
+			fprintf(fout, "exit %-4d%*s", WEXITSTATUS(pn->status),
+				len - 9 + 2, "");
+		    else
+			fprintf(fout, "done%*s", len - 4 + 2, "");
+		} else if (WIFSTOPPED(pn->status))
+		    fprintf(fout, "%-*s", len + 2,
+			    sigmsg(WSTOPSIG(pn->status)));
+		else if (WCOREDUMP(pn->status))
+		    fprintf(fout, "%s (core dumped)%*s",
+			    sigmsg(WTERMSIG(pn->status)),
+			    (int)(len - 14 + 2 -
+				  strlen(sigmsg(WTERMSIG(pn->status)))), "");
 		else
-		    fprintf(fout, "continued%*s", len - 9 + 2, "");
+		    fprintf(fout, "%-*s", len + 2,
+			    sigmsg(WTERMSIG(pn->status)));
 	    }
-	    else if (WIFEXITED(pn->status)) {
-		if (WEXITSTATUS(pn->status))
-		    fprintf(fout, "exit %-4d%*s", WEXITSTATUS(pn->status),
-			    len - 9 + 2, "");
-		else
-		    fprintf(fout, "done%*s", len - 4 + 2, "");
-	    } else if (WIFSTOPPED(pn->status))
-		fprintf(fout, "%-*s", len + 2, sigmsg(WSTOPSIG(pn->status)));
-	    else if (WCOREDUMP(pn->status))
-		fprintf(fout, "%s (core dumped)%*s",
-			sigmsg(WTERMSIG(pn->status)),
-			(int)(len - 14 + 2 - strlen(sigmsg(WTERMSIG(pn->status)))), "");
-	    else
-		fprintf(fout, "%-*s", len + 2, sigmsg(WTERMSIG(pn->status)));
 	    for (; pn != qn; pn = pn->next) {
 		char *txt = dupstring(pn->text);
 		int txtlen;
@@ -1904,7 +1918,7 @@
 	    }
 	    if (func != BIN_WAIT)
 		/* for bg and fg -- show the job we are operating on */
-		printjob(jobtab + job, (stopped) ? -1 : lng, 1);
+		printjob(jobtab + job, (stopped) ? -1 : lng, 3);
 	    if (func != BIN_BG) {		/* fg or wait */
 		if (jobtab[job].pwd && strcmp(jobtab[job].pwd, pwd)) {
 		    FILE *fout = (func == BIN_JOBS || !shout) ? stdout : shout;
Index: Src/options.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/options.c,v
retrieving revision 1.49
diff -u -r1.49 options.c
--- Src/options.c	8 Jul 2009 17:07:14 -0000	1.49
+++ Src/options.c	10 Jul 2009 10:48:57 -0000
@@ -201,6 +201,7 @@
 {{NULL, "posixaliases",       OPT_EMULATE|OPT_BOURNE},	 POSIXALIASES},
 {{NULL, "posixbuiltins",      OPT_EMULATE|OPT_BOURNE},	 POSIXBUILTINS},
 {{NULL, "posixidentifiers",   OPT_EMULATE|OPT_BOURNE},	 POSIXIDENTIFIERS},
+{{NULL, "posixjobs",          OPT_EMULATE|OPT_BOURNE},	 POSIXJOBS},
 {{NULL, "printeightbit",      0},                        PRINTEIGHTBIT},
 {{NULL, "printexitvalue",     0},			 PRINTEXITVALUE},
 {{NULL, "privileged",	      OPT_SPECIAL},		 PRIVILEGED},
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.158
diff -u -r1.158 zsh.h
--- Src/zsh.h	2 Jul 2009 13:48:36 -0000	1.158
+++ Src/zsh.h	10 Jul 2009 10:48:57 -0000
@@ -1955,6 +1956,7 @@
     POSIXALIASES,
     POSIXBUILTINS,
     POSIXIDENTIFIERS,
+    POSIXJOBS,
     PRINTEIGHTBIT,
     PRINTEXITVALUE,
     PRIVILEGED,

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[relevance 6%]

* Re: bug: $? after empty command
  2009-07-10  9:02  3%       ` Peter Stephenson
@ 2009-07-10 22:05  0%         ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2009-07-10 22:05 UTC (permalink / raw)
  To: zsh-workers

On Fri, 10 Jul 2009 10:02:28 +0100
Peter Stephenson <pws@csr.com> wrote:
> On Thu, 9 Jul 2009 21:41:51 +0000 (UTC)
> Eric Blake <ebb9@byu.net> wrote:
>> Eric Blake <ebb9 <at> byu.net> writes:
>> 
>>> But just from inspection,
>>> it looks like it does not cover these related issues, which are
>>> both required by POSIX to output 0:
>>> 
>>> $ zsh -c 'false; . /dev/null; echo $?'
>>> 1
>>> $ zsh -c 'false; ``; echo $?'
>>> 1
>> 
>> And another one that POSIX requires to output 0:
>> 
>> $ zsh -c 'false; sleep& echo $?'
>> 1
> 
> Also, I don't think it affects POSIX, because empty functions aren't
> required to work, but in zsh, "fn() { }" is valid, and I suspect "fn"
> logically ought to reset the status, too---basically anywhere where you've
> run a complex command with an empty list of commands in it.

These four were all fairly easy; in each case there is a local context
where the command in question is being executed in which the status can
be reset.  There may be a a more generic place, such as execlist(), for
these to go, but I like the transparency of resetting them locally;
execlist()/execode() are used in just too many places.  However, that's
a bit craven.

Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.166
diff -u -r1.166 exec.c
--- Src/exec.c	10 Jul 2009 11:08:48 -0000	1.166
+++ Src/exec.c	10 Jul 2009 21:59:52 -0000
@@ -1372,7 +1372,8 @@
 	else
 	    spawnjob();
 	child_unblock();
-	return 0;
+	/* Executing background code resets shell status */
+	return lastval = 0;
     } else {
 	if (newjob != lastwj) {
 	    Job jn = jobtab + newjob;
@@ -3512,6 +3513,7 @@
 	return retval;
     }
     /* pid == 0 */
+    lastval = 0;		/* status of empty list is zero */
     child_unblock();
     zclose(pipes[0]);
     redup(pipes[1], 1);
@@ -4259,6 +4261,7 @@
     if (trap_state == TRAP_STATE_PRIMED)
 	trap_return--;
     oldlastval = lastval;
+    lastval = 0;		/* status of empty function is zero */
     oldnumpipestats = numpipestats;
     if (noreturnval) {
 	/*
Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.103
diff -u -r1.103 init.c
--- Src/init.c	9 Jul 2009 19:42:20 -0000	1.103
+++ Src/init.c	10 Jul 2009 21:59:52 -0000
@@ -1131,6 +1131,7 @@
     fstack.tp = FS_SOURCE;
     funcstack = &fstack;
 
+    lastval = 0;		/* status of empty file is zero */
     if (prog) {
 	pushheap();
 	errflag = 0;
Index: Test/A01grammar.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A01grammar.ztst,v
retrieving revision 1.23
diff -u -r1.23 A01grammar.ztst
--- Test/A01grammar.ztst	10 Jul 2009 11:08:48 -0000	1.23
+++ Test/A01grammar.ztst	10 Jul 2009 21:59:52 -0000
@@ -27,6 +27,18 @@
   $nonexistent_variable
 0:Executing command that evaluates to empty resets status
 
+  false
+  sleep 1 &
+  print $?
+  # a tidy test is a happy test
+  wait $!
+0:Starting background command resets status
+>0
+
+  false
+  . /dev/null
+0:Sourcing empty file resets status
+
   fn() { local foo; read foo; print $foo; }
   coproc fn
   print -p coproc test output
@@ -531,3 +543,13 @@
   . ./bad_syntax
 126: Attempt to "." file with bad syntax.
 ?./bad_syntax:2: parse error near `\n'
+
+  echo 'false' >dot_false
+  . ./dot_false
+  print $?
+  echo 'true' >dot_true
+  . ./dot_true
+  print $?
+0:Last status of successfully executed "." file is retained
+>1
+>0
Index: Test/C04funcdef.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/C04funcdef.ztst,v
retrieving revision 1.5
diff -u -r1.5 C04funcdef.ztst
--- Test/C04funcdef.ztst	29 Dec 2008 04:24:36 -0000	1.5
+++ Test/C04funcdef.ztst	10 Jul 2009 21:59:52 -0000
@@ -1,5 +1,20 @@
 %test
 
+  fn1() { return 1; }
+  fn2() {
+      fn1
+      print $?
+      return 2
+  }
+  fn2
+2:Basic status returns from functions
+>1
+
+  fnz() { }
+  false
+  fnz
+0:Empty function body resets status
+
   function f$$ () {
     print regress expansion of function names
   }
Index: Test/D08cmdsubst.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D08cmdsubst.ztst,v
retrieving revision 1.2
diff -u -r1.2 D08cmdsubst.ztst
--- Test/D08cmdsubst.ztst	9 Dec 2007 23:53:33 -0000	1.2
+++ Test/D08cmdsubst.ztst	10 Jul 2009 21:59:52 -0000
@@ -89,3 +89,7 @@
   X=$(exit 2) $(exit 0) || print $?
 0:variable assignments processed after other substitutions
 >2
+
+ false
+ ``
+0:Empty command substitution resets status


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


^ permalink raw reply	[relevance 0%]

* Re: non-interactive set -m
  @ 2009-07-11 23:16  3%   ` Eric Blake
  2009-07-12 15:01 18%     ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Eric Blake @ 2009-07-11 23:16 UTC (permalink / raw)
  To: zsh-workers

Peter Stephenson <p.w.stephenson <at> ntlworld.com> writes:

> 
> Peter Stephenson wrote:
> > (The other chunk is because we allow "jobs" to work in a subshell
> > so you can pipe its output---if you "set -m" you're effectively making
> > the shell the output for "jobs" twice.)
>            ^
> 
> The missing word is "save".  When you do "set -m" in the subshell you're
> wiping the record of the parent shell's job control---that's inevitable
> if you now want the subshell to do its own job control.
> 

POSIX says the following about sh:

A shell execution environment consists of the following:
...
Options turned on at invocation or by set
...
Process IDs of the last commands in asynchronous lists known to this shell
environment;
...
A subshell environment shall be created as a duplicate of the shell environment,
except that signal traps set by that shell environment shall be set to the
default values. 


It also says, for wait:

If it is called in a subshell or separate utility execution environment, such as
one of the following:
(wait)
...
it returns immediately because there are no known process IDs to wait for in
those environments.


I interpret this to mean that subshells of a parent process with job control on
must also have job control on, but that their list of tracked processes is nuked.

So we are getting closer, but still not there.

$ zsh -ci 'echo $-; (echo $-)'

should have identical output on both lines (the subshell should not lose the
fact that -m was set in the parent shell).

Likewise, I argue that this should follow bash's behavior, and not print
anything between 'got' and 'here' since there are no jobs known to the subshell:

$ zsh -ci 'sleep 1& (echo got; jobs; echo here)'

-- 
Eric Blake



^ permalink raw reply	[relevance 3%]

* Re: non-interactive set -m
  2009-07-11 23:16  3%   ` Eric Blake
@ 2009-07-12 15:01 18%     ` Peter Stephenson
  2009-07-12 18:28  4%       ` Bart Schaefer
  0 siblings, 1 reply; 200+ results
From: Peter Stephenson @ 2009-07-12 15:01 UTC (permalink / raw)
  To: zsh-workers

On Sat, 11 Jul 2009 23:16:51 +0000 (UTC)
Eric Blake <ebb9@byu.net> wrote:
> I interpret this to mean that subshells of a parent process with job
> control on must also have job control on, but that their list of
> tracked processes is nuked.

These look fairly straightforward, if we don't run into problems later
on.  They can be attached to POSIX_JOBS---that's why I gave it a generic
name originally.

This looks to me like quite a big change in the way background processes
from subshells work, but if it's what POSIX users expects that's
fine---I'm not expecting anyone to turn the option on just for fun.

Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.83
diff -u -r1.83 options.yo
--- Doc/Zsh/options.yo	10 Jul 2009 11:08:48 -0000	1.83
+++ Doc/Zsh/options.yo	12 Jul 2009 14:59:11 -0000
@@ -1280,10 +1280,26 @@
 pindex(NOPOSIXJOBS)
 cindex(bg, output in POSIX format)
 cindex(fg, output in POSIX format)
+cindex(job control, in subshell)
+cindex(jobs, output in subshell)
 item(tt(POSIX_JOBS) <K> <S>)(
-When putting jobs in the background or foreground with tt(bg) or tt(fg),
-just print the text of the job as required by POSIX,
-rather than the full information that would be output by tt(jobs).
+This option makes job control more compliant with the POSIX standard.
+
+When the option is not set, the tt(MONITOR) option is unset on entry to
+subshells, so that job control is no longer active.  When the option is
+set, the tt(MONITOR) option and job control remain active in the
+subshell, but note that the subshell has no access to jobs in the parent
+shell.
+
+When the option is not set, jobs put in the background or foreground
+with tt(bg) or tt(fg) are displayed with the same information that would
+be reported by tt(jobs).  When the option is set, only the text is
+printed.  The output from tt(jobs) itself is not affected by the option.
+
+When the option is not set, job information from the parent
+shell is saved for output within a subshell (for example, within a
+pipeline).  When the option is set, the output of tt(jobs) is empty
+unless job control has been activated within the subshell.
 )
 enditem()
 
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.169
diff -u -r1.169 exec.c
--- Src/exec.c	11 Jul 2009 19:06:52 -0000	1.169
+++ Src/exec.c	12 Jul 2009 14:59:12 -0000
@@ -944,7 +950,9 @@
     }
     if (!(sigtrapped[SIGQUIT] & ZSIG_IGNORED))
 	signal_default(SIGQUIT);
-    opts[MONITOR] = opts[USEZLE] = 0;
+    if (!isset(POSIXJOBS))
+	opts[MONITOR] = 0;
+    opts[USEZLE] = 0;
     zleactive = 0;
     if (flags & ESUB_PGRP)
 	clearjobtab(monitor);
Index: Src/jobs.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v
retrieving revision 1.70
diff -u -r1.70 jobs.c
--- Src/jobs.c	11 Jul 2009 19:06:52 -0000	1.70
+++ Src/jobs.c	12 Jul 2009 14:59:12 -0000
@@ -1292,6 +1292,8 @@
 {
     int i;
 
+    if (isset(POSIXJOBS))
+	oldmaxjob = 0;
     for (i = 1; i <= maxjob; i++) {
 	/*
 	 * See if there is a jobtable worth saving.
@@ -1299,7 +1301,7 @@
 	 * once for each subshell of a shell with job control,
 	 * so doesn't create a leak.
 	 */
-	if (monitor && jobtab[i].stat)
+	if (monitor && !isset(POSIXJOBS) && jobtab[i].stat)
 	    oldmaxjob = i+1;
 	else if (jobtab[i].stat & STAT_INUSE)
 	    freejob(jobtab + i, 0);


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


^ permalink raw reply	[relevance 18%]

* Re: non-interactive set -m
  2009-07-12 15:01 18%     ` Peter Stephenson
@ 2009-07-12 18:28  4%       ` Bart Schaefer
  2009-07-12 19:35  0%         ` Peter Stephenson
  2009-07-13 13:20  0%         ` Eric Blake
  0 siblings, 2 replies; 200+ results
From: Bart Schaefer @ 2009-07-12 18:28 UTC (permalink / raw)
  To: zsh-workers

On Jul 12,  4:01pm, Peter Stephenson wrote:
}
} This looks to me like quite a big change in the way background processes
} from subshells work, but if it's what POSIX users expects that's
} fine---I'm not expecting anyone to turn the option on just for fun.

If zsh was previously in the wrong here, then so is pdksh:

schaefer[507] ksh                                                         4.2.0
$ sleep 30 &
[1] 14322
$ (jobs)
[1] + Running              sleep 30 
$ jobs | head
[1] + Running              sleep 30 
$ (wait)
$ (fg)
ksh: fg: job control not enabled
$ [1] + Done                 sleep 30 

Now, in pdksh "jobs | head" the "jobs" command is in the foreground
shell and "head" is forked off, whereas in zsh both "jobs" and "head"
will have been forked because of handling of this case ...

$ jobs | read line
$ echo $line

$ jobs | { read line; echo $line;}
[1] + Running sleep 30
$ 

... where in zsh the first "echo $line" will work (but won't any more
with this patch and POSIX_JOBS set).

POSIX doesn't specify whether the left or right side of a pipeline
will run in the current shell, which means that with POSIX_JOBS set
and this patch applied zsh will produce different results for the
piping of "jobs" to something.  Since it's only been about a year (?)
since we went through all the rigamarole of making "jobs" in a sub-
shell have access to (a snapshot of) the parent's job table, it seems
hasty to break that again even an as option.

Also look here:

$ sleep 30 &
[1] 14341
$ ( sleep 40 & jobs )
[2] + Running              sleep 40 
[1] - Running              sleep 30 
$ 

Note that in pdksh the job in the subshell is added to the table of
jobs inherited from the parent shell (testing with pdksh 5.2.14).

This may be something we should ask about on the austin-group list
before we select an interpretation and implement it.  I'm currently
not able to post there because of some problem with the listserv's
interpretation of the "+" in the email address I used to sign up.


^ permalink raw reply	[relevance 4%]

* Re: non-interactive set -m
  2009-07-12 18:28  4%       ` Bart Schaefer
@ 2009-07-12 19:35  0%         ` Peter Stephenson
  2009-07-12 21:19  4%           ` Bart Schaefer
  2009-07-13 13:20  0%         ` Eric Blake
  1 sibling, 1 reply; 200+ results
From: Peter Stephenson @ 2009-07-12 19:35 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer wrote:
> POSIX doesn't specify whether the left or right side of a pipeline
> will run in the current shell, which means that with POSIX_JOBS set
> and this patch applied zsh will produce different results for the
> piping of "jobs" to something.  Since it's only been about a year (?)
> since we went through all the rigamarole of making "jobs" in a sub-
> shell have access to (a snapshot of) the parent's job table, it seems
> hasty to break that again even an as option.

It seems to me it should one thing or the other---either have job
control in the shell with its own separate job table, or report the
parent's.  A mixture is madness.

> Also look here:
> 
> $ sleep 30 &
> [1] 14341
> $ ( sleep 40 & jobs )
> [2] + Running              sleep 40 
> [1] - Running              sleep 30 
> $ 
> 
> Note that in pdksh the job in the subshell is added to the table of
> jobs inherited from the parent shell (testing with pdksh 5.2.14).

Yuk.  So you've got a real job you can manipulate, and one phantom job
from the parent shell you can't and which is presumably fixed like that
for eternity.  In other words, pdksh (unlike zsh) doesn't clear the job
table while keeping a copy of the parent's around, it just uses the same
job table.  This doesn't strike me as the right way to do it.

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


^ permalink raw reply	[relevance 0%]

* Re: non-interactive set -m
  2009-07-12 19:35  0%         ` Peter Stephenson
@ 2009-07-12 21:19  4%           ` Bart Schaefer
  2009-07-13  1:48  3%             ` Eric Blake
  0 siblings, 1 reply; 200+ results
From: Bart Schaefer @ 2009-07-12 21:19 UTC (permalink / raw)
  To: zsh-workers

On Jul 12,  8:35pm, Peter Stephenson wrote:
} Subject: Re: non-interactive set -m
}
} Bart Schaefer wrote:
} > POSIX doesn't specify whether the left or right side of a pipeline
} > will run in the current shell, which means that with POSIX_JOBS set
} > and this patch applied zsh will produce different results for the
} > piping of "jobs" to something.
} 
} It seems to me it should one thing or the other---either have job
} control in the shell with its own separate job table, or report the
} parent's.  A mixture is madness.

I agree with *that*, but I'm wondering if the end result is that the
POSIX spec is self-contradictory [it wouldn't be the first time].
 
} > Note that in pdksh the job in the subshell is added to the table of
} > jobs inherited from the parent shell (testing with pdksh 5.2.14).
} 
} Yuk.  So you've got a real job you can manipulate, and one phantom job
} from the parent shell you can't and which is presumably fixed like that
} for eternity.

No, actually, you have two jobs neither of which you can manipulate.
PDKSH doesn't do job control in subshells.  It turns off -m when the
subshell starts, and silently ignores it if you manually turn it back
on again.


^ permalink raw reply	[relevance 4%]

* Re: non-interactive set -m
  2009-07-12 21:19  4%           ` Bart Schaefer
@ 2009-07-13  1:48  3%             ` Eric Blake
  0 siblings, 0 replies; 200+ results
From: Eric Blake @ 2009-07-13  1:48 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer <schaefer <at> brasslantern.com> writes:

> } > Note that in pdksh the job in the subshell is added to the table of
> } > jobs inherited from the parent shell (testing with pdksh 5.2.14).
> } 
> } Yuk.  So you've got a real job you can manipulate, and one phantom job
> } from the parent shell you can't and which is presumably fixed like that
> } for eternity.
> 
> No, actually, you have two jobs neither of which you can manipulate.
> PDKSH doesn't do job control in subshells.  It turns off -m when the
> subshell starts, and silently ignores it if you manually turn it back
> on again.

My opinion is that pdksh is somewhat buggy when it comes to job handling, and
that you are better off trying to emulate David Korn's ksh93 than the buggy
pdksh; other better examples are dash and bash.  I already quoted the parts of
POSIX that mention that subshells inherit the same options as the parent (so the
pdksh behavior of silently disabling -m in a subshell violates that rule).

-- 
Eric Blake



^ permalink raw reply	[relevance 3%]

* Re: non-interactive set -m
  2009-07-12 18:28  4%       ` Bart Schaefer
  2009-07-12 19:35  0%         ` Peter Stephenson
@ 2009-07-13 13:20  0%         ` Eric Blake
  1 sibling, 0 replies; 200+ results
From: Eric Blake @ 2009-07-13 13:20 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer <schaefer <at> brasslantern.com> writes:

> POSIX doesn't specify whether the left or right side of a pipeline
> will run in the current shell, which means that with POSIX_JOBS set
> and this patch applied zsh will produce different results for the
> piping of "jobs" to something.

This is similar to the issue of traps being reset in a subshell - see
http://austingroupbugs.net/view.php?id=53 for recent Austin group comments on
that related topic.  I've gone ahead and added a comment to that report about
the question on shell options and jobs across subshells.

-- 
Eric Blake



^ permalink raw reply	[relevance 0%]

* cd bugs
@ 2009-07-14 21:59  5% Eric Blake
  2009-07-14 22:30  4% ` Eric Blake
                   ` (2 more replies)
  0 siblings, 3 replies; 200+ results
From: Eric Blake @ 2009-07-14 21:59 UTC (permalink / raw)
  To: zsh-workers

POSIX requires cd to give output if a nonempty entry in CDPATH played a role, or
if 'cd -' was used.  Therefore, this line demonstrates two zsh bugs:

$ zsh -c 'emulate -R sh; cd /tmp; mkdir -p d; CDPATH=.; cd d; cd -; rmdir d'
$ bash -c 'cd /tmp; mkdir -p d; CDPATH=.; cd d; cd -; rmdir d'
/tmp/d
/tmp
$

while bash was correct in printing the absolute name of d and its parent.

When fixing this, be sure that you don't break

$ zsh -c 'emulate -R sh; mkdir foo; CDPATH=:; cd foo'

since POSIX states that particular use must remain silent (an implicit . used
from an empty CDPATH entry is different than an explicit . in CDPATH).

Another bug, mainly visible on platforms like cygwin where leading // is special
as allowed by POSIX (in particular, on my cygwin machin, //eblake exists but not
/eblake):

$ zsh -c 'emulate -R sh; CDPATH=///; cd eblake; /bin/pwd'
//eblake
$ bash -c 'CDPATH=///; cd eblake; /bin/pwd'
bash: line 0: cd: eblake: No such file or directory
/tmp
$

Since POSIX requires ///eblake to be synonymous with /eblake, and /eblake does
not exist, only bash was correct in printing an error and not changing location.

-- 
Eric Blake



^ permalink raw reply	[relevance 5%]

* Re: cd bugs
  2009-07-14 21:59  5% cd bugs Eric Blake
@ 2009-07-14 22:30  4% ` Eric Blake
  2009-07-19 19:00  8%   ` Peter Stephenson
  2009-07-15  3:28  4% ` Eric Blake
  2009-07-21  9:22  4% ` Peter Stephenson
  2 siblings, 1 reply; 200+ results
From: Eric Blake @ 2009-07-14 22:30 UTC (permalink / raw)
  To: zsh-workers

Eric Blake <ebb9 <at> byu.net> writes:

> 
> POSIX requires cd to give output if a nonempty entry in CDPATH played a role,
> or if 'cd -' was used.  Therefore, this line demonstrates two zsh bugs:
> 
> $ zsh -c 'emulate -R sh; cd /tmp; mkdir -p d; CDPATH=.; cd d; cd -; rmdir d'
> $ bash -c 'cd /tmp; mkdir -p d; CDPATH=.; cd d; cd -; rmdir d'
> /tmp/d
> /tmp
> $
> 
> while bash was correct in printing the absolute name of d and its parent.

Another bug - POSIX requires that CDPATH be searched prior to ., regardless of
whether CDPATH contains an explicit . or an empty entry.  Therefore, this is
another example where bash is right.  But I think the zsh native behavior of
favoring . over CDPATH if CDPATH does not include . is a little more intuitive,
so this may warrant the addition of a new shell option (POSIX_CD?) that defaults
to off in zsh mode but defaults to on in sh mode for POSIX compliance.

$ zsh -c 'emulate -R sh; cd /tmp; mkdir -p a/b b; CDPATH=a; cd b; /bin/pwd'
/tmp/b
$ bash -c 'cd /tmp; mkdir -p a/b b; CDPATH=a; cd b; /bin/pwd'
/tmp/a/b
/tmp/a/b
$ cd /tmp; rm -Rf a b
$

-- 
Eric Blake



^ permalink raw reply	[relevance 4%]

* Re: cd bugs
  2009-07-14 21:59  5% cd bugs Eric Blake
  2009-07-14 22:30  4% ` Eric Blake
@ 2009-07-15  3:28  4% ` Eric Blake
  2009-07-21  9:22  4% ` Peter Stephenson
  2 siblings, 0 replies; 200+ results
From: Eric Blake @ 2009-07-15  3:28 UTC (permalink / raw)
  To: zsh-workers

Eric Blake <ebb9 <at> byu.net> writes:

> $ zsh -c 'emulate -R sh; CDPATH=///; cd eblake; /bin/pwd'
> //eblake
> $ bash -c 'CDPATH=///; cd eblake; /bin/pwd'
> bash: line 0: cd: eblake: No such file or directory
> /tmp
> $

Of the three examples mentioned in this thread, this one is definitely a bug,
but one that only affects platforms where // is special (which, based on the
__CYGWIN__ conditional in the source, appears to be just cygwin).

The other two items mentioned in this thread are POSIX-compliance issues, but as
was pointed out to me off-list, changing them to obey POSIX is a feature request
and not a bug fix.  Unfortunately, while I'd like to help code it up, I'm not
sure how to go about adding a new option to implement POSIX semantics in cd
handling.  Besides adding a new option, one part is simple (in cd_do_chdir, set
hasdot to 1 and fake an implicit '.' entry at the end of cdpath if the POSIX_CD
option is set), the other part is a bit more complex (cdpath has to
differentiate between an explicit "." in CDPATH, which increments doprintdir,
and an implicit '.' due to an explicit empty entry or the implicit '.' added
from the first part of the fix, whereas right now the cdpath variable has
already converted implicit '.' to explicit "." in the array).

Actually, in looking at this patch again, I'm starting to wonder if it might be
better to teach tricat that if the first argument ends in '/' and the second
argument is exactly "/", then it does not need to use the second argument; this
would certainly make it touch all code paths that do file name concatenation,
rather than trying to change down and protect every caller of tricat with
__CYGWIN__ conditionals.  In other words, there are probably also bugs with ~
expansion when $HOME is exactly / or //, as well as other potential gotchas with
// handling that I haven't even investigated here.


From: Eric Blake <ebb9@byu.net>
Date: Tue, 14 Jul 2009 21:01:03 -0600
Subject: [PATCH] Eric Blake: 27149: fix // handling in cd for cygwin

---
 ChangeLog     |    5 +++++
 Src/builtin.c |   14 ++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4255d6f..b9d6dbd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-07-14  Eric Blake  <ebb9@byu.net>
+
+	* Eric Blake: 27149: Src/builtin.c: Fix // handling in cd for
+	cygwin.
+
 2009-07-14  Peter Stephenson  <pws@csr.com>

 	* Andy Spencer: 27148: Completion/Linux/Command/_modutils:
diff --git a/Src/builtin.c b/Src/builtin.c
index 62c6e3c..56cc916 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -1029,17 +1029,19 @@ cd_try_chdir(char *pfix, char *dest, int hard)

     /* handle directory prefix */
     if (pfix && *pfix) {
-	if (*pfix == '/')
+	if (*pfix == '/') {
 #ifdef __CYGWIN__
 /* NB: Don't turn "/"+"bin" into "//"+"bin" by mistake!  "//bin" may *
  * not be what user really wants (probably wants "/bin"), but        *
  * "//bin" could be valid too (see fixdir())!  This is primarily for *
- * handling CDPATH correctly.                                        */
-	    buf = tricat(pfix, ( pfix[1] == '\0' ? "" : "/" ), dest);
+ * handling CDPATH correctly.  Likewise for "//"+"bin" not becoming  *
+ * "///bin" (aka "/bin").                                            */
+	    int root = pfix[1] == '\0' || (pfix[1] == '/' && pfix[2] == '\0');
+	    buf = tricat(pfix, ( root ? "" : "/" ), dest);
 #else
 	    buf = tricat(pfix, "/", dest);
 #endif
-	else {
+	} else {
 	    int pfl = strlen(pfix);
 	    dlen = strlen(pwd);

@@ -1200,8 +1202,8 @@ fixdir(char *src)
 	/* compress multiple /es into single */
 	if (*src == '/') {
 #ifdef __CYGWIN__
-	    /* allow leading // under cygwin */
-	    if (src == s0 && src[1] == '/')
+	    /* allow leading // under cygwin, but /// still becomes / */
+	    if (src == s0 && src[1] == '/' && src[2] != '/')
 		*dest++ = *src++;
 #endif
 	    *dest++ = *src++;
-- 
1.6.3.3.334.g916e1




^ permalink raw reply	[relevance 4%]

* Re: cd bugs
  2009-07-14 22:30  4% ` Eric Blake
@ 2009-07-19 19:00  8%   ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2009-07-19 19:00 UTC (permalink / raw)
  To: zsh-workers

On Tue, 14 Jul 2009 22:30:33 +0000 (UTC)
Eric Blake <ebb9@byu.net> wrote:
> Another bug - POSIX requires that CDPATH be searched prior to ., regardless of
> whether CDPATH contains an explicit . or an empty entry.

Here's the option for this---obviously the other POSIX behaviour can be
associated with it, I just haven't done that here.

I also haven't bothered with optimising the case where we already tested
"." within CDPATH, it's not worth the extra code.

Index: Doc/Zsh/builtins.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v
retrieving revision 1.123
diff -u -r1.123 builtins.yo
--- Doc/Zsh/builtins.yo	2 Jul 2009 13:48:29 -0000	1.123
+++ Doc/Zsh/builtins.yo	19 Jul 2009 18:56:20 -0000
@@ -183,6 +183,9 @@
 successful.  If `tt(.)' occurs in tt(cdpath), then tt(cdpath) is searched
 strictly in order so that `tt(.)' is only tried at the appropriate point.
 
+The order of testing tt(cdpath) is modified if the option tt(POSIX_CD)
+is set, as described in the documentation for the option.
+
 If no directory is found, the option tt(CDABLE_VARS) is set, and a
 parameter named var(arg) exists whose value begins with a slash, treat its
 value as the directory.  In that case, the parameter is added to the named
Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.84
diff -u -r1.84 options.yo
--- Doc/Zsh/options.yo	12 Jul 2009 15:10:07 -0000	1.84
+++ Doc/Zsh/options.yo	19 Jul 2009 18:56:21 -0000
@@ -115,6 +115,22 @@
 will be treated as referring to the physical parent, even if the preceding
 path segment is a symbolic link.
 )
+pindex(POSIX_CD)
+pindex(POSIXCD)
+pindex(NO_POSIX_CD)
+pindex(NOPOSIXCD)
+cindex(CDPATH, order of checking)
+item(tt(POSIX_CD))(
+Modifies the behaviour of tt(cd), tt(chdir) and tt(pushd) commands
+to make them more compatible with the POSIX standard. The behaviour with
+the option unset is described in the documentation for the tt(cd)
+builtin in
+ifzman(zmanref(zshbuiltins))\
+ifnzman(noderef(Shell Builtin Commands)).
+If the option is set, the shell does not test for directories beneath
+the local directory (`tt(.)') until after all directories in tt(cdpath)
+have been tested.
+)
 pindex(PUSHD_IGNORE_DUPS)
 pindex(NO_PUSHD_IGNORE_DUPS)
 pindex(PUSHDIGNOREDUPS)
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.231
diff -u -r1.231 builtin.c
--- Src/builtin.c	15 Jul 2009 08:43:31 -0000	1.231
+++ Src/builtin.c	19 Jul 2009 18:56:21 -0000
@@ -945,14 +945,23 @@
 	return NULL;
     }
 
-    /* if cdpath is being used, check it for . */
-    if (!nocdpath)
+    /*
+     * If cdpath is being used, check it for ".".
+     * Don't bother doing this if POSIXCD is set, we don't
+     * need to know (though it doesn't actually matter).
+     */
+    if (!nocdpath && !isset(POSIXCD))
 	for (pp = cdpath; *pp; pp++)
 	    if (!(*pp)[0] || ((*pp)[0] == '.' && (*pp)[1] == '\0'))
 		hasdot = 1;
-    /* if there is no . in cdpath (or it is not being used), try the directory
-       as-is (i.e. from .) */
-    if (!hasdot) {
+    /*
+     * If 
+     * (- there is no . in cdpath
+     *  - or cdpath is not being used)
+     *  - and the POSIXCD option is not set
+     * try the directory as-is (i.e. from .)
+     */
+    if (!hasdot && !isset(POSIXCD)) {
 	if ((ret = cd_try_chdir(NULL, dest, hard)))
 	    return ret;
 	if (errno != ENOENT)
@@ -971,6 +980,15 @@
 	    if (errno != ENOENT)
 		eno = errno;
 	}
+    /*
+     * POSIX requires us to check "." after CDPATH rather than before.
+     */
+    if (isset(POSIXCD)) {
+	if ((ret = cd_try_chdir(NULL, dest, hard)))
+	    return ret;
+	if (errno != ENOENT)
+	    eno = errno;
+    }
 
     /* handle the CDABLEVARS option */
     if ((ret = cd_able_vars(dest))) {
Index: Src/options.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/options.c,v
retrieving revision 1.50
diff -u -r1.50 options.c
--- Src/options.c	10 Jul 2009 11:08:48 -0000	1.50
+++ Src/options.c	19 Jul 2009 18:56:22 -0000
@@ -200,6 +200,7 @@
 {{NULL, "pathdirs",	      OPT_EMULATE},		 PATHDIRS},
 {{NULL, "posixaliases",       OPT_EMULATE|OPT_BOURNE},	 POSIXALIASES},
 {{NULL, "posixbuiltins",      OPT_EMULATE|OPT_BOURNE},	 POSIXBUILTINS},
+{{NULL, "posixcd",            OPT_EMULATE|OPT_BOURNE},	 POSIXCD},
 {{NULL, "posixidentifiers",   OPT_EMULATE|OPT_BOURNE},	 POSIXIDENTIFIERS},
 {{NULL, "posixjobs",          OPT_EMULATE|OPT_BOURNE},	 POSIXJOBS},
 {{NULL, "printeightbit",      0},                        PRINTEIGHTBIT},
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.160
diff -u -r1.160 zsh.h
--- Src/zsh.h	11 Jul 2009 16:43:00 -0000	1.160
+++ Src/zsh.h	19 Jul 2009 18:56:22 -0000
@@ -1966,6 +1966,7 @@
     PATHDIRS,
     POSIXALIASES,
     POSIXBUILTINS,
+    POSIXCD,
     POSIXIDENTIFIERS,
     POSIXJOBS,
     PRINTEIGHTBIT,


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


^ permalink raw reply	[relevance 8%]

* Re: cd bugs
  2009-07-14 21:59  5% cd bugs Eric Blake
  2009-07-14 22:30  4% ` Eric Blake
  2009-07-15  3:28  4% ` Eric Blake
@ 2009-07-21  9:22  4% ` Peter Stephenson
  2 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2009-07-21  9:22 UTC (permalink / raw)
  To: zsh-workers

On Tue, 14 Jul 2009 21:59:14 +0000 (UTC)
Eric Blake <ebb9@byu.net> wrote:
> POSIX requires cd to give output if a nonempty entry in CDPATH played a
> role, or if 'cd -' was used.  Therefore, this line demonstrates two zsh
> bugs:
>
> $ zsh -c 'emulate -R sh; cd /tmp; mkdir -p d; CDPATH=.; cd d; cd -; rmdir d'
> $ bash -c 'cd /tmp; mkdir -p d; CDPATH=.; cd d; cd -; rmdir d'
> /tmp/d
> /tmp
> $
>
> while bash was correct in printing the absolute name of d and its parent.
>
> When fixing this, be sure that you don't break
>
> $ zsh -c 'emulate -R sh; mkdir foo; CDPATH=:; cd foo'
>
> since POSIX states that particular use must remain silent (an implicit . used
> from an empty CDPATH entry is different than an explicit . in CDPATH).

I think this should make the POSIX_CD option behave appropriately.

Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.85
diff -u -r1.85 options.yo
--- Doc/Zsh/options.yo	19 Jul 2009 19:08:49 -0000	1.85
+++ Doc/Zsh/options.yo	21 Jul 2009 09:20:37 -0000
@@ -130,6 +130,14 @@
 If the option is set, the shell does not test for directories beneath
 the local directory (`tt(.)') until after all directories in tt(cdpath)
 have been tested.
+
+Also, if the option is set, the conditions under which the shell
+prints the new directory after changing to it are modified.  It is
+no longer restricted to interactive shells (although printing of
+the directory stack with tt(pushd) is still limited to interactive
+shells); and any use of a component of tt(CDPATH), including a `tt(.)' but
+excluding an empty component that is otherwise treated as `tt(.)', causes
+the directory to be printed.
 )
 pindex(PUSHD_IGNORE_DUPS)
 pindex(NO_PUSHD_IGNORE_DUPS)
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.232
diff -u -r1.232 builtin.c
--- Src/builtin.c	19 Jul 2009 19:08:50 -0000	1.232
+++ Src/builtin.c	21 Jul 2009 09:20:37 -0000
@@ -972,8 +972,19 @@
     if (!nocdpath)
 	for (pp = cdpath; *pp; pp++) {
 	    if ((ret = cd_try_chdir(*pp, dest, hard))) {
-		if (strcmp(*pp, ".")) {
-		    doprintdir++;
+		if (isset(POSIXCD)) {
+		    /*
+		     * For POSIX we need to print the directory
+		     * any time CDPATH was used, except in the
+		     * special case of an empty segment being
+		     * treated as a ".".
+		     */
+		    if (**pp)
+			doprintdir++;
+		}  else {
+		    if (strcmp(*pp, ".")) {
+			doprintdir++;
+		    }
 		}
 		return ret;
 	    }
@@ -1146,8 +1157,8 @@
     pwd = new_pwd;
     set_pwd_env();
 
-    if (isset(INTERACTIVE)) {
-	if (func != BIN_CD) {
+    if (isset(INTERACTIVE) || isset(POSIXCD)) {
+	if (func != BIN_CD && isset(INTERACTIVE)) {
             if (unset(PUSHDSILENT) && !quiet)
 	        printdirstack();
         } else if (doprintdir) {


-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


'member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom'


^ permalink raw reply	[relevance 4%]

* Re: zsh 4.3.10 terminates with SIGINT when one types Ctrl-G in emacs under Mac OS X
  @ 2009-07-22  2:58  3%                   ` Eric Blake
  2009-07-22  8:16  0%                     ` Vincent Lefevre
  0 siblings, 1 reply; 200+ results
From: Eric Blake @ 2009-07-22  2:58 UTC (permalink / raw)
  To: zsh-workers

Vincent Lefevre <vincent <at> vinc17.org> writes:

> 
> Sorry, I was not enough clear. I meant that bash restores the trap
> to the behavior at the time that bash was called. But it seems to
> be something different, something like if SIGINT is ignored when
> bash is executed, a "trap command INT" has no effect unless both
> bash and its child receive a SIGINT. Now, this behavior is a bit
> strange, maybe a bug.

POSIX requires that if a shell starts life with a signal ignored, that the shell
should silently reject attempts to alter the fact that the signal is ignored
(either back to a default, or to a user-specified handler).  Which is very
annoying if your shell ever gets started with SIGPIPE ignored, but that's life.
 In other words, if you start bash with SIGINT ignored, you can't undo that from
within the bash shell.

-- 
Eric Blake



^ permalink raw reply	[relevance 3%]

* Re: zsh 4.3.10 terminates with SIGINT when one types Ctrl-G in emacs under Mac OS X
  2009-07-22  2:58  3%                   ` Eric Blake
@ 2009-07-22  8:16  0%                     ` Vincent Lefevre
  0 siblings, 0 replies; 200+ results
From: Vincent Lefevre @ 2009-07-22  8:16 UTC (permalink / raw)
  To: zsh-workers

On 2009-07-22 02:58:37 +0000, Eric Blake wrote:
> POSIX requires that if a shell starts life with a signal ignored,
> that the shell should silently reject attempts to alter the fact
> that the signal is ignored (either back to a default, or to a
> user-specified handler). Which is very annoying if your shell ever
> gets started with SIGPIPE ignored, but that's life. In other words,
> if you start bash with SIGINT ignored, you can't undo that from
> within the bash shell.

OK, thanks for the explanations. So, the following script shows a bug
in zsh (typing Ctrl-C immediately interrupts the sleep and the script
and SIGINT is output):

#!/bin/sh

trap ''  INT
zsh -fc "emulate sh; trap 'echo SIGINT; exit' INT; sleep 6"

I wonder whether zsh should behave in the same way without
"emulate sh".

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)


^ permalink raw reply	[relevance 0%]

* Re: unable to wait on completed job [was: should $! give the pid of subshell?]
       [not found]         ` <091129211436.ZM1769@torch.brasslantern.com>
@ 2009-11-30 18:37  0%       ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2009-11-30 18:37 UTC (permalink / raw)
  To: zsh-workers

On Sun, 29 Nov 2009 21:14:36 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> [schaefer@torch]$ (sleep 10; exit 19) &
> [1] 1680
> [schaefer@torch]$ pid=$!
> [schaefer@torch]$ sleep 12; wait $pid
> [1]+  Exit 19                 ( sleep 10; exit 19 )
> bash: wait: pid 1680 is not a child of this shell
>>..
> Apparently POSIX.2 requires "wait" be able to access the exit status
> of an asynchronous job until the next asynchronous job is started.
> Zsh is only able to access that status until the next job (whether
> synchronous or not) completes; the completion of "sleep 12" clears
> the previously-completed "sleep 10 &" from the job table, so "wait"
> is no longer able to see it.

(Moved to zsh-workers.)

If it's only an issue for $! (lastpid internally), I think it's fairly
straightforward to fix.  I tried to make it work even if a new process with
the same PID came along later.

No idea about anything to do with SIGTTOU, however, that's outside my
range.

Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.172
diff -u -r1.172 exec.c
--- Src/exec.c	22 Sep 2009 09:17:10 -0000	1.172
+++ Src/exec.c	30 Nov 2009 18:34:17 -0000
@@ -2727,6 +2727,8 @@
 #endif
 	    if (how & Z_ASYNC) {
 		lastpid = (zlong) pid;
+		/* indicate it's possible to set status for lastpid */
+		lastpid_status = -2L;
 	    } else if (!jobtab[thisjob].stty_in_env && varspc) {
 		/* search for STTY=... */
 		Wordcode p = varspc;
Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.106
diff -u -r1.106 init.c
--- Src/init.c	12 Jul 2009 15:10:07 -0000	1.106
+++ Src/init.c	30 Nov 2009 18:34:18 -0000
@@ -913,6 +913,7 @@
     bufstack = znewlinklist();
     hsubl = hsubr = NULL;
     lastpid = 0;
+    lastpid_status = -1L;
     bshin = SHIN ? fdopen(SHIN, "r") : stdin;
     if (isset(SHINSTDIN) && !SHIN && unset(INTERACTIVE)) {
 #ifdef _IONBF
Index: Src/jobs.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v
retrieving revision 1.73
diff -u -r1.73 jobs.c
--- Src/jobs.c	30 Sep 2009 20:32:49 -0000	1.73
+++ Src/jobs.c	30 Nov 2009 18:34:18 -0000
@@ -104,6 +104,15 @@
 /**/
 int numpipestats, pipestats[MAX_PIPESTATS];
 
+/*
+ * The status associated with the process lastpid.
+ * -1 if not set and no associated lastpid
+ * -2 if lastpid is set and status isn't yet
+ * else the value returned by wait().
+ */
+/**/
+long lastpid_status;
+
 /* Diff two timevals for elapsed-time computations */
 
 /**/
@@ -1109,6 +1118,14 @@
 {
     Process pn, *pnlist;
 
+    if (pid == lastpid && lastpid_status != -2L) {
+	/*
+	 * The status for the previous lastpid is invalid.
+	 * Presumably process numbers have wrapped.
+	 */
+	lastpid_status = -1L;
+    }
+
     DPUTS(thisjob == -1, "No valid job in addproc.");
     pn = (Process) zshcalloc(sizeof *pn);
     pn->pid = pid;
@@ -1845,6 +1862,8 @@
 		retval = waitforpid(pid, 1);
 		if (!retval)
 		    retval = lastval2;
+	    } else if (pid == lastpid && lastpid_status >= 0L) {
+		retval = (int)lastpid_status;
 	    } else {
 		zwarnnam(name, "pid %d is not a child of this shell", pid);
 		/* presumably lastval2 doesn't tell us a heck of a lot? */
Index: Src/signals.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/signals.c,v
retrieving revision 1.56
diff -u -r1.56 signals.c
--- Src/signals.c	20 Jul 2009 04:38:56 -0000	1.56
+++ Src/signals.c	30 Nov 2009 18:34:18 -0000
@@ -530,6 +530,7 @@
 	     * Find the process and job containing this pid and
 	     * update it.
 	     */
+	    pn = NULL;
 	    if (findproc(pid, &jn, &pn, 0)) {
 #if defined(HAVE_WAIT3) && defined(HAVE_GETRUSAGE)
 		struct timezone dummy_tz;
@@ -551,6 +552,15 @@
 		 */
 		get_usage();
 	    }
+	    /*
+	     * Remember the status associated with $!, so we can
+	     * wait for it even if it's exited.  This value is
+	     * only used if we can't find the PID in the job table,
+	     * so it doesn't matter that the value we save here isn't
+	     * useful until the process has exited.
+	     */
+	    if (pn != NULL && pid == lastpid && lastpid_status != -1L)
+		lastpid_status = lastval2;
 	}
         break;
  


-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[relevance 0%]

* Re: [PATCH] run-help: ugly workaround for run-help-$X with alias for $X
@ 2009-12-14 11:40  3% Jörg Sommer
  0 siblings, 0 replies; 200+ results
From: Jörg Sommer @ 2009-12-14 11:40 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1381 bytes --]

Hi Peter,

Peter Stephenson <pws@csr.com> wrote:
> Index: Functions/Misc/run-help
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Functions/Misc/run-help,v
> retrieving revision 1.16
> diff -u -r1.16 run-help
> --- Functions/Misc/run-help	5 Jun 2009 11:18:01 -0000	1.16
> +++ Functions/Misc/run-help	10 Dec 2009 09:48:44 -0000
> @@ -49,6 +49,7 @@
>    noalias=1
>  fi
>  
> +{
>  while ((i++ < $#places))
>  do
>      what=$places[$i]
> @@ -56,7 +57,8 @@
>      builtin print -r $what
>      case $what in
>      (*( is an alias)*)
> -	[[ ${what[(w)6]:t} != ${what[(w)1]} ]] && run-help ${what[(w)6]:t}
> +	[[ ${what[(w)6]:t} != ${what[(w)1]} ]] &&
> +	  run_help_orig_cmd=${what[(w)1]} run-help ${what[(w)6]:t}

> +} always {
> +  unset run_help_orig_cmd
> +}

Why do you need the unset here? In Posix shell an expression “VAR=xy
cmd” exports the variable VAR only to the command cmd, but doesn't export
or set it in the current environment. I zsh different here?

Bye, Jörg.
-- 
IRC: Der [Prof. Andreas Pfitzmann, TU Dresden] hat gerade vorgeschlagen, sie
  sollen doch statt Trojanern die elektromagnetische Abstrahlung nutzen. Das
  sei nicht massenfähig, ginge ohne Eingriff ins System, sei zielgerichtet,
  und, der Hammer, das funktioniere ja bei Wahlcomputern schon sehr gut.

[-- Attachment #2: Digital signature http://en.wikipedia.org/wiki/OpenPGP --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[relevance 3%]

* Fwd: command substitutions starting with $((
       [not found]             ` <20091222113413.GA9234@squonk.masqnet>
@ 2009-12-22 22:02  3%           ` Bart Schaefer
  0 siblings, 0 replies; 200+ results
From: Bart Schaefer @ 2009-12-22 22:02 UTC (permalink / raw)
  To: zsh-workers

Tail of a fairly interesting thread on the austin-group (POSIX) list.


---------- Forwarded message ----------
From: Geoff Clare <gwc@opengroup.org>
Date: Tue, Dec 22, 2009 at 3:34 AM
Subject: Re: command substitutions starting with $((
To: austin-group-l@opengroup.org


Philip Guenther <guenther@gmail.com> wrote, on 21 Dec 2009:
>
> On Mon, Dec 21, 2009 at 9:53 AM, Geoff Clare <gwc@opengroup.org> wrote:
> ...
> > Are you claiming there are text sequences such that $((text)) is
> > syntactically valid both as an arithmetic substitution and as a
> > command substitution, and it is not a "single subshell" command
> > substitution?
> >
> > Unless such text sequences exist, it seems clear that the shell is
> > required to distinguish between the two cases based on which one the
> > syntax is valid for.
>
> How about:
>
> cat=1 ; EOH=3; echo $(( cat <<EOH
> + ( (
> EOH
> ) && ( cat <<EOH
> ) ) + 1 +
> EOH
> ))

<Applause> We have a winner.  I'm impressed :-)

This means we do need to make a change to the standard.  The tricky
part is going to be deciding exactly what to change.

Since it's a simple matter for application writers to use "$( ("
instead of "$((" when they are writing a command substitution
that starts with a subshell, I think it would be appropriate for
the standard to say that arithmetic expansion has precedence.
I.e. if $(( introduces a syntactically valid arithmetic expansion,
then an arithmetic expansion will be performed.  Otherwise if $((
introduces a syntactically valid command substitution, then a
command substitution will be performed.  If the syntax is valid
for neither, then it is unspecified what kind of syntax error the
shell reports.  (Or a modification of this which retains the
"single subshell" rule.)

This appears to match what current shells do.  All the shells I
tried Philip's example in output 256.

--
Geoff Clare <g.clare@opengroup.org>
The Open Group, Thames Tower, Station Road, Reading, RG1 1LX, England


^ permalink raw reply	[relevance 3%]

* Re: cp file with a filter
  @ 2010-01-18  9:56  3%   ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2010-01-18  9:56 UTC (permalink / raw)
  To: Zsh hackers list

Bart Schaefer wrote:
> On Jan 17,  9:30pm, Peter Stephenson wrote:
> }
> } Talking of annoying inconsistencies, this updates the patch to work when
> } pcre is used for regex matching and fixes the pcre behaviour (and
> } documents the behaviour for both cases)
> 
> Was there supposed to be a patch for Doc/Zsh/mod_pcre.yo included here?
> There was none.

No.  The "=~" interface, whether you're using pcre or POSIX regular
expressions, is separate from the original PCRE interface and is
completely documented in cond.yo.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[relevance 3%]

* PATCH: function support for regular expression substitution
@ 2010-01-18 12:42  3% Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2010-01-18 12:42 UTC (permalink / raw)
  To: Zsh hackers list

While I'm at it.

Index: Functions/Misc/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Misc/.distfiles,v
retrieving revision 1.16
diff -u -r1.16 .distfiles
--- Functions/Misc/.distfiles	16 Dec 2009 12:12:57 -0000	1.16
+++ Functions/Misc/.distfiles	18 Jan 2010 12:40:45 -0000
@@ -10,6 +10,7 @@
 mere
 nslookup
 promptnl
+regexp-replace
 relative
 run-help
 run-help-git
Index: Functions/Misc/regexp-replace
===================================================================
RCS file: Functions/Misc/regexp-replace
diff -N Functions/Misc/regexp-replace
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Functions/Misc/regexp-replace	18 Jan 2010 12:40:45 -0000
@@ -0,0 +1,35 @@
+# Replace all occurrences of a regular expression in a variable.  The
+# variable is modified directly.  Respects the setting of the
+# option RE_MATCH_PCRE.
+#
+# First argument: *name* (not contents) of variable.
+# Second argument: regular expression
+# Third argument: replacement string.  This can contain all forms of
+# $ and backtick substitutions; in particular, $MATCH will be replaced
+# by the portion of the string matched by the regular expression.
+
+integer pcre
+
+[[ -o re_match_pcre ]] && pcre=1
+
+emulate -L zsh
+(( pcre )) && setopt re_match_pcre
+
+# $4 is the string to be matched
+4=${(P)1}
+# $5 is the final string
+5=
+local MATCH MBEGIN MEND
+local -a match mbegin mend
+
+while [[ -n $4 ]]; do
+  if [[ $4 =~ $2 ]]; then
+    5+=${4[1,MBEGIN-1]}${(e)3}
+    4=${4[MEND+1,-1]}
+  else
+    break
+  fi
+done
+5+=$4
+
+eval ${1}=${(q)5}
Index: Functions/Zle/replace-string-again
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Zle/replace-string-again,v
retrieving revision 1.2
diff -u -r1.2 replace-string-again
--- Functions/Zle/replace-string-again	3 Apr 2008 11:39:11 -0000	1.2
+++ Functions/Zle/replace-string-again	18 Jan 2010 12:40:46 -0000
@@ -13,7 +13,7 @@
   return 1
 fi
 
-if [[ $curwidget = *pattern* ]]; then
+if [[ $curwidget = *(pattern|regex)* ]]; then
     local rep2
     # The following horror is so that an & preceded by an even
     # number of backslashes is active, without stripping backslashes,
@@ -38,8 +38,14 @@
 	rep=${match[5]}
     done
     rep2+=$rep
-    LBUFFER=${LBUFFER//(#bm)$~_replace_string_src/${(e)rep2}}
-    RBUFFER=${RBUFFER//(#bm)$~_replace_string_src/${(e)rep2}}
+    if [[ $curwidget = *regex* ]]; then
+      autoload -U regexp-replace
+      regexp-replace LBUFFER $_replace_string_src $rep2
+      regexp-replace RBUFFER $_replace_string_src $rep2
+    else
+      LBUFFER=${LBUFFER//(#bm)$~_replace_string_src/${(e)rep2}}
+      RBUFFER=${RBUFFER//(#bm)$~_replace_string_src/${(e)rep2}}
+    fi
 else
     LBUFFER=${LBUFFER//$_replace_string_src/$_replace_string_rep}
     RBUFFER=${RBUFFER//$_replace_string_src/$_replace_string_rep}
Index: Doc/Zsh/contrib.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/contrib.yo,v
retrieving revision 1.106
diff -u -r1.106 contrib.yo
--- Doc/Zsh/contrib.yo	16 Jan 2010 16:28:30 -0000	1.106
+++ Doc/Zsh/contrib.yo	18 Jan 2010 12:40:46 -0000
@@ -1570,14 +1570,14 @@
 tindex(replace-pattern)
 xitem(tt(replace-string), tt(replace-pattern))
 item(tt(replace-string-again), tt(replace-pattern-again))(
-The function tt(replace-string) implements two widgets.
+The function tt(replace-string) implements three widgets.
 If defined under the same name as the function, it prompts for two
 strings; the first (source) string will be replaced by the second
 everywhere it occurs in the line editing buffer.
 
 If the widget name contains the word `tt(pattern)', for example by
 defining the widget using the command `tt(zle -N replace-pattern
-replace-string)', then the replacement is done by pattern matching.  All
+replace-string)', then the matching is performed using zsh patterns.  All
 zsh extended globbing patterns can be used in the source string; note
 that unlike filename generation the pattern does not need to match an
 entire word, nor do glob qualifiers have any effect.  In addition, the
@@ -1588,6 +1588,12 @@
 `tt(\{)var(N)tt(})' may be used to protect the digit from following
 digits.
 
+If the widget instead contains the word `tt(regex)' (or `tt(regexp)'),
+then the matching is performed using regular expressions, respecting
+the setting of the option tt(RE_MATCH_PCRE) (see the description of the
+function tt(regexp-replace) below).  The facilities described
+for pattern matching are also available.
+
 By default the previous source or replacement string will not be offered
 for editing.  However, this feature can be activated by setting the style
 tt(edit-previous) in the context tt(:zle:)var(widget) (for example,
@@ -1595,12 +1601,12 @@
 numeric argument forces the previous values to be offered, a negative or
 zero argument forces them not to be.
 
-The function tt(replace-string-again) can be used to repeat the
-previous replacement; no prompting is done.  As with tt(replace-string), if
-the name of the widget contains the word `tt(pattern)', pattern matching
-is performed, else a literal string replacement.  Note that the
-previous source and replacement text are the same whether pattern or string
-matching is used.
+The function tt(replace-string-again) can be used to repeat the previous
+replacement; no prompting is done.  As with tt(replace-string), if the name
+of the widget contains the word `tt(pattern)' or `tt(regex)', pattern or
+regular expression matching is performed, else a literal string
+replacement.  Note that the previous source and replacement text are the
+same whether pattern, regular expression or string matching is used.
 
 For example, starting from the line:
 
@@ -2574,6 +2580,25 @@
 
 See also the tt(pager), tt(prompt) and tt(rprompt) styles below.
 )
+findex(regexp-replace)
+item(tt(regexp-replace) var(var) var(regexp) var(replace))(
+Use regular expressions to perform a global search and replace operation
+on a variable.  If the option tt(RE_MATCH_PCRE) is not set, POSIX
+extended regular expressions are used, else Perl-compatible regular
+expressions (this requires the shell to be linked against the tt(pcre)
+library).
+
+var(var) is the name of the variable containing the string to be matched.
+The variable will be modified directly by the function.  The
+variables tt(MATCH), tt(MBEGIN), tt(MEND), tt(match), tt(mbegin), tt(mend)
+should be avoided as these are used by the regular expression code.
+
+var(regexp) is the regular expression to match against the string.
+
+var(replace) is the replacement text.  This can contain parameter, command
+and arithmetic expressions which will be replaced:  in particular, a
+reference to tt($MATCH) will be replaced by the text matched by the pattern.
+)
 findex(run-help)
 item(tt(run-help) var(cmd))(
 This function is designed to be invoked by the tt(run-help) ZLE widget,


-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[relevance 3%]

* Re: Want to replace bash w zsh as system shell on Ubuntu
       [not found]     ` <87vdefkeuf.fsf@ft.bewatermyfriend.org>
@ 2010-02-02 15:06  0%   ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2010-02-02 15:06 UTC (permalink / raw)
  To: Zsh Hackers' List

On Tue, 02 Feb 2010 13:21:44 +0100
Frank Terbeck <ft@bewatermyfriend.org> wrote:
> One of the problems (which was worked around after four years in debian)
> was a script defining a function called `repeat'. That's also a shell
> reserved word in zsh, leading to a parsing error. If zsh would disable
> `repeat' in sh mode, which would also be correct, that problem would be
> gone.
> 
> The other problem mentioned in grml's FAQ is #329288[1], where the
> problem is a script using `ulimit'. In sh mode, zsh does not make
> `ulimit' available as a builtin command. The guy responding to the bug
> report closed the bug, stating that zsh in sh mode is not a POSIX
> compatible shell and therefore not supported. I guess strictly speaking,
> you cannot dispute that - although sh mode is trying as hard as possible
> to be compatible. Demanding POSIX here is kind of a two sided sword,
> though. If you look at the actual standard for ulimit[2] you'll find
> that `ulimit' is only an extension to the standard.

I'm perfectly happy to change things like this if it's more convenient.
Emulations aren't there to keep normal zsh users happy, so *backwards*
compatibility is not the issue for once.  (If ulimit is allowed as an
extension, then making it available is presumably not making any
compatibility problems worse.)

This makes it possible to have loadable features available in emulation
mode, makes the "ulimit" builtin one such, and disables "repeat" in emulation
mode.  I'm not sure how sophisticated this would need to be; having things
other than parameters different in different (non-native) emulation modes
is a complexity it would be good to avoid.

Would need some documentation.

Index: Etc/zsh-development-guide
===================================================================
RCS file: /cvsroot/zsh/zsh/Etc/zsh-development-guide,v
retrieving revision 1.22
diff -u -r1.22 zsh-development-guide
--- Etc/zsh-development-guide	11 May 2009 09:03:28 -0000	1.22
+++ Etc/zsh-development-guide	2 Feb 2010 14:57:45 -0000
@@ -198,12 +198,16 @@
   - nozshdep        non-empty indicates no dependence on the `zsh/main'
                     pseudo-module
   - alwayslink      if non-empty, always link the module into the executable
-  - autobins        builtins defined by the module, for autoloading
-  - autoinfixconds  infix condition codes defined by the module, for
-                    autoloading (without the leading `-')
-  - autoprefixconds like autoinfixconds, but for prefix condition codes
-  - autoparams      parameters defined by the module, for autoloading
-  - automathfuncs   math functions defined by the module, for autoloading
+  - autofeatures    features defined by the module for autoloading,
+                    a space-separated list.  The syntax for features is as
+                    for zmodload -F, e.g. b:mybin refers to the builtin
+                    mybin.  This replaces the previous mechanism with
+                    separate variables for builtins, conditions, math
+                    functions and parameters.  Note the features are only
+		    available in zsh's native mode, not in emulation modes.
+  - autofeatures_emu As autofeatures, but the features so presented are
+                    available in modes that are *not* zsh's native mode.
+		    The variable autofeatures must also be present.
   - objects         .o files making up this module (*must* be defined)
   - proto           .syms files for this module (default generated from $objects)
   - headers         extra headers for this module (default none)
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.237
diff -u -r1.237 builtin.c
--- Src/builtin.c	29 Jan 2010 21:44:59 -0000	1.237
+++ Src/builtin.c	2 Feb 2010 14:57:45 -0000
@@ -206,6 +206,17 @@
     }
 }
 
+/**/
+void
+init_builtins(void)
+{
+    if (!EMULATION(EMULATE_ZSH)) {
+	HashNode hn = reswdtab->getnode2(reswdtab, "repeat");
+	if (hn)
+	    reswdtab->disablenode(hn, 0);
+    }
+}
+
 /* Make sure we have space for a new option and increment. */
 
 #define OPT_ALLOC_CHUNK 16
Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.109
diff -u -r1.109 init.c
--- Src/init.c	27 Jan 2010 19:25:34 -0000	1.109
+++ Src/init.c	2 Feb 2010 14:57:45 -0000
@@ -1443,6 +1443,7 @@
     setupvals();
     init_signals();
     init_bltinmods();
+    init_builtins();
     run_init_scripts();
     init_misc();
 
Index: Src/mkbltnmlst.sh
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/mkbltnmlst.sh,v
retrieving revision 1.10
diff -u -r1.10 mkbltnmlst.sh
--- Src/mkbltnmlst.sh	11 Feb 2009 20:42:16 -0000	1.10
+++ Src/mkbltnmlst.sh	2 Feb 2010 14:57:45 -0000
@@ -37,18 +37,38 @@
         echo "/* non-linked-in known module \`$x_mod' */"
 	linked=no
     esac
-    unset moddeps autofeatures
+    unset moddeps autofeatures autofeatures_emu
     . $srcdir/../$modfile
     if test "x$autofeatures" != x; then
-	echo "  if (EMULATION(EMULATE_ZSH)) {"
-	echo "    char *features[] = { "
-	for feature in $autofeatures; do
-	    echo "      \"$feature\","
-	done
-	echo "      NULL"
-	echo "    }; "
-	echo "    autofeatures(\"zsh\", \"$x_mod\", features, 0, 1);"
-	echo "  }"
+        if test "x$autofeatures_emu" != x; then
+            echo "  {"
+	    echo "    char *zsh_features[] = { "
+	    for feature in $autofeatures; do
+		echo "      \"$feature\","
+	    done
+	    echo "      NULL"
+	    echo "    }; "
+	    echo "    char *emu_features[] = { "
+	    for feature in $autofeatures_emu; do
+		echo "      \"$feature\","
+	    done
+	    echo "      NULL"
+	    echo "    }; "
+	    echo "    autofeatures(\"zsh\", \"$x_mod\","
+	    echo "       EMULATION(EMULATE_ZSH) ? zsh_features : emu_features,"
+	    echo "       0, 1);"
+	    echo "  }"
+        else
+	    echo "  if (EMULATION(EMULATE_ZSH)) {"
+	    echo "    char *features[] = { "
+	    for feature in $autofeatures; do
+		echo "      \"$feature\","
+	    done
+	    echo "      NULL"
+	    echo "    }; "
+	    echo "    autofeatures(\"zsh\", \"$x_mod\", features, 0, 1);"
+	    echo "  }"
+	fi
     fi
     for dep in $moddeps; do
 	echo "  add_dep(\"$x_mod\", \"$dep\");"
Index: Src/Builtins/rlimits.mdd
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Builtins/rlimits.mdd,v
retrieving revision 1.4
diff -u -r1.4 rlimits.mdd
--- Src/Builtins/rlimits.mdd	20 Jun 2007 20:59:17 -0000	1.4
+++ Src/Builtins/rlimits.mdd	2 Feb 2010 14:57:46 -0000
@@ -3,6 +3,7 @@
 load=yes
 
 autofeatures="b:limit b:ulimit b:unlimit"
+autofeatures_emu="b:ulimit"
 
 objects="rlimits.o"
 

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[relevance 0%]

* Improve job text for ( ... ) and { ... }
@ 2010-02-13 20:21  2% Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2010-02-13 20:21 UTC (permalink / raw)
  To: Zsh hackers list

The unnecessary and rather confusing first semicolon in

% ( sleep 10 ) &
[1] 9520
% jobs
[1]  + running    (; sleep 10; )

is entirely cosmetic but nonetheless has been annoying me for a while
now.  This removes it.  Shout if you see any similar cases I missed.

I realise the ";" after the "sleep 10" is also optional in zsh, but it's
standard and I don't think it's distracting in the same way as the one
before, so I've left it.  The alternative would be to make it optional
on some POSIX option, but I don't see the point.

Index: Src/text.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/text.c,v
retrieving revision 1.24
diff -u -r1.24 text.c
--- Src/text.c	11 Sep 2008 17:14:39 -0000	1.24
+++ Src/text.c	13 Feb 2010 20:13:29 -0000
@@ -102,7 +102,7 @@
 
 /**/
 static void
-taddnl(void)
+taddnl(int no_semicolon)
 {
     int t0;
 
@@ -110,8 +110,11 @@
 	taddchr('\n');
 	for (t0 = 0; t0 != tindent; t0++)
 	    taddchr('\t');
-    } else
+    } else if (no_semicolon) {
+	taddstr(" ");
+    } else {
 	taddstr("; ");
+    }
 }
 
 /* get a permanent textual representation of n */
@@ -275,7 +278,7 @@
 		}
 		if (!(stack = (WC_LIST_TYPE(code) & Z_END))) {
 		    if (tnewlins)
-			taddnl();
+			taddnl(0);
 		    else
 			taddstr((WC_LIST_TYPE(code) & Z_ASYNC) ? " " : "; ");
 		    s->code = *state->pc++;
@@ -355,7 +358,7 @@
 	    if (!s) {
 		taddstr("(");
 		tindent++;
-		taddnl();
+		taddnl(1);
 		n = tpush(code, 1);
 		n->u._subsh.end = state->pc + WC_SUBSH_SKIP(code);
 		/* skip word only use for try/always */
@@ -363,7 +366,8 @@
 	    } else {
 		state->pc = s->u._subsh.end;
 		dec_tindent();
-		taddnl();
+		/* semicolon is optional here but more standard */
+		taddnl(0);
 		taddstr(")");
 		stack = 1;
 	    }
@@ -372,7 +376,7 @@
 	    if (!s) {
 		taddstr("{");
 		tindent++;
-		taddnl();
+		taddnl(1);
 		n = tpush(code, 1);
 		n->u._subsh.end = state->pc + WC_CURSH_SKIP(code);
 		/* skip word only use for try/always */
@@ -380,7 +384,8 @@
 	    } else {
 		state->pc = s->u._subsh.end;
 		dec_tindent();
-		taddnl();
+		/* semicolon is optional here but more standard */
+		taddnl(0);
 		taddstr("}");
 		stack = 1;
 	    }
@@ -412,7 +417,7 @@
 		} else {
 		    taddstr(" () {");
 		    tindent++;
-		    taddnl();
+		    taddnl(1);
 		    n = tpush(code, 1);
 		    n->u._funcdef.strs = state->strs;
 		    n->u._funcdef.end = end;
@@ -423,7 +428,7 @@
 		state->strs = s->u._funcdef.strs;
 		state->pc = s->u._funcdef.end;
 		dec_tindent();
-		taddnl();
+		taddnl(0);
 		taddstr("}");
 		stack = 1;
 	    }
@@ -445,15 +450,15 @@
 			taddstr(" in ");
 			taddlist(state, *state->pc++);
 		    }
-		    taddnl();
+		    taddnl(0);
 		    taddstr("do");
 		}
 		tindent++;
-		taddnl();
+		taddnl(0);
 		tpush(code, 1);
 	    } else {
 		dec_tindent();
-		taddnl();
+		taddnl(0);
 		taddstr("done");
 		stack = 1;
 	    }
@@ -467,11 +472,11 @@
 		    taddlist(state, *state->pc++);
 		}
 		tindent++;
-		taddnl();
+		taddnl(0);
 		tpush(code, 1);
 	    } else {
 		dec_tindent();
-		taddnl();
+		taddnl(0);
 		taddstr("done");
 		stack = 1;
 	    }
@@ -484,14 +489,14 @@
 		tpush(code, 0);
 	    } else if (!s->pop) {
 		dec_tindent();
-		taddnl();
+		taddnl(0);
 		taddstr("do");
 		tindent++;
-		taddnl();
+		taddnl(0);
 		s->pop = 1;
 	    } else {
 		dec_tindent();
-		taddnl();
+		taddnl(0);
 		taddstr("done");
 		stack = 1;
 	    }
@@ -500,14 +505,14 @@
 	    if (!s) {
 		taddstr("repeat ");
 		taddstr(ecgetstr(state, EC_NODUP, NULL));
-		taddnl();
+		taddnl(0);
 		taddstr("do");
 		tindent++;
-		taddnl();
+		taddnl(0);
 		tpush(code, 1);
 	    } else {
 		dec_tindent();
-		taddnl();
+		taddnl(0);
 		taddstr("done");
 		stack = 1;
 	    }
@@ -522,7 +527,7 @@
 
 		if (state->pc >= end) {
 		    if (tnewlins)
-			taddnl();
+			taddnl(0);
 		    else
 			taddchr(' ');
 		    taddstr("esac");
@@ -530,7 +535,7 @@
 		} else {
 		    tindent++;
 		    if (tnewlins)
-			taddnl();
+			taddnl(0);
 		    else
 			taddchr(' ');
 		    taddstr("(");
@@ -559,7 +564,7 @@
 		    break;
 		}
 		if (tnewlins)
-		    taddnl();
+		    taddnl(0);
 		else
 		    taddchr(' ');
 		taddstr("(");
@@ -588,7 +593,7 @@
 		}
 		dec_tindent();
 		if (tnewlins)
-		    taddnl();
+		    taddnl(0);
 		else
 		    taddchr(' ');
 		taddstr("esac");
@@ -610,14 +615,14 @@
 		stack = 1;
 	    } else if (s->u._if.cond) {
 		dec_tindent();
-		taddnl();
+		taddnl(0);
 		taddstr("then");
 		tindent++;
-		taddnl();
+		taddnl(0);
 		s->u._if.cond = 0;
 	    } else if (state->pc < s->u._if.end) {
 		dec_tindent();
-		taddnl();
+		taddnl(0);
 		code = *state->pc++;
 		if (WC_IF_TYPE(code) == WC_IF_ELIF) {
 		    taddstr("elif ");
@@ -626,12 +631,12 @@
 		} else {
 		    taddstr("else");
 		    tindent++;
-		    taddnl();
+		    taddnl(0);
 		}
 	    } else {
 		s->pop = 1;
 		dec_tindent();
-		taddnl();
+		taddnl(0);
 		taddstr("fi");
 		stack = 1;
 	    }
@@ -762,7 +767,7 @@
 	    if (!s) {
 		taddstr("{");
 		tindent++;
-		taddnl();
+		taddnl(0);
 		n = tpush(code, 0);
 		state->pc++;
 		/* this is the end of the try block alone */
@@ -770,14 +775,14 @@
 	    } else if (!s->pop) {
 		state->pc = s->u._subsh.end;
 		dec_tindent();
-		taddnl();
+		taddnl(0);
 		taddstr("} always {");
 		tindent++;
-		taddnl();
+		taddnl(0);
 		s->pop = 1;
 	    } else {
 		dec_tindent();
-		taddnl();
+		taddnl(0);
 		taddstr("}");
 		stack = 1;
 	    }


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


^ permalink raw reply	[relevance 2%]

* PATCH: FAQ for advanced character sets
@ 2010-02-15 14:10  5% Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2010-02-15 14:10 UTC (permalink / raw)
  To: Zsh hackers list

A brief glance should that bits of this were out of date.

Index: Etc/FAQ.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Etc/FAQ.yo,v
retrieving revision 1.52
diff -p -u -r1.52 FAQ.yo
--- Etc/FAQ.yo	15 Feb 2010 13:15:58 -0000	1.52
+++ Etc/FAQ.yo	15 Feb 2010 14:08:05 -0000
@@ -933,37 +933,16 @@ sect(What is zsh's support for Unicode/U
   ways of supporting character sets beyond ASCII.  `UTF-8' is an
   encoding of Unicode that is particularly natural on Unix-like systems.
 
-  Q: Does zsh support UTF-8?
-
-  A: zsh's built-in printf command supports "\u" and "\U" escapes
-  to output arbitrary Unicode characters.  ZLE (the Zsh Line Editor) has
+  The production branch of zsh, 4.2, has very limited support:
+  the built-in printf command supports "\u" and "\U" escapes
+  to output arbitrary Unicode characters; ZLE (the Zsh Line Editor) has
   no concept of character encodings, and is confused by multi-octet
   encodings.
 
-  Q: Why doesn't zsh have proper UTF-8 support?
-
-  A: The code has not been written yet.
-
-  Q: What makes UTF-8 support difficult to implement?
-
-  A: In order to handle arbitrary encodings the correct way, significant
-  and intrusive changes must be made to the shell.
-
-  Q: Why can't zsh just use readline?
-
-  A: ZLE is not encapsulated from the rest of the shell.  Isolating it
-  such that it could be replaced by readline would be a significant
-  effort.  Furthermore, using readline would effect a significant loss of
-  features.
-
-  Q: What changes are planned?
-
-  A: Introduction of Unicode support will be gradual, so if you are
-  interested in being involved you should join the zsh-workers mailing
-  list.  As a first step ZLE will be rewritten to use wide characters
-  internally.  Character based widgets can then operate on a single wide
-  character instead of a single byte, and the proper display width can be
-  calculated with wcswidth().
+  However, the 4.3 branch has much better support, and furthermore this
+  is now fairly stable.  (Only a few minor areas need fixing before
+  this becomes a production release.)  This is discussed more
+  fully below, see `Multibyte input and output'.
 
 
 chapter(How to get various things to work)
@@ -2030,7 +2009,7 @@ sect(What is multibyte input?)
   zsh will be able to use any such encoding as long as it contains ASCII as
   a single-octet subset and the system can provide information about other
   characters.  However, in the case of Unicode, UTF-8 is the only one you
-  are likely to enounter.
+  are likely to enounter that is useful in zsh.
 
   (In case you're confused: Unicode is the character set, while UTF-8 is
   an encoding of it.  You might hear about other encodings, such as UCS-2
@@ -2063,7 +2042,7 @@ sect(How does zsh handle multibyte input
   Note that if the shell is emulating a Bourne shell the tt(MULTIBYTE)
   option is unset by default.  This allows various POSIX modes to
   work normally (POSIX does not deal with multibyte characters).  If
-  you use a "sh" or "ksh" emulation interactively you shouldprobably
+  you use a "sh" or "ksh" emulation interactively you should probably
   set the tt(MULTIBYTE) option.
 
   The other option that affects multibyte support is tt(COMBINING_CHARS),
@@ -2072,9 +2051,10 @@ sect(How does zsh handle multibyte input
   assumed to be modifications (accents etc.) to the base character and to
   be displayed within the same screen area as the base character.  As not
   all terminals handle this, even if they correctly display the base
-  multibyte character, this option is not on by default.  The KDE terminal
-  emulator tt(konsole), tt(rxvt-unicode), and the Unicode version of
-  xterm, tt(xterm -u8) or the front-end tt(uxterm), are known to handle
+  multibyte character, this option is not on by default.  Recent versions
+  of the KDE and GNOME terminal emulators tt(konsole) and
+  tt(gnome-terminal) as well as tt(rxvt-unicode), and the Unicode version
+  of xterm, tt(xterm -u8) or the front-end tt(uxterm), are known to handle
   combining characters.
 
   The tt(COMBINING_CHARS) option only affects output; combining characters
@@ -2110,12 +2090,12 @@ sect(How do I ensure multibyte input and
       edit file names that have been created using a different character
       set it won't work properly.)
    it() The terminal emulator.  Those that are supplied with a recent
-      desktop environment, such as gnome-terminal, are likely to have
-      extensive support for localization and may work correctly as soon
-      as they know the locale.  You can enable UTF-8 support for
-      tt(xterm) in its application defaults file.  The following are
-      the relevant resources; you don't actually need all of them, as
-      described below.  If you use a mytt(~/.Xdefaults) or
+      desktop environment, such as tt(konsole) and tt(gnome-terminal), are
+      likely to have extensive support for localization and may work
+      correctly as soon as they know the locale.  You can enable UTF-8
+      support for tt(xterm) in its application defaults file.  The
+      following are the relevant resources; you don't actually need all of
+      them, as described below.  If you use a mytt(~/.Xdefaults) or
       mytt(~/.Xresources) file for setting resources, prefix all the lines
       with mytt(xterm):
       verb(
@@ -2147,7 +2127,12 @@ sect(How do I ensure multibyte input and
   this feature does.)  If your terminal doesn't have characters
   that need to be input as multibyte, however, you can still use
   the meta bindings and can ignore the warning message.  Use
-  mytt(bindkey -m 2>/dev/null) to suprress it.
+  mytt(bindkey -m 2>/dev/null) to suppress it.
+
+  You might also note that the latest version of the Cygwin environment
+  for Windows supports UTF-8.  In previous versions, zsh was able
+  to compile with the tt(MULTIBYTE) option enabled, but the system
+  didn't provide full support for it.
 
 
 sect(How can I input characters that aren't on my keyboard?)
@@ -2187,6 +2172,9 @@ url(http://www.unicode.org/charts/)(http
   however, using UTF-8 massively extends the number of valid characters
   that can be produced.
 
+  If you have a recent X Window System installation, you might find
+  the tt(AltGr) key helps you input accented Latin characters; for
+  example on my keyboard tt(AltGr-; e) gives mytt(e) with an acute accent.
   See also url(http://www.cl.cam.ac.uk/~mgk25/unicode.html#input)(http://www.cl.cam.ac.uk/~mgk25/unicode.html#input)
   for general information on entering Unicode characters from a keyboard.
 

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[relevance 5%]

* PATCH: Standard IFS
@ 2010-03-11 22:04  8% Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2010-03-11 22:04 UTC (permalink / raw)
  To: Zsh hackers list

I keep meaning to post this.

POSIX requires that IFS be set to a particular value if it's not in the
environment (which we ignore anyway, that's explicitly allowed).  We
should use this value in sh and ksh emulation.

You'd be surprised how long it took me to realise why 'echo $IFS | xxd'
didn't do what I expected in sh mode.  (You need double quotes because
of word splitting.)

Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.111
diff -p -u -r1.111 init.c
--- Src/init.c	9 Feb 2010 13:58:33 -0000	1.111
+++ Src/init.c	11 Mar 2010 22:02:46 -0000
@@ -815,7 +815,8 @@ setupvals(void)
 	? ztrdup("+ ") : ztrdup("+%N:%i> ");
     sprompt = ztrdup("zsh: correct '%R' to '%r' [nyae]? ");
 
-    ifs         = ztrdup(DEFAULT_IFS);
+    ifs         = EMULATION(EMULATE_KSH|EMULATE_SH) ?
+	ztrdup(DEFAULT_IFS_SH) : ztrdup(DEFAULT_IFS);
     wordchars   = ztrdup(DEFAULT_WORDCHARS);
     postedit    = ztrdup("");
     zunderscore  = (char *) zalloc(underscorelen = 32);
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.240
diff -p -u -r1.240 utils.c
--- Src/utils.c	24 Feb 2010 21:38:10 -0000	1.240
+++ Src/utils.c	11 Mar 2010 22:02:48 -0000
@@ -3271,7 +3271,8 @@ inittyptab(void)
 	typtab[t0] |= ITOK | IMETA;
     for (t0 = (int)STOUC(Snull); t0 <= (int)STOUC(Nularg); t0++)
 	typtab[t0] |= ITOK | IMETA | INULL;
-    for (s = ifs ? ifs : DEFAULT_IFS; *s; s++) {
+    for (s = ifs ? ifs : EMULATION(EMULATE_KSH|EMULATE_SH) ?
+	ztrdup(DEFAULT_IFS_SH) : ztrdup(DEFAULT_IFS); *s; s++) {
 	int c = STOUC(*s == Meta ? *++s ^ 32 : *s);
 #ifdef MULTIBYTE_SUPPORT
 	if (!isascii(c)) {
@@ -3305,7 +3306,8 @@ inittyptab(void)
     }
 #ifdef MULTIBYTE_SUPPORT
     set_widearray(wordchars, &wordchars_wide);
-    set_widearray(ifs ? ifs : DEFAULT_IFS, &ifs_wide);
+    set_widearray(ifs ? ifs : EMULATION(EMULATE_KSH|EMULATE_SH) ?
+	ztrdup(DEFAULT_IFS_SH) : ztrdup(DEFAULT_IFS), &ifs_wide);
 #endif
     for (s = SPECCHARS; *s; s++)
 	typtab[STOUC(*s)] |= ISPECIAL;
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.163
diff -p -u -r1.163 zsh.h
--- Src/zsh.h	24 Feb 2010 21:38:10 -0000	1.163
+++ Src/zsh.h	11 Mar 2010 22:02:48 -0000
@@ -127,6 +127,10 @@ struct mathfunc {
 
 #define DEFAULT_IFS	" \t\n\203 "
 
+/* As specified in the standard (POSIX 2008) */
+
+#define DEFAULT_IFS_SH	" \t\n"
+
 /*
  * Character tokens.
  * These should match the characters in ztokens, defined in lex.c


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


^ permalink raw reply	[relevance 8%]

* Re: Is this a bug? Why not?
  @ 2010-03-31 15:11  3%   ` Bart Schaefer
  2010-04-01  8:26  0%     ` Phil Pennock
  0 siblings, 1 reply; 200+ results
From: Bart Schaefer @ 2010-03-31 15:11 UTC (permalink / raw)
  To: zsh-workers

Incidentally, this came up because of a discussion on the POSIX standards
mailing list (austin-group) in which David Korn just asserted that he'd
like to add the syntax ${"var"} which means to expand the value of var
as if it's quoted (what zsh's normal mode does all the time).

This differs from "${var}" because you can write ${"var"-*} and get the
value of $var quoted but the glob pattern unquoted.  Apparently the old
Bourne shell allows the abominable "${var"-*}  (note quote placement
overlapping with brace placement) to accomplish this.

I was hoping to be able to say "Oh, zsh already has syntax XYZ for that"
but in fact we don't -- zsh either always, or never, does it, depending
on the globsubst option; there's no way to flip globsubst on the fly.

On Mar 30, 11:06pm, Phil Pennock wrote:
} Subject: Re: Is this a bug? Why not?
}
} So the string ${var} when treated as a variable-name is empty but
} defined?  The four expansions with a nested ${var} are entirely
} consistent with the behaviour when expanding a variable which is
} defined with a value of length 0.
} 
} Seems unusual, but consistent.

Indeed.  OK, I can live with that, as it's been that way forever.

} In bash, ksh, bad substitution.  In ksh93, it gets weird:
}   $ echo ${var-???}
}   OSM SCM bin dbg doc etc lib man src tmp www
}   $ echo ${${var}-???}
}   ksh93: syntax error: `!' unexpected

That is weird, but AFAIK only zsh of all shells allows wrapping ${...}
in another ${...} as valid syntax, so this may just be an error ksh93
didn't catch.

} The ksh reference-name expansion made me think of the somewhat opposite
} expansion in zsh, (P)var ...
} 
} Hrm, zsh 4.3.10 1.4705:
} 
}   % print ${(P)-???}
}   zsh: 0239BCJPXZgiklms: ??
} 
} Strange that the first entry is somehow tying into expanding $- for the
} shell options ...

Actually that makes perfect sense; only the :- and :+ forms are doc'd
as working with a missing parameter name, so ${(P)-} really does mean
to grab the value of $- and try to use that as a parameter name.  It
otherwise has to behave like ${-?string}.


^ permalink raw reply	[relevance 3%]

* Re: Is this a bug? Why not?
  2010-03-31 15:11  3%   ` Bart Schaefer
@ 2010-04-01  8:26  0%     ` Phil Pennock
  2010-04-01 14:36  3%       ` Bart Schaefer
  0 siblings, 1 reply; 200+ results
From: Phil Pennock @ 2010-04-01  8:26 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

On 2010-03-31 at 08:11 -0700, Bart Schaefer wrote:
> Incidentally, this came up because of a discussion on the POSIX standards
> mailing list (austin-group) in which David Korn just asserted that he'd
> like to add the syntax ${"var"} which means to expand the value of var
> as if it's quoted (what zsh's normal mode does all the time).
> 
> This differs from "${var}" because you can write ${"var"-*} and get the
> value of $var quoted but the glob pattern unquoted.  Apparently the old
> Bourne shell allows the abominable "${var"-*}  (note quote placement
> overlapping with brace placement) to accomplish this.
> 
> I was hoping to be able to say "Oh, zsh already has syntax XYZ for that"
> but in fact we don't -- zsh either always, or never, does it, depending
> on the globsubst option; there's no way to flip globsubst on the fly.

No *neat* syntax.

% ls
lib         viewvc.conf
% print -l ${~~foo-${(~):-*}}
lib
viewvc.conf
% foo='???'
$ print -l ${~~foo-${(~):-*}}
???
% print -l $foo
lib
% unsetopt glob_subst
% print -l $foo      
???
%

*cough*


^ permalink raw reply	[relevance 0%]

* Re: Is this a bug? Why not?
  2010-04-01  8:26  0%     ` Phil Pennock
@ 2010-04-01 14:36  3%       ` Bart Schaefer
  2010-04-01 21:57  0%         ` Phil Pennock
  0 siblings, 1 reply; 200+ results
From: Bart Schaefer @ 2010-04-01 14:36 UTC (permalink / raw)
  To: zsh-workers

On Apr 1,  1:26am, Phil Pennock wrote:
} Subject: Re: Is this a bug? Why not?
}
} On 2010-03-31 at 08:11 -0700, Bart Schaefer wrote:
} > Incidentally, this came up because of a discussion on the POSIX standards
} > mailing list (austin-group) in which David Korn just asserted that he'd
} > like to add the syntax ${"var"} which means to expand the value of var
} > as if it's quoted (what zsh's normal mode does all the time).
} > 
} > I was hoping to be able to say "Oh, zsh already has syntax XYZ for that"
} > but in fact we don't -- zsh either always, or never, does it, depending
} > on the globsubst option; there's no way to flip globsubst on the fly.
} 
} No *neat* syntax.
} 
} % ls
} lib         viewvc.conf
} % print -l ${~~foo-${(~):-*}}

That isn't really what you mean, is it?  The (~) flag only applies to
the (j::) et al. strings.

However, it's not even necessary to do the ${:-*} thing, ${~~foo-*} is
sufficient.

For austin-group purposes, however, I was hoping for something that did
not rely on parameter expansion flags.  E.g., why doesn't the following
cause $foo to be quoted?

schaefer[516] ARGV0=sh Src/zsh
$ foo="???"
$ print ${foo+"$foo"}
Doc Etc Src
$ 

It works in bash.


^ permalink raw reply	[relevance 3%]

* Re: Is this a bug? Why not?
  2010-04-01 14:36  3%       ` Bart Schaefer
@ 2010-04-01 21:57  0%         ` Phil Pennock
  0 siblings, 0 replies; 200+ results
From: Phil Pennock @ 2010-04-01 21:57 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

On 2010-04-01 at 07:36 -0700, Bart Schaefer wrote:
> On Apr 1,  1:26am, Phil Pennock wrote:
> } Subject: Re: Is this a bug? Why not?
> }
> } On 2010-03-31 at 08:11 -0700, Bart Schaefer wrote:
> } > Incidentally, this came up because of a discussion on the POSIX standards
> } > mailing list (austin-group) in which David Korn just asserted that he'd
> } > like to add the syntax ${"var"} which means to expand the value of var
> } > as if it's quoted (what zsh's normal mode does all the time).
> } > 
> } > I was hoping to be able to say "Oh, zsh already has syntax XYZ for that"
> } > but in fact we don't -- zsh either always, or never, does it, depending
> } > on the globsubst option; there's no way to flip globsubst on the fly.
> } 
> } No *neat* syntax.
> } 
> } % ls
> } lib         viewvc.conf
> } % print -l ${~~foo-${(~):-*}}
> 
> That isn't really what you mean, is it?  The (~) flag only applies to
> the (j::) et al. strings.

Oh, interesting, I missed that glob_subst wasn't affecting the default
at all.

> However, it's not even necessary to do the ${:-*} thing, ${~~foo-*} is
> sufficient.

Okay, *phew*, I did understand the problem statement.

> For austin-group purposes, however, I was hoping for something that did
> not rely on parameter expansion flags.  E.g., why doesn't the following
> cause $foo to be quoted?
> 
> schaefer[516] ARGV0=sh Src/zsh
> $ foo="???"
> $ print ${foo+"$foo"}
> Doc Etc Src
> $ 
> 
> It works in bash.

Defining "works" as seeing ??? emitted: it works in zsh with glob_subst
disabled.  It works in FreeBSD /bin/sh ...

Is this use-case important enough to warrant yet another option?

-Phil


^ permalink raw reply	[relevance 0%]

* [PATCH 4/6] Update news and releases.
  @ 2010-04-17 21:40  3% ` Simon Ruderich
  0 siblings, 0 replies; 200+ results
From: Simon Ruderich @ 2010-04-17 21:40 UTC (permalink / raw)
  To: zsh-workers

---
 News/index.html |    7 ++
 index.html      |    2 +-
 releases.html   |  204 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 212 insertions(+), 1 deletions(-)

diff --git a/News/index.html b/News/index.html
index bc1fb81..545441a 100644
--- a/News/index.html
+++ b/News/index.html
@@ -25,6 +25,13 @@

 <dl>

+<dt><font size="+1"><font color="red">2009-06-01</font> : <b>Release 4.3.10</b></font></dt>
+<dd>Bug fixes and some minor improvements.</dd>
+
+<dt><font size="+1"><font color="red">2008-11-03</font> : <b>Release 4.3.9</b></font></dt>
+<dd>Improved multibyte support on MacOS, updated prompt system and better
+debug support.</dd>
+
 <dt><font size="+1"><font color="red">2008-08-29</font> : <b>Zsh for Symbian OS.</b></font></dt>
 <dd><a href="http://www.symbian.com/">Symbian</a> has released a port of
 Zsh, together with telnetd, onto Symbian OS using its P.I.P.S. layer.
diff --git a/index.html b/index.html
index ed528ea..beb399f 100644
--- a/index.html
+++ b/index.html
@@ -22,7 +22,7 @@
   <td>
     <ul>
     <font size="+1" color="#600000"><b>Information</b></font>
-    <li><a href="News/">News</a> <font color=red><i>2008-08-29</i></font>
+    <li><a href="News/">News</a> <font color=red><i>2009-06-01</i></font>
     <li><a href="about.html">About these pages</a>
     <li><a href="releases.html">Release Notes</a>
     <li><a href="links.html">Useful links</a>
diff --git a/releases.html b/releases.html
index 2b94704..8adbc94 100644
--- a/releases.html
+++ b/releases.html
@@ -27,6 +27,210 @@
 </table>
 <hr size=1 noshade>

+
+<h2>Changes between versions 4.3.9 and 4.3.10</h2>
+
+<p>
+The command "<tt>emulate <mode> -c ...</tt>" evaluates an expression in a given
+emulation.  The emulation is sticky for functions defined within the
+expression.
+</p><p>
+The variable <tt>CORRECT_IGNORE</tt> gives a pattern that can be ignored
+in spelling correction.  <tt>CORRECT_IGNORE='_*'</tt> ignores completion functions.
+</p><p>
+The option <tt>POSIX_ALIASES</tt> improves compatibility of aliases with other
+shells.
+</p><p>
+The variable <tt>ZSH_PATCHLEVEL</tt> can be used to test for unreleased versions of
+the shell; it is present but less useful in released versions.
+</p><p>
+The variables <tt>ZLE_REMOVE_SUFFIX_CHARS</tt> and <tt>ZLE_SPACE_SUFFIX_CHARS</tt> allow more
+control over the way automatically removed suffixes are treated in
+completion.
+</p>
+
+<h2>Major changes between versions 4.3.6 and 4.3.9</h2>
+
+<p>
+The option <tt>COMBINING_CHARS</tt> has been added.  When it is set, the
+line editor assumes the terminal is capable of displaying zero-width
+combining characters (typically accents) correctly as modifications
+to the base character, and will act accordingly.  Note it is not set
+by default owing to vagaries of terminals.  The system is reported
+to work on MacOS, where this is particularly important as accented
+characters in file names are stored in their decomposed form (i.e.
+with base and combining characters).
+</p><p>
+The option <tt>HIST_FCNTL_LOCK</tt> has been added to provide locking of history
+files using the system call <tt>fcntl()</tt>.  On recent NFS implementations this
+may provide better reliability.
+</p><p>
+The syntax <tt>~[...]</tt> provides a dynamic form of directory naming,
+supplementing the existing static ~name syntax.  A user-defined shell
+function, zsh_directory_name, is used to handle both expansion of names to
+directories and contraction of directories to names.
+</p><p>
+Patterns can now be used in incremental searches with the new widgets
+<tt>history-incremental-pattern-search-backward</tt> and
+<tt>history-incremental-pattern-search-forward</tt>.  These are not bound to
+keys by default.
+</p><p>
+Highlighting and colouring of sections of the command line is now
+supported, controlled by the array parameter zle_highlight and the ZLE
+special parameter region_highlight.
+</p><p>
+Colouring of prompts is now supported within the shell by prompt
+escapes.  The prompt theme system has been updated.
+</p>
+
+Various changes have been added to make debugging of shell code easier:
+<ul>
+<li>As noted in README, the option <tt>DEBUG_BEFORE_CMD</tt> is now set by default.
+</li>
+<li>In <tt>DEBUG</tt> traps, <tt>$ZSH_DEBUG_CMD</tt> gives the code for which the trap is
+    called as a string.
+</li>
+<li><tt>"setopt ERR_EXIT"</tt> in a <tt>DEBUG</tt> trap causes the code not to be executed.
+</li>
+<li><tt>$ZSH_SUBSHELL</tt> indicates the subshell level at which code is being
+    executed.
+</li>
+<li>The zsh/parameter module has various additional arrays similar to
+    the existing <tt>$funcstack</tt> and <tt>$functrace</tt>, namely <tt>$funcsourcetrace</tt>
+    and <tt>$funcfiletrace</tt>.  The consistency and informativeness of
+    the output of all these arrays has been improved.
+</li>
+<li>Prompt escapes <tt>%x</tt> and <tt>%I</tt> show the source file and line number in
+    debug prompts (compare <tt>%N</tt> and <tt>%i</tt> which show names and line numbers
+    in the execution environment).
+</li>
+<li>The option <tt>NO_MULTI_FUNCDEF</tt> can turn off multiple definition of
+    functions at once, a rarely used feature that can cause problems
+    with misplaced "<tt>()</tt>".
+</li>
+<li>The "<tt>fc</tt>" builtin has been enhanced to make non-interactive use possible
+    and output consistent when the history is manipulated with "<tt>print -s</tt>".
+</li>
+</ul>
+
+<p>
+The completion style accept-exact-dirs has been added.  When true, this
+suppresses attempts to complete non-final directory segments of a filename
+path when the directory exists.  (For example, <tt>/home/pws/src/zsh/&lt;TAB&gt;</tt>
+discovers that <tt>/home/pws/src/zsh</tt> exists and leaves the directory component
+alone, while <tt>/h/p/s/z/&lt;TAB&gt;</tt> completes to <tt>/home/pws/src/zsh/...</tt> as before.)
+This should improve completion behaviour noticeably in special cases, such
+as remote paths under Cygwin.
+</p>
+
+<h2>Major changes between versions 4.3.5 and 4.3.6</h2>
+
+<p>
+<tt>cd</tt>, <tt>chdir</tt>, <tt>pushd</tt> and <tt>popd</tt> now take a <tt>-q</tt> option to suppress side effects
+including printing the directory stack (for <tt>pushd</tt> and <tt>popd</tt>) and executing
+the <tt>chpwd</tt> hook functions (for all four).
+</p><p>
+The parameter subscript (<tt>e</tt>) flag now forces the argument to be treated
+as a string where it would previously have been treated as a pattern,
+for example <tt>${array[(ie)*]}</tt> substitutes the index of the element whose
+value is "<tt>*</tt>".
+</p>
+
+<h2>Major changes between versions 4.3.4 and 4.3.5</h2>
+
+<ul>
+<li>The new extended globbing flag (<tt>#cN,M</tt>) behaves similarly to the extended
+  regular expression syntax <tt>{N,M}</tt>.
+</li>
+<li>The zsh/datetime module has been enhanced and a calendar function
+  system has been added along the lines of (but much enhanced from)
+  the traditional Unix "calendar" utility.  This is still under
+  development.  See the zshcalsys manual.  (The calendar functions
+  were in 4.3.4 but were not listed in this file.  There have been
+  significant enhancements since 4.3.4.)
+</li>
+<li>A new module zsh/curses provides a builtin zcurses for access to
+  to the curses screen manipulation package.  See the entry for zsh/curses
+  in the zshmodules manual.
+</li>
+<li>The module system has been enhanced to support the notion of "features"
+  that give more control over which builtins, parameters, conditions
+  and math functions are loaded from a module.  In particular,
+  "<tt>zmodload -F zsh/stat b:zstat</tt>" makes the builtin previously called
+  "stat" available as "zstat" (only) to avoid clashes with a system
+  command named "stat".
+</li>
+</ul>
+
+<h2>Major changes between versions 4.2 and 4.3.4</h2>
+
+<ul>
+<li>There is support for multibyte character sets.  This is now reasonably
+  close to complete, although Unicode combining characters don't work
+  properly.  See Multibyte Character Support in INSTALL.
+</li>
+<li>The shell can now run an installation function for a new user
+  (a user with no .zshrc, .zshenv, .zprofile or .zlogin file) without
+  any additional setting up by the administrator.  See "THE ZSH/NEWUSER
+  MODULE" in the zshmodules manual page.
+</li>
+<li>The manual now has a Roadmap section (manual page zshroadmap) to
+  give new users an indication of the most interesting parts of the
+  manual.
+</li>
+<li>New option <tt>PROMPT_SP</tt> (on by default): works around the problem that the
+  line editor can overwrite output with no newline at the end.  See the
+  zshoptions manual page.
+</li>
+<li>New option <tt>HIST_SAVE_BY_COPY</tt> (on by default): history is saved by
+  copying and renaming instead of directly overwriting.  See the
+  zshoptions manual page.
+</li>
+<li>New redirection syntax e.g. <tt>{myfd}&gt;file</tt> opens a new file descriptor
+  and stores the number in <tt>$myfd</tt>, so that <tt>&gt;&amp;$myfd</tt> will work.  Chosen
+  not to break existing code (and to be compatible with proposals for the
+  Korn shell).  See the section REDIRECTION in the zshmisc manual page.
+</li>
+<li>Substitutions of the form <tt>${var:-"$@"}</tt>, <tt>${var:+"$@"}</tt> and similar where
+  word-splitting is applied to the text after the :- or :+ (in particular,
+  where the <tt>SH_WORD_SPLIT</tt> option is in effect for compatibility) now
+  behave as in other Bourne- and POSIX-compatible shells when in the
+  appropriate emulation mode.
+</li>
+<li>New Posix-style zsh-specific tests <tt>[[:IDENT:]]</tt>, <tt>[[:IFS:]]</tt>,
+  <tt>[[:IFSSPACE:]]</tt>, <tt>[[:WORD:]]</tt> test if character can appear in identifier,
+  is an IFS character, is an IFS whitespace character, or is considered
+  as part of a word (is alphanumeric or appears in <tt>$WORDCHARS</tt>).  These
+  works correctly on multibyte characters if the appropriate support
+  is present.  See the section FILENAME GENERATION in the zshexpn
+  manual page.
+</li>
+<li>Time comparisons on files when sorting or using test operators will
+  use high-resolution timestamps when available.  This gives a
+  resolution of a nanosecond instead of a second.
+</li>
+<li>The idiom <tt>=(&lt;&lt;&lt;...)</tt> is optimised so that the shell internally turns
+  the ... into the contents of a file whose name is then substituted.
+  The syntax has always been usable by means of the <tt>NULLCMD</tt> feature,
+  but previously it generated an intermediate process; it has now
+  been rewritten along the same lines as the optimisation for <tt>$(&lt;...)</tt>
+  that inserts a file into the command line without the use of an
+  external programme.
+</li>
+<li>Supplied functions catch and throw provide limited support for
+exception handling using the <tt>`{ ... }</tt> always <tt>{ ... }'</tt> syntax.
+  See the section EXCEPTION HANDLING in the zshcontrib manual page.
+</li>
+<li>Signals now accept the SIG as part of the name for compatibility with
+  other shells.
+</li>
+<li>Editor function argument-base allows non-decimal arguments for
+  editor widgets.  See the entry in the zshzle manual page.
+</li>
+<li>As always, there are many enhancements to completion functions.
+</li>
+</ul>
+
 <h2>Changes since zsh version 4.2.0</h2>

 <ul>
-- 
1.7.0.5


-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9


^ permalink raw reply	[relevance 3%]

* [hamer@hamer.org.ua: Bug#590736: zsh: Segmentation fault in completion]
@ 2010-07-29  4:48  2% Clint Adams
  0 siblings, 0 replies; 200+ results
From: Clint Adams @ 2010-07-29  4:48 UTC (permalink / raw)
  To: zsh-workers

----- Forwarded message from Александр Новиченко <hamer@hamer.org.ua> -----

Date: Thu, 29 Jul 2010 01:12:48 +0300
From: Александр Новиченко <hamer@hamer.org.ua>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: Bug#590736: zsh: Segmentation fault in completion

Package: zsh
Version: 4.3.10-14


To reproduce this bug, mpc (an MPD client) is needed.
~/.zshrc must contain lines:
        setopt recexact
        autoload -U compinit
        compinit
After adding some songs to current playlist od MPD, type
"mpc play " in zsh and press <TAB>.

Probably, segfaults like this may appear in other cases too.

Debugger session around this bug:
(gdb) run
Starting program: /usr/local/bin/zsh
hamer# mpc play
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff64fe9bb in matcheq (a=0x7ffff7ff6af8, b=0x0) at compcore.c:3070
3070        return matchstreq(a->ipre, b->ipre) &&
(gdb) list
3065
3066    /**/
3067    static int
3068    matcheq(Cmatch a, Cmatch b)
3069    {
3070        return matchstreq(a->ipre, b->ipre) &&
3071            matchstreq(a->pre, b->pre) &&
3072            matchstreq(a->ppre, b->ppre) &&
3073            matchstreq(a->psuf, b->psuf) &&
3074            matchstreq(a->suf, b->suf) &&
(gdb) print a
$1 = (Cmatch) 0x7ffff7ff6af8
(gdb) print b
$2 = (Cmatch) 0x0
(gdb) up
#1  0x00007ffff64fe395 in add_match_data (alt=0, str=0x7ffff7ff6af0 "",
orig=0x75cc10 "", line=0x7ffff7ff6970, ipre=0x7ffff7ff67b8 "", ripre=0x0,
isuf=0x7ffff7ff67c0 "", pre=0x0, prpre=0x0, ppre=0x0, pline=0x0, psuf=0x0,
    sline=0x0, suf=0x0, flags=64, exact=1) at compcore.c:2935
2935            } else if (useexact && !matcheq(cm, ai->exactm)) {

As you can see, problem is in spelling NULL-pointer in matcheq().

For resolving ths bug, i propose use this patch:

diff -Naur zsh-4.3.10.orig/Src/Zle/compcore.c zsh-4.3.10/Src/Zle/compcore.c
--- zsh-4.3.10.orig/Src/Zle/compcore.c  2009-01-13 12:15:38.000000000 +0000
+++ zsh-4.3.10/Src/Zle/compcore.c       2010-07-27 22:58:40.726692827 +0000
@@ -2932,7 +2932,7 @@
                comp_setunset(0, 0, CP_EXACTSTR, 0);
            }
            ai->exactm = cm;
-       } else if (useexact && !matcheq(cm, ai->exactm)) {
+       } else if (useexact && (!ai->exactm || !matcheq(cm, ai->exactm))) {
            ai->exact = 2;
            ai->exactm = NULL;
            if (incompfunc)

P.S.: I have already reported this bug to devepolers of zsh
http://sourceforge.net/tracker/?func=detail&aid=3035629&group_id=4068&atid=104068

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-5-686 (SMP w/1 CPU core)
Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages zsh depends on:
ii  libc6                     2.11.2-2       Embedded GNU C Library:  
Shared lib
ii  libcap2                   1:2.17-2       support for getting/setting  
POSIX.
ii  libncursesw5              5.7+20100313-2 shared libraries for terminal 
hand

Versions of packages zsh recommends:
ii  libc6                         2.11.2-2   Embedded GNU C Library:  
Shared lib
ii  libpcre3                      7.8-3      Perl 5 Compatible Regular  
Expressi

Versions of packages zsh suggests:
ii  zsh-doc                       4.3.10-14  zsh documentation - info/HTML 
form

-- no debconf information


----- End forwarded message -----


^ permalink raw reply	[relevance 2%]

* Re: Fix testsuite errors due to shell quoted parameter expansion issue.
       [not found]     <20100803203204.GG13690@gmx.de>
@ 2010-08-03 20:55  3% ` Eric Blake
  2010-08-03 21:21  0%   ` Mikael Magnusson
  2010-08-05 22:15  0%   ` Chet Ramey
  0 siblings, 2 replies; 200+ results
From: Eric Blake @ 2010-08-03 20:55 UTC (permalink / raw)
  To: libtool-patches, gary, Bash - Bug, zsh-workers, Autoconf

[-- Attachment #1: Type: text/plain, Size: 2156 bytes --]

[adding autoconf to document some shell bugs]

On 08/03/2010 02:32 PM, Ralf Wildenhues wrote:
> Interesting shell unportability:
> 
> $ bash -c 'f=" val" e=; echo "$e"$f'
> val
> $ ksh -c 'f=" val" e=; echo "$e"$f'
>  val
> 
> ksh93, dash, zsh all do it like ksh.  Is that a bug in bash?

Yes; adding bug-bash accordingly.  According to POSIX:

http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_05

"After parameter expansion ( Parameter Expansion ), command substitution
( Command Substitution ), and arithmetic expansion ( Arithmetic
Expansion  ), the shell shall scan the results of expansions and
substitutions that did not occur in double-quotes for field splitting
and multiple fields can result."

Since $f is not quoted, its expansion must undergo field splitting.  But
since "$e" is quoted, it must not be elided even though empty.  The
result must be _two_ fields, as if you had done "echo '' 'val'".

But it is _also_ a bug in zsh; adding zsh-workers accordingly.

$ zsh -cvx 'f=" val" e=; echo "$e"$f'
+zsh:1> f=' val' e=''
+zsh:1> echo ' val'
 val

Oops - zsh only passed one argument to echo, with a leading space,
instead of passing an empty argument and letting echo supply the space.
 ksh93, pdksh, and dash get it right (although dash doesn't use quotes
in -vx output, hence my use of n() to force things to tell; n() is
another way to expose the bash and zsh bugs).

$ ksh -cvx 'n() { echo $#; }; f=" val" e=; n "$e"$f'
n() { echo $#; }; f=" val" e=; n ""$f+ f=' val'
+ e=''
+ n '' val
+ echo 2
2

And meanwhile, I found a ksh93 parsing bug (don't know where to report
that):

$ ksh -c 'a(){ echo hi; }; a'
ksh: syntax error at line 1: `}' unexpected
$ ksh -c 'a() { echo hi; }; a'
hi
$ bash -c 'a(){ echo hi; }; a'
hi
$ /bin/sh -c 'a(){ echo hi; }; a'
hi

ksh is the only shell that requires a space between the ) and {, even
though the ) is a metacharacter and should not need trailing space (even
Solaris /bin/sh got that right).

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[relevance 3%]

* Re: Fix testsuite errors due to shell quoted parameter expansion  issue.
  2010-08-03 20:55  3% ` Fix testsuite errors due to shell quoted parameter expansion issue Eric Blake
@ 2010-08-03 21:21  0%   ` Mikael Magnusson
  2010-08-03 21:28  3%     ` Eric Blake
  2010-08-04 15:18  0%     ` John Lumby
  2010-08-05 22:15  0%   ` Chet Ramey
  1 sibling, 2 replies; 200+ results
From: Mikael Magnusson @ 2010-08-03 21:21 UTC (permalink / raw)
  To: Eric Blake; +Cc: libtool-patches, gary, zsh-workers, Autoconf

On 3 August 2010 22:55, Eric Blake <eblake@redhat.com> wrote:
> [adding autoconf to document some shell bugs]
>
> On 08/03/2010 02:32 PM, Ralf Wildenhues wrote:
>> Interesting shell unportability:
>>
>> $ bash -c 'f=" val" e=; echo "$e"$f'
>> val
>> $ ksh -c 'f=" val" e=; echo "$e"$f'
>>  val
>>
>> ksh93, dash, zsh all do it like ksh.  Is that a bug in bash?
>
> Yes; adding bug-bash accordingly.  According to POSIX:
>
> http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_05
>
> "After parameter expansion ( Parameter Expansion ), command substitution
> ( Command Substitution ), and arithmetic expansion ( Arithmetic
> Expansion  ), the shell shall scan the results of expansions and
> substitutions that did not occur in double-quotes for field splitting
> and multiple fields can result."
>
> Since $f is not quoted, its expansion must undergo field splitting.  But
> since "$e" is quoted, it must not be elided even though empty.  The
> result must be _two_ fields, as if you had done "echo '' 'val'".
>
> But it is _also_ a bug in zsh; adding zsh-workers accordingly.
>
> $ zsh -cvx 'f=" val" e=; echo "$e"$f'
> +zsh:1> f=' val' e=''
> +zsh:1> echo ' val'
>  val
>
> Oops - zsh only passed one argument to echo, with a leading space,
> instead of passing an empty argument and letting echo supply the space.
>  ksh93, pdksh, and dash get it right (although dash doesn't use quotes
> in -vx output, hence my use of n() to force things to tell; n() is
> another way to expose the bash and zsh bugs).

zsh doesn't do word splitting by default, you can enable it with the = modifier:
% zsh -fcvx 'f=" val" e=; echo "$e"$=f'
+zsh:1> f=' val' e=''
+zsh:1> echo '' val
 val

does what you want

Alternatively you can make zsh try to be closer to sh by setting
argv[0] to sh when executing it, or running 'emulate sh' as the first
command (and possibly other ways I don't know about):
% zsh -fcvx 'emulate sh;f=" val" e=; echo "$e"$f'
+zsh:1> emulate sh
+zsh:1> f=' val' e=''
+zsh:1> echo '' val
 val

There's also --shwordsplit for this specific case:
% zsh --shwordsplit -fcvx 'f=" val" e=; echo "$e"$f'
+zsh:1> f=' val' e=''
+zsh:1> echo '' val
 val

(the -f above only avoids loading my .zshenv which would spam my output)

-- 
Mikael Magnusson


^ permalink raw reply	[relevance 0%]

* Re: Fix testsuite errors due to shell quoted parameter expansion issue.
  2010-08-03 21:21  0%   ` Mikael Magnusson
@ 2010-08-03 21:28  3%     ` Eric Blake
  2010-08-04 15:18  0%     ` John Lumby
  1 sibling, 0 replies; 200+ results
From: Eric Blake @ 2010-08-03 21:28 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: zsh-workers, Autoconf

[-- Attachment #1: Type: text/plain, Size: 1726 bytes --]

[trimming the cc a bit]

On 08/03/2010 03:21 PM, Mikael Magnusson wrote:
>> But it is _also_ a bug in zsh; adding zsh-workers accordingly.
>>
>> $ zsh -cvx 'f=" val" e=; echo "$e"$f'
>> +zsh:1> f=' val' e=''
>> +zsh:1> echo ' val'
>>  val
>>
>> Oops - zsh only passed one argument to echo, with a leading space,
>> instead of passing an empty argument and letting echo supply the space.
>>  ksh93, pdksh, and dash get it right (although dash doesn't use quotes
>> in -vx output, hence my use of n() to force things to tell; n() is
>> another way to expose the bash and zsh bugs).
> 
> zsh doesn't do word splitting by default, you can enable it with the = modifier:
> % zsh -fcvx 'f=" val" e=; echo "$e"$=f'
> +zsh:1> f=' val' e=''
> +zsh:1> echo '' val
>  val
> 
> does what you want

Thanks for the information.

> 
> Alternatively you can make zsh try to be closer to sh by setting
> argv[0] to sh when executing it, or running 'emulate sh' as the first
> command (and possibly other ways I don't know about):
> % zsh -fcvx 'emulate sh;f=" val" e=; echo "$e"$f'
> +zsh:1> emulate sh
> +zsh:1> f=' val' e=''
> +zsh:1> echo '' val
>  val

In the context of portable shell programming, and autoconf in
particular, we already _always_ force zsh into 'emulate sh' mode, so
that we don't trip up on non-POSIX incompatibilities like this behavior
of word splitting.  So it should not be a problem for autoconf, other
than to remind users that portable programming requires the use of
'emulate sh' in scripts that don't pick up autoconf's automatic shell
sanitization prelude.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[relevance 3%]

* RE: Fix testsuite errors due to shell quoted parameter expansion issue.
  2010-08-03 21:21  0%   ` Mikael Magnusson
  2010-08-03 21:28  3%     ` Eric Blake
@ 2010-08-04 15:18  0%     ` John Lumby
  1 sibling, 0 replies; 200+ results
From: John Lumby @ 2010-08-04 15:18 UTC (permalink / raw)
  To: eblake; +Cc: zsh-workers, autoconf maillist, libtool-patches, mikachu

[-- Attachment #1: Type: text/plain, Size: 3681 bytes --]


Re the statement

    since "$e" is quoted, it must not be elided

I don't think that is correct.   In fact "$e" *must* be elided  -  because you juxtaposed it with the next token.    eliding and quoting are orthogonal.

What you appear to be be expecting is that the effect of quoting one token should somehow have some effect on interpretation of a special character (blank) in a subsequent unquoted token.   I don't think that is expected behaviour.      The quoting of $e has the effect of quoting any special characters inside *it*, of which there are none.     your blank is unquoted.    Then word-spilling proceeds.

What I find interesting is this

bash -c 'declare -i length; f=" val" e=;concat="$e"$f; length=${#concat}; echo "length= $length"'
4

John Lumby

> Date: Tue, 3 Aug 2010 23:21:02 +0200
> From: mikachu@gmail.com
> To: eblake@redhat.com
> CC: zsh-workers@zsh.org; Autoconf@gnu.org; libtool-patches@gnu.org
> Subject: Re: Fix testsuite errors due to shell quoted parameter expansion 	issue.
> 
> On 3 August 2010 22:55, Eric Blake <eblake@redhat.com> wrote:
> > [adding autoconf to document some shell bugs]
> >
> > On 08/03/2010 02:32 PM, Ralf Wildenhues wrote:
> >> Interesting shell unportability:
> >>
> >> $ bash -c 'f=" val" e=; echo "$e"$f'
> >> val
> >> $ ksh -c 'f=" val" e=; echo "$e"$f'
> >>  val
> >>
> >> ksh93, dash, zsh all do it like ksh.  Is that a bug in bash?
> >
> > Yes; adding bug-bash accordingly.  According to POSIX:
> >
> > http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_05
> >
> > "After parameter expansion ( Parameter Expansion ), command substitution
> > ( Command Substitution ), and arithmetic expansion ( Arithmetic
> > Expansion  ), the shell shall scan the results of expansions and
> > substitutions that did not occur in double-quotes for field splitting
> > and multiple fields can result."
> >
> > Since $f is not quoted, its expansion must undergo field splitting.  But
> > since "$e" is quoted, it must not be elided even though empty.  The
> > result must be _two_ fields, as if you had done "echo '' 'val'".
> >
> > But it is _also_ a bug in zsh; adding zsh-workers accordingly.
> >
> > $ zsh -cvx 'f=" val" e=; echo "$e"$f'
> > +zsh:1> f=' val' e=''
> > +zsh:1> echo ' val'
> >  val
> >
> > Oops - zsh only passed one argument to echo, with a leading space,
> > instead of passing an empty argument and letting echo supply the space.
> >  ksh93, pdksh, and dash get it right (although dash doesn't use quotes
> > in -vx output, hence my use of n() to force things to tell; n() is
> > another way to expose the bash and zsh bugs).
> 
> zsh doesn't do word splitting by default, you can enable it with the = modifier:
> % zsh -fcvx 'f=" val" e=; echo "$e"$=f'
> +zsh:1> f=' val' e=''
> +zsh:1> echo '' val
>  val
> 
> does what you want
> 
> Alternatively you can make zsh try to be closer to sh by setting
> argv[0] to sh when executing it, or running 'emulate sh' as the first
> command (and possibly other ways I don't know about):
> % zsh -fcvx 'emulate sh;f=" val" e=; echo "$e"$f'
> +zsh:1> emulate sh
> +zsh:1> f=' val' e=''
> +zsh:1> echo '' val
>  val
> 
> There's also --shwordsplit for this specific case:
> % zsh --shwordsplit -fcvx 'f=" val" e=; echo "$e"$f'
> +zsh:1> f=' val' e=''
> +zsh:1> echo '' val
>  val
> 
> (the -f above only avoids loading my .zshenv which would spam my output)
> 
> -- 
> Mikael Magnusson
> 
> _______________________________________________
> Autoconf mailing list
> Autoconf@gnu.org
> http://lists.gnu.org/mailman/listinfo/autoconf
 		 	   		  

^ permalink raw reply	[relevance 0%]

* Re: Fix testsuite errors due to shell quoted parameter expansion issue.
  2010-08-03 20:55  3% ` Fix testsuite errors due to shell quoted parameter expansion issue Eric Blake
  2010-08-03 21:21  0%   ` Mikael Magnusson
@ 2010-08-05 22:15  0%   ` Chet Ramey
  1 sibling, 0 replies; 200+ results
From: Chet Ramey @ 2010-08-05 22:15 UTC (permalink / raw)
  To: Eric Blake
  Cc: libtool-patches, gary, Bash - Bug, zsh-workers, Autoconf, chet.ramey

On 8/3/10 4:55 PM, Eric Blake wrote:
> [adding autoconf to document some shell bugs]
> 
> On 08/03/2010 02:32 PM, Ralf Wildenhues wrote:
>> Interesting shell unportability:
>>
>> $ bash -c 'f=" val" e=; echo "$e"$f'
>> val
>> $ ksh -c 'f=" val" e=; echo "$e"$f'
>>  val
>>
>> ksh93, dash, zsh all do it like ksh.  Is that a bug in bash?
> 
> Yes; adding bug-bash accordingly.  According to POSIX:

Thanks; this was an easy fix.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


^ permalink raw reply	[relevance 0%]

* Re: [RFC or so] Add HASH_LOOKUP option
  @ 2010-08-24  8:37  2%     ` Bart Schaefer
  0 siblings, 0 replies; 200+ results
From: Bart Schaefer @ 2010-08-24  8:37 UTC (permalink / raw)
  To: zsh workers

On Aug 23,  8:25pm, Mikael Magnusson wrote:
}
} > I think there may be  problem with this in the event that the "hash"
} > command has been used to deliberately insert an entry into the hash
} > table.  That's a documented mechanism for overriding path search.
} > Also I think you've missed that execute() also uses the hash table;
} > did you intend that "command foo" ignores NO_HASHLOOKUP?
} 
} As I said, I didn't check everywhere yet to see if there are more
} duplicated codepaths, so no, that is not the intent. However, command
} foo for me doesn't appear to ignore it for me.

execute() gets called for all WC_SIMPLE commands that aren't builtins
or functions, including the "command" and "exec" precommand modifiers:

    /* for command -p, search the default path */ 
    if (defpath) {
        ...
    } else {
   
	if ((cn = (Cmdnam) cmdnamtab->getnode(cmdnamtab, arg0))) {
            ...
        }
        ... usual path search ...
    }

} The fact that 'command' supposedly does a hash lookup while 'command
} -p' doesn't seems to be rather undocumented too.

It'd hardly be possible to search the default POSIX $PATH via a hash
lookup, given that the hash table is filled from what is most commonly
a non-default $path.
 
} > It starts (if the command is not already in the hash table and HASHCMDS
} > is set) by doing hashcmd(), which performs a search of only absolute
} > directory names in the path (not, e.g., ".", "..", or other relative
} > names).  That search itself seems a bit off because if *arg0 == '/'
} > then it's going to prepend the path component anyway. [*]
} 
} That's the first fishy thing I noticed, why is this for loop over
} $path copied to at least four places, two of which are in the same
} function, with slight variations?
 
My recollection (which I haven't bothered to augment by attempting to
search the list archives) is that the path is searched first so that
the hash table is populated so spelling corrections can be suggested,
or something like that.  The first such search, though, has to skip
relative directories, lest "." cause NO_PATH_DIRS to be violated.

Then it's necessary to repeat the search for just the directories that
previously were skipped, in case one of them appears earlier in the
path than the directory where the command was previously found.  So
that's two variations.

Then execute() has to search either the default $PATH (third variant)
or the normal $path (fourth variant), but doesn't have to worry about
separating absolute and relative directories; it can just use whichever
it finds first, just like the final fallback attempt in findcmd().
 
} I guess in this specific function I could move my isset(HASHLOOKUP) to
} be in the & HASHED if() instead of the cn one. Which is to say if the
} whole thing isn't broken in the first place.

Except for the part about putting goofy stuff in the hash table in a
few edge cases, I think it's not actually broken, just disorganized.

} > [**] The HASHED bit means the command was deliberately inserted into
} > the hash table with the "hash" builtin, rather than found by search.
} > In this case the both findcmd() and execute() are forced to believe
} > what the hash table tells them.
} 
} Could this be used, theoretically, to still allow users to override
} the path, and still do a full path search for search hashed entries?

I'm not sure what you mean, but on my best guess:  If you poke into
the hash table with "hash foo=/xyz/foo" then the "foo" command will
run /xyz/foo even if ${^path}/foo(N) is non-empty.

However, and this might be considered a bug, changing the value of
$path discards the entire hash table, including entries that have been
explicitly inserted with "hash".

} Another thing I was vaguely wondering about is how is HASH_CMDS forced
} on by CORRECT? I was unable to grep up anything about it.

It isn't actually forced on by CORRECT, but during the actual event of
correcting, spckword() calls cmdnamtab->filltable() which has the same
effect.


^ permalink raw reply	[relevance 2%]

* PATCH: NEWS for 4.3.11
@ 2010-09-08 14:02  6% Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2010-09-08 14:02 UTC (permalink / raw)
  To: Zsh hackers list

Here are some new features I noted by scanning the change log.  If
you're using anything I missed let me know.

Index: NEWS
===================================================================
RCS file: /cvsroot/zsh/zsh/NEWS,v
retrieving revision 1.32
diff -p -u -r1.32 NEWS
--- NEWS	15 Apr 2010 09:26:37 -0000	1.32
+++ NEWS	8 Sep 2010 13:59:27 -0000
@@ -29,6 +29,53 @@ e.g. /u/b/z no longer completes to /usr/
 where this form of completion is pathologically slow due to network
 performance.
 
+With the MULTIBYTE option, the line editor now highlights bytes in the
+input that are not part of a valid character in the current locale in hex
+as <XX> for hex digits X; highlighting is controlled by the "special"
+keyword in the zle_highlight array.  These can be distinguished from
+unprintable Unicode characters which also use "special" highlighting as the
+latter are always two or four bytes long, e.g. <XXXX>, <XXXXXXXX>.
+
+The line editor now sets the variable ZLE_LINE_ABORTED if there is
+an error when editing the line.  The following code can be used
+to create a bindable editor widget to restore the aborted line:
+  recover-line() { LBUFFER=$ZLE_LINE_ABORTED RBUFFER=; }
+  zle -N recover-line
+
+The parameter ZLE_STATE, available in user-defined line editor widgets,
+gives information on the state of the line editor.  Currently this is
+whether the line editor is in insert or overwrite mode.
+
+There is now a function system for recording and restoring recently
+entered directories.  See the entry for cdr in the zshcontrib manual page.
+
+The (D) flag use in parameter expansion abbreviates directories in the
+substituted value.  The (q-) flag does minimal shell quotation of arguments
+for maximum human readability of the result.
+
+The new shell option SOURCE_TRACE causes the shell to report files
+containing shell code that the shell executes directly, i.e. startup files
+or files run with the `source' or `.' builtins.
+
+The shell option SUN_KEYBOARD_HACK has been supplemented by a more general
+mechanism: the KEYBOARD_HACK variable defines the character to be ignored.
+
+The new shell option POSIX_CD, active in emulations of POSIX-based shells,
+makes the cd builtin POSIX-compatible.
+
+The shell option MONITOR can be set in non-interactive shells, and also in
+subshells (as created by surrounding commands with parentheses), turning on
+job control for that subshell.  The initial behaviour of a subshell is
+still to turn job control off, however if the new POSIX_JOBS option is set
+MONITOR remains active in subshells.
+
+Regular expression matches now use the same variables for storing matched
+components as shell patttern matching.  The function system now provides
+the function regexp-replace for replacing text using regular expressions.
+The zle widgets replace-string, replace-string-again, if defined with regex
+in the name (e.g. "zle -N replace-regexp replace-string"), perform regular
+expression matches.  In replacement text \& and \1 have the standard
+meaning.
 
 Changes between versions 4.3.9 and 4.3.10
 -----------------------------------------

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[relevance 6%]

* PATCH: POSIX_TRAPS option
@ 2010-09-10 19:31  6% Peter Stephenson
  2010-09-12  3:49  3% ` Bart Schaefer
  0 siblings, 1 reply; 200+ results
From: Peter Stephenson @ 2010-09-10 19:31 UTC (permalink / raw)
  To: Zsh hackers list

It's high time we were able to treat EXIT traps the same way as other
shells.

Oddly, POSIX doesn't seem to specify when EXIT traps are actually run,
but the implication must be it refers to exiting the shell, not
returning from shell functions.

Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.94
diff -p -u -r1.94 options.yo
--- Doc/Zsh/options.yo	23 Aug 2010 13:40:43 -0000	1.94
+++ Doc/Zsh/options.yo	10 Sep 2010 19:29:48 -0000
@@ -1876,6 +1876,19 @@ If multibyte character support is not co
 ignored; all octets with the top bit set may be used in identifiers.
 This is non-standard but is the traditional zsh behaviour.
 )
+pindex(POSIX_TRAPS)
+pindex(NO_POSIX_TRAPS)
+pindex(POSIXTRAPS)
+pindex(NOPOSIXTRAPS)
+cindex(traps, on function exit)
+cindex(traps, POSIX compatibility)
+item(tt(POSIX_TRAPS) <K> <S>)(
+When the is option is set, the usual zsh behaviour of executing
+traps for tt(EXIT) on exit from shell functions is suppressed.
+In that case, manipulating tt(EXIT) traps always alters the global
+trap for exiting the shell; the tt(LOCAL_TRAPS) option is
+ignored for the tt(EXIT) trap.
+)
 pindex(SH_FILE_EXPANSION)
 pindex(NO_SH_FILE_EXPANSION)
 pindex(SHFILEEXPANSION)
Index: Src/options.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/options.c,v
retrieving revision 1.54
diff -p -u -r1.54 options.c
--- Src/options.c	16 Mar 2010 09:44:55 -0000	1.54
+++ Src/options.c	10 Sep 2010 19:29:48 -0000
@@ -204,6 +204,7 @@ static struct optname optns[] = {
 {{NULL, "posixcd",            OPT_EMULATE|OPT_BOURNE},	 POSIXCD},
 {{NULL, "posixidentifiers",   OPT_EMULATE|OPT_BOURNE},	 POSIXIDENTIFIERS},
 {{NULL, "posixjobs",          OPT_EMULATE|OPT_BOURNE},	 POSIXJOBS},
+{{NULL, "posixtraps",          OPT_EMULATE|OPT_BOURNE},	 POSIXTRAPS},
 {{NULL, "printeightbit",      0},                        PRINTEIGHTBIT},
 {{NULL, "printexitvalue",     0},			 PRINTEXITVALUE},
 {{NULL, "privileged",	      OPT_SPECIAL},		 PRIVILEGED},
Index: Src/signals.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/signals.c,v
retrieving revision 1.59
diff -p -u -r1.59 signals.c
--- Src/signals.c	22 Aug 2010 20:08:57 -0000	1.59
+++ Src/signals.c	10 Sep 2010 19:29:49 -0000
@@ -864,7 +864,8 @@ removetrap(int sig)
      * one, to aid in removing this one.  However, if there's
      * already one at the current locallevel we just overwrite it.
      */
-    if (!dontsavetrap && (isset(LOCALTRAPS) || sig == SIGEXIT) &&
+    if (!dontsavetrap &&
+	(sig == SIGEXIT ? !isset(POSIXTRAPS) : isset(LOCALTRAPS)) &&
 	locallevel &&
 	(!trapped || locallevel > (sigtrapped[sig] >> ZSIG_SHIFT)))
 	dosavetrap(sig, locallevel);
@@ -932,7 +933,7 @@ starttrapscope(void)
      * so give it the next higher one. dosavetrap() is called
      * automatically where necessary.
      */
-    if (sigtrapped[SIGEXIT]) {
+    if (sigtrapped[SIGEXIT] && !isset(POSIXTRAPS)) {
 	locallevel++;
 	unsettrap(SIGEXIT);
 	locallevel--;
@@ -960,7 +961,7 @@ endtrapscope(void)
      */
     if (intrap)
 	exittr = 0;
-    else if ((exittr = sigtrapped[SIGEXIT])) {
+    else if (!isset(POSIXTRAPS) && (exittr = sigtrapped[SIGEXIT])) {
 	if (exittr & ZSIG_FUNC) {
 	    exitfn = removehashnode(shfunctab, "TRAPEXIT");
 	} else {
@@ -1005,7 +1006,8 @@ endtrapscope(void)
     }
 
     if (exittr) {
-	dotrapargs(SIGEXIT, &exittr, exitfn);
+	if (!isset(POSIXTRAPS))
+	    dotrapargs(SIGEXIT, &exittr, exitfn);
 	if (exittr & ZSIG_FUNC)
 	    shfunctab->freenode((HashNode)exitfn);
 	else
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.166
diff -p -u -r1.166 zsh.h
--- Src/zsh.h	27 May 2010 18:57:34 -0000	1.166
+++ Src/zsh.h	10 Sep 2010 19:29:49 -0000
@@ -1987,6 +1987,7 @@ enum {
     POSIXCD,
     POSIXIDENTIFIERS,
     POSIXJOBS,
+    POSIXTRAPS,
     PRINTEIGHTBIT,
     PRINTEXITVALUE,
     PRIVILEGED,
Index: Test/C03traps.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/C03traps.ztst,v
retrieving revision 1.19
diff -p -u -r1.19 C03traps.ztst
--- Test/C03traps.ztst	10 May 2010 12:31:49 -0000	1.19
+++ Test/C03traps.ztst	10 Sep 2010 19:29:49 -0000
@@ -371,6 +371,23 @@
 0: EXIT trap set in command substitution
 >command substitution exited
 
+   (cd ..; $ZTST_exe -fc 'setopt posixtraps;
+   TRAPEXIT() { print Exited; }
+   fn1() { trap; }
+   setopt localtraps # should be ignored by EXIT
+   fn2() { TRAPEXIT() { print No, really exited; } }
+   fn1
+   fn2
+   fn1')
+0:POSIX_TRAPS option
+>TRAPEXIT () {
+>	print Exited
+>}
+>TRAPEXIT () {
+>	print No, really exited
+>}
+>No, really exited
+
 %clean
 
   rm -f TRAPEXIT

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


^ permalink raw reply	[relevance 6%]

* Re: PATCH: POSIX_TRAPS option
  2010-09-10 19:31  6% PATCH: POSIX_TRAPS option Peter Stephenson
@ 2010-09-12  3:49  3% ` Bart Schaefer
  0 siblings, 0 replies; 200+ results
From: Bart Schaefer @ 2010-09-12  3:49 UTC (permalink / raw)
  To: Zsh hackers list

On Sep 10,  8:31pm, Peter Stephenson wrote:
}
} It's high time we were able to treat EXIT traps the same way as other
} shells.

Hrm.  A couple of thoughts ...

(1) POSIX doesn't have anything to do with TRAPEXIT (or with any of
the other special TRAP functions).  Perhaps the POSIX_TRAPS option
should apply only to the "trap" builtin?  I don't feel very strongly
about it either way, but for example TRAPEXIT persists into subshells
whereas "trap" does not.

(2) The documentation should explain (somewhere) in what order the
EXIT trap and the zshexit hook function are executed.  Emprically,
zshexit is always last.


^ permalink raw reply	[relevance 3%]

* avoid $status and $options in POSIX mode
@ 2010-09-17 17:33  9% Eric Blake
  2010-09-18  3:25  8% ` Bart Schaefer
  0 siblings, 1 reply; 200+ results
From: Eric Blake @ 2010-09-17 17:33 UTC (permalink / raw)
  To: zsh-workers

POSIX states "The name space of environment variable names containing 
lowercase letters is reserved for applications. Applications can define 
any environment variables with names from this name space without 
modifying the behavior of the standard utilities."
http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08

Yet, the existence of zsh-magic variables like $status and $options 
infringe upon the right of a user's script to use this namespace for 
their own desires.  For example, see this recent autoconf patch:
http://git.sv.gnu.org/cgit/autoconf.git/commit/?id=23a2c336

It would be really nice if 'emulate sh' could disable zsh magic handling 
of any variables that infringe upon the lower-case namespace reserved 
for applications.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


^ permalink raw reply	[relevance 9%]

* Re: avoid $status and $options in POSIX mode
  2010-09-17 17:33  9% avoid $status and $options in POSIX mode Eric Blake
@ 2010-09-18  3:25  8% ` Bart Schaefer
  2010-09-18  7:25  8%   ` Bart Schaefer
  0 siblings, 1 reply; 200+ results
From: Bart Schaefer @ 2010-09-18  3:25 UTC (permalink / raw)
  To: Eric Blake, zsh-workers

On Sep 17, 11:33am, Eric Blake wrote:
} Subject: avoid $status and $options in POSIX mode
}
} Yet, the existence of zsh-magic variables like $status and $options 
} infringe upon the right of a user's script to use this namespace for 
} their own desires.  For example, see this recent autoconf patch:
} http://git.sv.gnu.org/cgit/autoconf.git/commit/?id=23a2c336

That patch is incorrect (or maybe only partly correct).  The "options"
variable is only defined if the zsh/parameter module has been loaded,
which it won't be when the shell is started as "sh".  The "status"
variable is also disabled when the shell is started as "sh".

If autoconf is running into problems with $options, the maintainers
need to find out why zsh/parameter is being loaded in the first place.
Is the shell run by the name "zsh" and *then* switched to emulation?
In that event, module autoloads will still be in effect, so $options
will load itself.

The zsh manual says:

In `sh' and `ksh' compatibility modes the following parameters are not
special and not initialized by the shell: ARGC, argv, cdpath, fignore,
fpath, HISTCHARS, mailpath, MANPATH, manpath, path, prompt, PROMPT,
PROMPT2, PROMPT3, PROMPT4, psvar, status, watch.

} It would be really nice if 'emulate sh' could disable zsh magic handling 
} of any variables that infringe upon the lower-case namespace reserved 
} for applications.

Starting the shell as zsh and then running "emulate" is not the same as
compatibility mode, and is unlikely ever to be; "emulate" is meant to
switch back and forth with minimal loss of state, not to entirely wipe
the slate and become another shell.


^ permalink raw reply	[relevance 8%]

* Re: avoid $status and $options in POSIX mode
  2010-09-18  3:25  8% ` Bart Schaefer
@ 2010-09-18  7:25  8%   ` Bart Schaefer
  2010-09-19 21:39  5%     ` Bart Schaefer
  0 siblings, 1 reply; 200+ results
From: Bart Schaefer @ 2010-09-18  7:25 UTC (permalink / raw)
  To: Eric Blake, zsh-workers

On Sep 17,  8:25pm, Bart Schaefer wrote:
}
} Starting the shell as zsh and then running "emulate" is not the same as
} compatibility mode, and is unlikely ever to be; "emulate" is meant to
} switch back and forth with minimal loss of state, not to entirely wipe
} the slate and become another shell.

However, it occurs to me that's no reason not to provide a way to wipe
the slate ...

I've probably forgotten something here, but this should give the basic
idea.  This creates a module named "autoconf/posixshell" (it could be
called anything, including "posix/shell" ... just tweak posixshell.mdd)
which sets up a parameter scope (as if entering a shell function) and
predeclares variables to mask all those that, according to the manual
(and params.c) are not supposed to be used when not in native mode.
Then it runs "emulate -R sh".

When the module is unloaded, it restores everything, very much like
leaving a function scope.  I'm not entirely sure there aren't side
effects of making the global parameter scope deeper, but I've tried
a few simple tests with it and it seems to work as expected.

There are probably other things that could be done here -- for example,
hiding or overriding various builtins (though if you ever want to back
out again you'd better not hide "zmodload") -- and of course the print
statements could go away.  Oh, a fairly large omission at this point
is that it doesn't disable autoloads from other modules, so this does
not yet solve the problem of $options manifesting itself.  However,
the upshot of this is, with a module like this installed in the proper
location, autoconf could replace "emulate sh" (or whatever it's
doing now) with "zmodload autoconf/posixshell" and thereby assure
itself of whatever environment it needed.

Aside:  The module docs in INSTALL and zsh-development-guide could
really use some fixing up.  In particular they should mention that if
configure has been run with --disable-dynamic then the modules whose
mdd files say "dynamic" are never so much as compiled.  That had me
confused for a bit about why my newly-added module was not built.


--- /dev/null	2010-08-30 09:03:23.520307808 -0700
+++ posixshell.c	2010-09-17 23:44:20.000000000 -0700
@@ -0,0 +1,126 @@
+/*
+ * posixshell.c - a POSIX helper module for zsh
+ *
+ * This file is part of zsh, the Z shell.
+ *
+ * Copyright (c) 2010 Bart Schaefer
+ * All rights reserved.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and to distribute modified versions of this software for any
+ * purpose, provided that the above copyright notice and the following
+ * two paragraphs appear in all copies of this software.
+ *
+ * In no event shall Bart Schaefer or the Zsh Development Group be liable
+ * to any party for direct, indirect, special, incidental, or consequential
+ * damages arising out of the use of this software and its documentation,
+ * even if Bart Schaefer and the Zsh Development Group have been advised of
+ * the possibility of such damage.
+ *
+ * Bart Schaefer and the Zsh Development Group specifically disclaim any
+ * warranties, including, but not limited to, the implied warranties of
+ * merchantability and fitness for a particular purpose.  The software
+ * provided hereunder is on an "as is" basis, and Bart Schaefer and the
+ * Zsh Development Group have no obligation to provide maintenance,
+ * support, updates, enhancements, or modifications.
+ *
+ */
+
+#include "posixshell.mdh"
+#include "posixshell.pro"
+
+static char saveopts[OPT_SIZE];
+static int saveemulation;
+
+/**/
+int
+setup_(UNUSED(Module m))
+{
+    /* Copied from doshfunc() */
+    memcpy(saveopts, opts, sizeof(opts));
+    saveemulation = emulation;
+
+    printf("Entering POSIX emulation.\n");
+    fflush(stdout);
+
+    return 0;
+}
+
+static struct features module_features = {
+    0
+};
+
+/**/
+int
+features_(Module m, char ***features)
+{
+    *features = featuresarray(m, &module_features);
+    return 0;
+}
+
+/**/
+int
+enables_(Module m, int **enables)
+{
+    return 0;
+}
+
+/**/
+int
+boot_(Module m)
+{
+    startparamscope();
+
+    createparam("ARGC", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("HISTCHARS", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("histchars", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("status", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("prompt", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("PROMPT", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("PROMPT2", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("PROMPT3", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("PROMPT4", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("MANPATH", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("argv", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("fignore", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("cdpath", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("fpath", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("mailpath", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("manpath", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("psvar", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("watch", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("zsh_eval_context", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("module_path", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("path", PM_HIDE|PM_LOCAL|PM_UNSET);
+    createparam("pipestatus", PM_HIDE|PM_LOCAL|PM_UNSET);
+
+    execstring("emulate -R sh", 1, 0, "POSIX");
+    errflag = lastval = 0;
+
+    return 0;
+}
+
+/**/
+int
+cleanup_(Module m)
+{
+    endparamscope();
+    return 0;
+}
+
+/**/
+int
+finish_(UNUSED(Module m))
+{
+    printf("Leaving POSIX emulation.\n");
+    fflush(stdout);
+
+    /* Copied from doshfunc() */
+    saveopts[PRIVILEGED] = opts[PRIVILEGED];
+    saveopts[RESTRICTED] = opts[RESTRICTED];
+    memcpy(opts, saveopts, sizeof(opts));
+    emulation = saveemulation;
+
+    return 0;
+}
--- /dev/null	2010-08-30 09:03:23.520307808 -0700
+++ posixshell.mdd	2010-09-17 23:28:47.000000000 -0700
@@ -0,0 +1,5 @@
+name=autoconf/posixshell
+link=dynamic
+load=no
+
+objects="posixshell.o"


^ permalink raw reply	[relevance 8%]

* Re: avoid $status and $options in POSIX mode
  2010-09-18  7:25  8%   ` Bart Schaefer
@ 2010-09-19 21:39  5%     ` Bart Schaefer
  2010-09-20  8:45  5%       ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Bart Schaefer @ 2010-09-19 21:39 UTC (permalink / raw)
  To: zsh-workers

On Sep 18, 12:25am, Bart Schaefer wrote:
}
} I'm not entirely sure there aren't side effects of [the proposed
} autoconf/posixshell module] making the global parameter scope deeper

The worst effect I've found is that loading the module from inside a
function makes it appear that function scope has never ended.  This
means the module must refuse to load except at top level, or at least
behave differently in a function.

Misc. mostly harmless things ...

- An extra prompt is printed after "exit" when interactive
- The warn_create_global option reports all undeclared parameters
- Pushed history with "fc -a -p" is popped on module unload (feature!)
- Diagnostics print line numbers as if in a function body

} Oh, a fairly large omission at this point is that it doesn't disable
} autoloads from other modules, so this does not yet solve the problem
} of $options manifesting itself.

The most obvious solution to this seems to be to walk the parameter
table looking for PM_AUTOLOAD and mask any parameter that has it.
Anyone have better suggestions?

-- 


^ permalink raw reply	[relevance 5%]

* Re: avoid $status and $options in POSIX mode
  2010-09-19 21:39  5%     ` Bart Schaefer
@ 2010-09-20  8:45  5%       ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2010-09-20  8:45 UTC (permalink / raw)
  To: zsh-workers

On Sun, 19 Sep 2010 14:39:43 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> } Oh, a fairly large omission at this point is that it doesn't disable
> } autoloads from other modules, so this does not yet solve the problem
> } of $options manifesting itself.
> 
> The most obvious solution to this seems to be to walk the parameter
> table looking for PM_AUTOLOAD and mask any parameter that has it.
> Anyone have better suggestions?

I don't see any real problem with this one.  There's plenty of code that
does this already.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK



Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[relevance 5%]

* Fw: zsh POSIX_TRAPS option
@ 2010-10-11  8:42  5% Peter Stephenson
  2010-10-11 15:16  4% ` Bart Schaefer
  0 siblings, 1 reply; 200+ results
From: Peter Stephenson @ 2010-10-11  8:42 UTC (permalink / raw)
  To: Zsh Hackers' List

Date: Sat, 9 Oct 2010 14:54:17 +0200
From: Jilles Tjoelker <jilles@stack.nl>
To: Peter Stephenson <pws@csr.com>
Subject: zsh POSIX_TRAPS option


Hi,

Regarding the POSIX_TRAPS option, I can't help but wonder if making a
difference between f() { ... } (POSIX functions) and function f { ... }
(ksh functions) instead of adding more and more options would make
things less complex. In ksh93, ksh functions have their own traps, while
POSIX functions share the invoker's traps.

ksh93 does not support function f() { ... } (a stupid bashism), but mksh
does, treating it as a POSIX function.

-- 
Jilles Tjoelker


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[relevance 5%]

* Re: Fw: zsh POSIX_TRAPS option
  2010-10-11  8:42  5% Fw: zsh POSIX_TRAPS option Peter Stephenson
@ 2010-10-11 15:16  4% ` Bart Schaefer
  2010-10-15 13:47  0%   ` Jilles Tjoelker
  0 siblings, 1 reply; 200+ results
From: Bart Schaefer @ 2010-10-11 15:16 UTC (permalink / raw)
  To: Zsh Hackers' List; +Cc: Jilles Tjoelker

On Oct 11,  9:42am, Jilles Tjoelker <jilles@stack.nl> was quoted
} by Peter W. Stephenson:
} 
} Regarding the POSIX_TRAPS option, I can't help but wonder if making a
} difference between f() { ... } (POSIX functions) and function f { ... }
} (ksh functions) instead of adding more and more options would make
} things less complex.

That could have been a good idea when the "function" keyword was first
introduced, but we now have years of treating them equivalently to
think about.  (Also, whether functions have their own traps is based
on the LOCAL_TRAPS option, not the POSIX_TRAPS option, except for the
special case of the EXIT trap.)

In particular there's the problem of autoloaded functions.  We already
have several potentially confusing tricks to designate KSH_AUTOLOAD and
to define the of function correctly in the event the file is loaded
under the wrong regimen.  Having an additional behavior that changes
depending on these circumstances would seem to me more complex rather
than less, particularly if there's no way to test for that behavior.

} In ksh93, ksh functions have their own traps, while POSIX functions
} share the invoker's traps.

This is suddenly seeming familiar.  There may have been discussion of
changing zsh semantics of "function f" vs. "f()" at some earlier time,
but I have no idea how to do an efficient list archive search for it.

I have only a year-old version of mksh to conveniently play with.  What
does "have their own traps" imply during function execution about traps
that were set before the function was entered, when the function does
NOT redefine them?


^ permalink raw reply	[relevance 4%]

* Re: Fw: zsh POSIX_TRAPS option
  2010-10-11 15:16  4% ` Bart Schaefer
@ 2010-10-15 13:47  0%   ` Jilles Tjoelker
  0 siblings, 0 replies; 200+ results
From: Jilles Tjoelker @ 2010-10-15 13:47 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Hackers' List

On Mon, Oct 11, 2010 at 08:16:52AM -0700, Bart Schaefer wrote:
> On Oct 11,  9:42am, Jilles Tjoelker <jilles@stack.nl> was quoted
> } by Peter W. Stephenson:

> } Regarding the POSIX_TRAPS option, I can't help but wonder if making a
> } difference between f() { ... } (POSIX functions) and function f { ... }
> } (ksh functions) instead of adding more and more options would make
> } things less complex.

> That could have been a good idea when the "function" keyword was first
> introduced, but we now have years of treating them equivalently to
> think about.  (Also, whether functions have their own traps is based
> on the LOCAL_TRAPS option, not the POSIX_TRAPS option, except for the
> special case of the EXIT trap.)

> In particular there's the problem of autoloaded functions.  We already
> have several potentially confusing tricks to designate KSH_AUTOLOAD and
> to define the of function correctly in the event the file is loaded
> under the wrong regimen.  Having an additional behavior that changes
> depending on these circumstances would seem to me more complex rather
> than less, particularly if there's no way to test for that behavior.

Yes :(

> } In ksh93, ksh functions have their own traps, while POSIX functions
> } share the invoker's traps.

> This is suddenly seeming familiar.  There may have been discussion of
> changing zsh semantics of "function f" vs. "f()" at some earlier time,
> but I have no idea how to do an efficient list archive search for it.

> I have only a year-old version of mksh to conveniently play with.  What
> does "have their own traps" imply during function execution about traps
> that were set before the function was entered, when the function does
> NOT redefine them?

You need ksh93 for this, as mksh does not (yet) implement this feature.
The basic idea is that the function is treated much like a separate
process: if the signal occurs and there is no trap handler in the
function environment, the function is aborted and the parent's trap is
taken.

There is additional magic if the exit and return special builtins are
used without parameter in a a function environment's trap handler:
the outer environment's trap handler is executed as well; in the case of
return, execution then continues (unless a trap handler exited).

Although more complicated to implement, this seems to make more sense
than simply saving and restoring the traps, especially with ksh93's
static scoping which shields function g from function f's variables if f
calls g.

-- 
Jilles Tjoelker


^ permalink raw reply	[relevance 0%]

* static vs. dynamic scoping
@ 2010-11-09 22:08  4% Eric Blake
  2010-11-10 11:10  5% ` Peter Stephenson
                   ` (2 more replies)
  0 siblings, 3 replies; 200+ results
From: Eric Blake @ 2010-11-09 22:08 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 2383 bytes --]

On the Austin Group mailing list, David Korn (of ksh93 fame)
complained[1] that bash's 'local' uses dynamic scoping, but that ksh's
'typeset' uses static scoping, and argued that static scoping is saner
since it matches the behavior of declarative languages like C and Java
(dynamic scoping mainly matters in functional languages like lisp):

[1]
https://www.opengroup.org/sophocles/show_mail.tpl?CALLER=show_archive.tpl&source=L&listname=austin-group-l&id=14951

I'm trying to standardize the notion of local variables for the next
revision of POSIX, but before I can do so, I need some feedback on two
general aspects:

1. Implementation aspect:
  How hard would it be to add static scoping to zsh?
  Is it something that can be added in addition to dynamic scoping, via
the use of an option to select the non-default mode (for example, 'local
-d' to force dynamic, 'local -s' to force static, and 'local' to go with
default scoping)?
  If both scoping forms are supported, is it worth making the default
scoping dependent on posix compliance (for example, 'local' means
dynamic scoping for 'emulate zsh' but static scoping for 'emulate sh'),
or should it be the same default for both modes?

2. User aspect:
  Is anyone aware of a script that intentionally uses the full power of
dynamic scoping available through 'local' which would break if scoping
switched to static?

Here's a sample shell script that illustrates the difference between the
two scoping methods.

$ ksh -c 'function f1 { typeset a=local; f2; echo $a; };
  function f2 { echo $a; a=changed; };
  a=global; f1; echo $a'
global
local
changed

$ zsh -c 'function f1 { typeset a=local; f2; echo $a; };
  function f2 { echo $a; a=changed; };
  a=global; f1; echo $a'
local
changed
global

In static scoping, function f2 does not shadow a declaration of a, so
references to $a within f2 refer to the global variable.  The local
variable a of f1 can only be accessed within f1; the behavior of f2 is
the same no matter how it was reached.

In dynamic scoping, function f2 looks up its call stack for the closest
enclosing scope of a variable named a, and finds the local one declared
in f1.  Therefore, the behavior of f2 depends on how f2 is called.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[relevance 4%]

* Re: static vs. dynamic scoping
  2010-11-09 22:08  4% static vs. dynamic scoping Eric Blake
@ 2010-11-10 11:10  5% ` Peter Stephenson
  2010-11-10 16:50  3% ` Bart Schaefer
    2 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2010-11-10 11:10 UTC (permalink / raw)
  To: zsh-workers

I might as well copy what I sent to the Austin group list this
morning for the majority not following that...

The "other" matters referred to are, to summarise very briefly,
basically whether

  foo="a b"
  export x=$foo

causes x to be set to "a b".  Currently POSIX implies it doesn't.


From: Peter Stephenson <pws@csr.com>
To: austin-group-l@opengroup.org
Subject: Re: Word splitting in 'export' arguments and adding local
Date: Wed, 10 Nov 2010 10:13:20 +0000

On Tue, 09 Nov 2010 22:34:22 -0500
Chet Ramey <chet.ramey@case.edu> wrote:
> Bash uses dynamic scoping and, as I have existing users and scripts
> that take advantage of it, I have no intention of changing that.  I
> know zsh uses dynamic scoping and there are scripts that make
> extensive use of it.  

That's correct about zsh: the completion functions supplied with the
shell rely (very) heavily on dynamic scoping and we certainly wouldn't
be changing that.  I can't see any likelihood of writing a completely
different additional implementation of local variables with static
scoping for POSIX mode.

It might be possible as an option to hide and uncover variables when
entering nested functions to simulate static scoping without a complete
rewrite, but I really haven't thought it through and it's not likely to
be a high priority.  It might also be worth reminding people that POSIX
support was rather an afterthought for zsh but we try to keep that mode
working where possible.

I don't think any of the other matters being discusses here are a big
issue for zsh in POSIX mode, however.  If you happen to be investigating
this in zsh, the following options are relevant:

SH_WORD_SPLIT
   turn on splitting of substitutions as done by default in other shells

KSH_TYPESET
   turn off argument splitting on assignments for typeset, local, etc.
   if SH_WORD_SPLIT is on.  Note this is not turned on automatically
   in POSIX mode (for reasons anyone following this thread will realise).

MAGIC_EQUAL_SUBST
   ~-expansion (and zsh-specific =-expansion, if applicable) are active
   after all "=", and also after following :, regardless of the command.
   The example in the manual is
     echo foo=~/bar:~/rod
   expands both ~'s.  The effect of this option has expanded somewhat
   during the life of zsh.  (I'm not suggesting this would ever be
   POSIX-compatible.)

pws


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[relevance 5%]

* Re: static vs. dynamic scoping
  2010-11-09 22:08  4% static vs. dynamic scoping Eric Blake
  2010-11-10 11:10  5% ` Peter Stephenson
@ 2010-11-10 16:50  3% ` Bart Schaefer
  2010-11-10 17:28  4%   ` Eric Blake
    2 siblings, 1 reply; 200+ results
From: Bart Schaefer @ 2010-11-10 16:50 UTC (permalink / raw)
  To: Eric Blake, zsh-workers

On Nov 9,  3:08pm, Eric Blake wrote:
}
} 1. Implementation aspect:
}   How hard would it be to add static scoping to zsh?

Just to elaborate on this, as I've been fooling with parameter scopes a
bit lately (http://www.zsh.org/mla/workers//2010/msg00719.html) ...

Zsh currently maintains scopes as [what amounts to] a parallel stack
alongside the function call stack, with scope depth indexed by the
call stack depth.  A variable expansions finds its object at the
uppermost frame of the scope stack in which that variable's name has
been "mentioned" with either typeset/local/declare or undef; if it is
not found at all, assignment creates it in the global frame.  Note,
though, that the global frame is simply the bottom of the stack, not
handled separately except for some special cases for stack depth 0.

Therefore it's at least moderately difficult to add static scoping.

}   Is it something that can be added in addition to dynamic scoping, via
} the use of an option to select the non-default mode (for example, 'local
} -d' to force dynamic, 'local -s' to force static, and 'local' to go with
} default scoping)?

It might be possible to flag a variable in a given frame as static and
thereby cause it to be skipped when the current call depth does not
match the stack depth where the variable was "mentioned", but due to
the details of the implementation [*] I can't think of any reasonable
way to mark entire frames static or dynamic as implied by having two
different function styles.  Maybe that doesn't matter as long as all
undeclared variables in either kind of scope are global, because then
the state of the frame matters only when "local" is used in that frame.

[*] Cf. "what amounts to" -- in reality, every variable has its own
independent stack which comes into being only when the variable is
"mentioned", so that it's not necessary to walk the stack to find
the uppermost frame for a given variable.

}   If both scoping forms are supported, is it worth making the default
} scoping dependent on posix compliance (for example, 'local' means
} dynamic scoping for 'emulate zsh' but static scoping for 'emulate sh'),
} or should it be the same default for both modes?

As it'd probably be controlled by an option, this probably doesn't
change the difficulty either way.


^ permalink raw reply	[relevance 3%]

* Re: static vs. dynamic scoping
  2010-11-10 16:50  3% ` Bart Schaefer
@ 2010-11-10 17:28  4%   ` Eric Blake
  0 siblings, 0 replies; 200+ results
From: Eric Blake @ 2010-11-10 17:28 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers, austin-group-l

[-- Attachment #1: Type: text/plain, Size: 5025 bytes --]

On 11/10/2010 09:50 AM, Bart Schaefer wrote:
> On Nov 9,  3:08pm, Eric Blake wrote:
> }
> } 1. Implementation aspect:
> }   How hard would it be to add static scoping to zsh?
> 
> Just to elaborate on this, as I've been fooling with parameter scopes a
> bit lately (http://www.zsh.org/mla/workers//2010/msg00719.html) ...
> 
> Zsh currently maintains scopes as [what amounts to] a parallel stack
> alongside the function call stack, with scope depth indexed by the
> call stack depth.  A variable expansions finds its object at the
> uppermost frame of the scope stack in which that variable's name has
> been "mentioned" with either typeset/local/declare or undef; if it is
> not found at all, assignment creates it in the global frame.  Note,
> though, that the global frame is simply the bottom of the stack, not
> handled separately except for some special cases for stack depth 0.
> 
> Therefore it's at least moderately difficult to add static scoping.
> 
> }   Is it something that can be added in addition to dynamic scoping, via
> } the use of an option to select the non-default mode (for example, 'local
> } -d' to force dynamic, 'local -s' to force static, and 'local' to go with
> } default scoping)?
> 
> It might be possible to flag a variable in a given frame as static and
> thereby cause it to be skipped when the current call depth does not
> match the stack depth where the variable was "mentioned", but due to
> the details of the implementation [*] I can't think of any reasonable
> way to mark entire frames static or dynamic as implied by having two
> different function styles.  Maybe that doesn't matter as long as all
> undeclared variables in either kind of scope are global, because then
> the state of the frame matters only when "local" is used in that frame.
>
> [*] Cf. "what amounts to" -- in reality, every variable has its own
> independent stack which comes into being only when the variable is
> "mentioned", so that it's not necessary to walk the stack to find
> the uppermost frame for a given variable.

You are correct that ksh93 currently has two flavors of functions:

POSIX functions 'f () {...}', currently no scoping support
ksh functions 'function f {...}', supports static scoping

But I see no need to standardize on this.  My current thoughts for POSIX
standardization are:

keep a single function syntax (ksh can continue to use 'function' as a
reserved word, and with alternate function syntax, but that would be an
extension and not mandatory; bash can continue to use function as an
alternate spelling for POSIX functions without the split in
functionality used by ksh)

provide the 'typeset' special built-in, which is required to obey XBD
12.2 (that is, it must honor --), so as to allow implementations to
support extensions such as 'typeset -a' for declaring array variables

require that 'typedef' used without options and within a function body
provide a statically scoped local variable.  Possible require a few
other commonly implemented 'typedef -X' options, such as 'typedef -p'
for printing the current set of locally scoped variables (much like
'export -p).

only require static scoping (for ksh93), but additionally allow dynamic
scoping as an extension (this would be the course used by bash and zsh,
to preserve their current user base of tab-completion that expects
dynamic scoping)

continue to allow the ksh extension of reference variables (since ksh
uses this in in lieu of dynamic scoping for exposing local variables to
secondary functions), although I don't see this implemented in bash or zsh

For implementations that want to provide static and dynamic scoping
simultaneously (bash, zsh), I think the following implementation would
do just fine:
 + Create two variants of 'local': 'local -d' for dynamic scoping, and
'local -s' for static scoping (which version was used determines whether
a variable is marked as static on the variable stack).  For backwards
compatibility, 'local' becomes 'local -d'.
 + Make 'typedef' become a synonym for 'local -s' (or keep 'typedef' as
a synonym for 'local', and add a a shell option that determines whether
'local' defaults to 'local -d' or 'local -s', where that option is
auto-set according to posix mode)
 + Within a function, when referencing a variable:
   + if the variable was declared within that function, use it (doesn't
matter whether it was declared with 'local -s' or 'local -d')
   + if the variable was not declared within that function, then travel
up the variable declaration stack to the first instance of the variable
that was not marked static (if the script only uses static scoping, then
this requires traversing the entire stack of variables, but will settle
on the global scope; if the script only uses dynamic scoping, then this
will find the very first variable on the stack)

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[relevance 4%]

* Re: static vs. dynamic scoping
  @ 2010-11-10 17:30  3%   ` Eric Blake
  0 siblings, 0 replies; 200+ results
From: Eric Blake @ 2010-11-10 17:30 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1291 bytes --]

On 11/10/2010 10:22 AM, Bart Schaefer wrote:
> One additional thought on this ...
> 
> Zsh does have the "-g" option of "typeset" to allow one declare or
> to change the properties of a variable that is not in the scope of
> the current function.  However, "-g" doesn't really mean "global";
> it means only "the nearest dynamic scope where this variable is
> already declared" which is the global scope if the parameter has
> never been declared, but might even be the current scope if there
> has previously been a "local" delcaration of the variable.
> 
> Does ksh93 have any mechanism for explicitly declaring a variable to
> be global from inside a function scope?

I'm not that familiar with ksh93; you'd have to ask David Korn for
precise details.  But my understanding is that with static scoping,
every variable reference which was not explicitly declared local is
inherently global, because there are no other scopes to worry about.

That is (assuming ksh were to support local scoping with posix syntax
functions):

f () {
  a=1  # modify the global variable a
  typeset a;
  a=2  # modify the function-local a
}
a=0; f; echo $a # outputs 1

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[relevance 3%]

* Re: PATCH: bash-style substrings & subarrays
  @ 2010-11-18 12:44  3% ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2010-11-18 12:44 UTC (permalink / raw)
  To: Zsh hackers list

On Wed, 17 Nov 2010 16:54:17 +0000
Peter Stephenson <pws@csr.com> wrote:
> One thing I have not yet tried to do is the fact that the offset is
> offset by 1 when the variable is * or @ in bash (i.e. corresponding to
> having KSH_ARRAYS set, except it doesn't this time), i.e. ${*:1:1}
> gives you $1 not $2.

I refer honourable members to the answer I gave on a previous occasion.

> Yech.

Index: Doc/Zsh/expn.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/expn.yo,v
retrieving revision 1.122
diff -p -u -r1.122 expn.yo
--- Doc/Zsh/expn.yo	18 Nov 2010 10:07:56 -0000	1.122
+++ Doc/Zsh/expn.yo	18 Nov 2010 12:38:42 -0000
@@ -623,6 +623,16 @@ tt(${)var(name)tt(:-)var(word)tt(}) form
 may be inserted before the tt(-).  Furthermore, neither var(offset) nor
 var(length) may begin with an alphabetic character or tt(&) as these are
 used to indicate history-style modifiers.
+
+For further compatibility with other shells there is a special case
+when the tt(KSH_ARRAYS) option is active, as in emulation of
+Bourne-style shells.  In this case array subscript 0 usually refers to the
+first element of the array.  However, if the substitution refers to the
+positional parameter array, e.g. tt($@) or tt($*), then offset 0
+instead refers to tt($0), offset 1 refers to tt($1), and so on.  In
+other words, the positional parameter array is effectively extended by
+prepending tt($0).  Hence tt(${*:0:1}) substitutes tt($0) and
+tt(${*:1:1}) substitutes tt($1).
 )
 xitem(tt(${)var(name)tt(/)var(pattern)tt(/)var(repl)tt(}))
 item(tt(${)var(name)tt(//)var(pattern)tt(/)var(repl)tt(}))(
Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.109
diff -p -u -r1.109 subst.c
--- Src/subst.c	18 Nov 2010 10:07:56 -0000	1.109
+++ Src/subst.c	18 Nov 2010 12:38:42 -0000
@@ -1636,6 +1636,12 @@ paramsubst(LinkList l, LinkNode n, char 
      * and the argument passing to fetchvalue has another kludge.
      */
     int subexp;
+    /*
+     * If we're referring to the positional parameters, then
+     * e.g ${*:1:1} refers to $1 even if KSH_ARRAYS is in effect.
+     * This is for compatibility.
+     */
+    int horrible_offset_hack = 0;
 
     *s++ = '\0';
     /*
@@ -2281,6 +2287,12 @@ paramsubst(LinkList l, LinkNode n, char 
 		val = getstrvalue(v);
 	    }
 	}
+	/* See if this is a reference to the positional parameters. */
+	if (v && v->pm && v->pm->gsu.a == &vararray_gsu &&
+	    (char ***)v->pm->u.data == &pparams)
+	    horrible_offset_hack = 1;
+	else
+	    horrible_offset_hack = 0;
 	/*
 	 * Finished with the original parameter and its indices;
 	 * carry on looping to see if we need to do more indexing.
@@ -2732,6 +2744,7 @@ paramsubst(LinkList l, LinkNode n, char 
 	    if (check_offset) {
 		zlong offset = mathevali(check_offset);
 		zlong length = (zlong)-1;
+		int offset_hack_argzero = 0;
 		if (errflag)
 		    return NULL;
 		if ((*check_offset2 && *check_offset2 != ':')) {
@@ -2753,8 +2766,21 @@ paramsubst(LinkList l, LinkNode n, char 
 			return NULL;
 		    }
 		}
-		if (!isset(KSHARRAYS) && offset > 0)
-		    offset--;
+		if (!isset(KSHARRAYS) || 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 array which includes offset 0, we use
+		     * $0.
+		     */
+		    if (isset(KSHARRAYS) && horrible_offset_hack &&
+			offset == 0 && isarr) {
+			offset_hack_argzero = 1;
+		    } else if (offset > 0) {
+			offset--;
+		    }
+		}
 		if (isarr) {
 		    int alen = arrlen(aval), count;
 		    char **srcptr, **dstptr, **newarr;
@@ -2764,6 +2790,8 @@ paramsubst(LinkList l, LinkNode n, char 
 			if (offset < 0)
 			    offset = 0;
 		    }
+		    if (offset_hack_argzero)
+			alen++;
 		    if (length < 0)
 		      length = alen;
 		    if (offset > alen)
@@ -2774,6 +2802,10 @@ paramsubst(LinkList l, LinkNode n, char 
 		    srcptr = aval + offset;
 		    newarr = dstptr = (char **)
 			zhalloc((length+1)*sizeof(char *));
+		    if (count && offset_hack_argzero) {
+			*dstptr++ = dupstring(argzero);
+			count--;
+		    }
 		    while (count--)
 			*dstptr++ = dupstring(*srcptr++);
 		    *dstptr = (char *)NULL;
Index: Test/D04parameter.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D04parameter.ztst,v
retrieving revision 1.45
diff -p -u -r1.45 D04parameter.ztst
--- Test/D04parameter.ztst	18 Nov 2010 10:07:56 -0000	1.45
+++ Test/D04parameter.ztst	18 Nov 2010 12:38:42 -0000
@@ -1302,3 +1302,32 @@
 >6
 >9
 >1 2 3 4 5 6 7 8 9
+
+   testfn() {
+     emulate -L sh
+     set -A foo 1 2 3
+     set -- 1 2 3
+     str=abc
+     echo ${foo[*]:0:1}
+     echo ${foo[*]:1:1}
+     echo ${foo[*]: -1:1}
+     :
+     echo ${*:0:1}
+     echo ${*:1:1}
+     echo ${*: -1:1}
+     :
+     echo ${str:0:1}
+     echo ${str:1:1}
+     echo ${str: -1:1}
+   }
+   testfn
+0:Bash-style subscripts, Bourne-style indexing
+>1
+>2
+>3
+>testfn
+>1
+>3
+>a
+>b
+>c

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[relevance 3%]

* PATCH: POSIX_STRINGS option
@ 2010-11-19 18:16  7% Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2010-11-19 18:16 UTC (permalink / raw)
  To: Zsh hackers list

There's been some POSIX-directed discussion in the Austin group that a
NULL character in a $'...' style string should terminate the string at
that point.  This isn't in the standard yet, but bash already does it
this way, so I might as well add this for compatibility now.
(Apparently ksh currently truncates the entire string, not just the
quoted string, at that point, but is likely to change.)

I've assumed this will be a POSIX requirement and named it so that
anything similar that comes up can be associated with this option.

I can't think of a good reason for setting the option deliberately, it
just makes \0 within $'...' essentially useless.

Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.96
diff -p -u -r1.96 options.yo
--- Doc/Zsh/options.yo	2 Oct 2010 21:03:04 -0000	1.96
+++ Doc/Zsh/options.yo	19 Nov 2010 18:01:08 -0000
@@ -1891,6 +1891,33 @@ If multibyte character support is not co
 ignored; all octets with the top bit set may be used in identifiers.
 This is non-standard but is the traditional zsh behaviour.
 )
+pindex(POSIX_STRINGS)
+pindex(NO_POSIX_STRINGS)
+pindex(POSIXSTRINGS)
+pindex(NOPOSIXSTRINGS)
+cindex(discarding embedded nulls in $'...')
+cindex(embedded nulls, in $'...')
+cindex(nulls, embedded in $'...')
+item(tt(POSIX_STRINGS) <K> <S>)(
+This option affects processing of quoted strings.  Currently it only
+affects the behaviour of null characters, i.e. character 0 in the
+portable character set corresponding to US ASCII.
+
+When this option is not set, null characters embedded within strings
+of the form tt($')var(...)tt(') are treated as ordinary characters. The
+entire string is maintained within the shell and output to files where
+necessary, although owing to restrictions of the library interface
+the string is truncated at the null character in file names, environment
+variables, or in arguments to external programs.
+
+When this option is set, the tt($')var(...)tt(') expression is truncated at
+the null character.  Note that remaining parts of the same string
+beyond the termination of the quotes are not trunctated.
+
+For example, the command line argument tt(a$'b\0c'd) is treated with
+the option off as the characters tt(a), tt(b), null, tt(c), tt(d),
+and with the option on as the characters tt(a), tt(b), tt(d).
+)
 pindex(POSIX_TRAPS)
 pindex(NO_POSIX_TRAPS)
 pindex(POSIXTRAPS)
Index: Src/options.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/options.c,v
retrieving revision 1.56
diff -p -u -r1.56 options.c
--- Src/options.c	2 Oct 2010 21:03:04 -0000	1.56
+++ Src/options.c	19 Nov 2010 18:01:08 -0000
@@ -205,7 +205,8 @@ static struct optname optns[] = {
 {{NULL, "posixcd",            OPT_EMULATE|OPT_BOURNE},	 POSIXCD},
 {{NULL, "posixidentifiers",   OPT_EMULATE|OPT_BOURNE},	 POSIXIDENTIFIERS},
 {{NULL, "posixjobs",          OPT_EMULATE|OPT_BOURNE},	 POSIXJOBS},
-{{NULL, "posixtraps",          OPT_EMULATE|OPT_BOURNE},	 POSIXTRAPS},
+{{NULL, "posixstrings",       OPT_EMULATE|OPT_BOURNE},   POSIXSTRINGS},
+{{NULL, "posixtraps",         OPT_EMULATE|OPT_BOURNE},	 POSIXTRAPS},
 {{NULL, "printeightbit",      0},                        PRINTEIGHTBIT},
 {{NULL, "printexitvalue",     0},			 PRINTEXITVALUE},
 {{NULL, "privileged",	      OPT_SPECIAL},		 PRIVILEGED},
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.246
diff -p -u -r1.246 utils.c
--- Src/utils.c	15 Oct 2010 18:56:17 -0000	1.246
+++ Src/utils.c	19 Nov 2010 18:01:09 -0000
@@ -5200,7 +5200,7 @@ getkeystring(char *s, int *len, int how,
     char *buf, tmp[1];
     char *t, *tdest = NULL, *u = NULL, *sstart = s, *tbuf = NULL;
     char svchar = '\0';
-    int meta = 0, control = 0;
+    int meta = 0, control = 0, ignoring = 0;
     int i;
 #if defined(HAVE_WCHAR_H) && defined(HAVE_WCTOMB) && defined(__STDC_ISO_10646__)
     wint_t wval;
@@ -5623,11 +5623,22 @@ getkeystring(char *s, int *len, int how,
 	if (how & GETKEY_DOLLAR_QUOTE) {
 	    char *t2;
 	    for (t2 = tbuf; t2 < t; t2++) {
+		/*
+		 * In POSIX mode, an embedded NULL is discarded and
+		 * terminates processing.  It just does, that's why.
+		 */
+		if (isset(POSIXSTRINGS)) {
+		    if (*t2 == '\0')
+			ignoring = 1;
+		    if (ignoring)
+			break;
+		}
 		if (imeta(*t2)) {
 		    *tdest++ = Meta;
 		    *tdest++ = *t2 ^ 32;
-		} else
+		} else {
 		    *tdest++ = *t2;
+		}
 	    }
 	    /*
 	     * Reset use of temporary buffer.
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.169
diff -p -u -r1.169 zsh.h
--- Src/zsh.h	2 Oct 2010 21:03:04 -0000	1.169
+++ Src/zsh.h	19 Nov 2010 18:01:09 -0000
@@ -1992,6 +1992,7 @@ enum {
     POSIXCD,
     POSIXIDENTIFIERS,
     POSIXJOBS,
+    POSIXSTRINGS,
     POSIXTRAPS,
     PRINTEIGHTBIT,
     PRINTEXITVALUE,
Index: Test/A03quoting.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A03quoting.ztst,v
retrieving revision 1.4
diff -p -u -r1.4 A03quoting.ztst
--- Test/A03quoting.ztst	6 Nov 2007 20:45:09 -0000	1.4
+++ Test/A03quoting.ztst	19 Nov 2010 18:01:09 -0000
@@ -42,6 +42,7 @@
   unsetopt rcquotes
 0:Yes RC_QUOTES with single quotes
 >'
+# ' Deconfuse Emacs quoting rules
 
   print '<\u0041>'
   printf '%s\n' $'<\u0042>'
@@ -52,3 +53,24 @@
 ><B>
 ><C>
 ><D>
+
+  null1="$(print -r a$'b\0c'd)"
+  null2="$(setopt posixstrings; print -r a$'b\0c'd)"
+  for string in $null1 $null2; do
+    print ":"
+    for (( i = 1; i <= $#string; i++ )); do
+      char=$string[$i]
+      print $(( [#16] #char ))
+    done
+  done
+0:Embedded null characters in $'...' strings.
+>:
+>16#61
+>16#62
+>16#0
+>16#63
+>16#64
+>:
+>16#61
+>16#62
+>16#64

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[relevance 7%]

* Re: PATCH: bash-style substrings & subarrays
  @ 2010-11-23 11:14  3%   ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2010-11-23 11:14 UTC (permalink / raw)
  To: Zsh hackers list

On Sun, 21 Nov 2010 17:02:38 +0000
Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> Should ${foo:1} always start 1 character/element beyond the
> first one, regardless which subscripting rules are in use?  I'm now
> inclining in that direction.

Nobody commented but this is the change with some more careful
documentation.

Index: Doc/Zsh/expn.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/expn.yo,v
retrieving revision 1.123
diff -p -u -r1.123 expn.yo
--- Doc/Zsh/expn.yo	18 Nov 2010 13:57:19 -0000	1.123
+++ Doc/Zsh/expn.yo	23 Nov 2010 11:09:33 -0000
@@ -588,23 +588,29 @@ remove the non-matched elements).
 xitem(tt(${)var(name)tt(:)var(offset)tt(}))
 item(tt(${)var(name)tt(:)var(offset)tt(:)var(length)tt(}))(
 This syntax gives effects similar to parameter subscripting
-in the form tt($)var(name)tt({)var(offset)tt(,)var(end)tt(}) but in
-a form compatible with other shells.
+in the form tt($)var(name)tt({)var(start)tt(,)var(end)tt(}), but is
+compatible with other shells; note that both var(offset) and var(length)
+are interpreted differently from the components of a subscript.
+
+If var(offset) is non-negative, then if the variable var(name) is a
+scalar substitute the contents starting var(offset) characters from the
+first character of the string, and if var(name) is an array substitute
+elements starting var(offset) elements from the first element.  If
+var(length) is given, substitute that many characters or elements,
+otherwise the entire rest of the scalar or array.
+
+A positive var(offset) is always treated as the offset of a character or
+element in var(name) from the first character or element of the array
+(this is different from native zsh subscript notation).  Hence 0
+refers to the first character or element regardless of the setting of
+the option tt(KSH_ARRAYS).
 
-If the variable var(name) is a scalar, substitute the contents
-starting from offset var(offset); if var(name) is an array,
-substitute elements from element var(offset).  If var(length) is
-given, substitute that many characters or elements, otherwise the
-entire rest of the scalar or array.
-
-var(offset) is treated similarly to a parameter subscript:
-the offset of the first character or element in var(name)
-is 0 if the option tt(KSH_ARRAYS) is set, else 1; a negative
-subscript counts backwards so that -1 corresponds to the last
-character or element.
+A negative offset counts backwards from the end of the scalar or array,
+so that -1 corresponds to the last character or element, and so on.
 
 var(length) is always treated directly as a length and hence may not be
-negative.
+negative.  The option tt(MULTIBYTE) is obeyed, i.e. the offset and length
+count multibyte characters where appropriate.
 
 var(offset) and var(length) undergo the same set of shell substitutions
 as for scalar assignment; in addition, they are then subject to arithmetic
@@ -615,19 +621,29 @@ print ${foo: 1 + 2}
 print ${foo:$(( 1 + 2))}
 print ${foo:$(echo 1 + 2)})
 
-all have the same effect.
+all have the same effect, extracting the string starting at the fourth
+character of tt($foo) if the substution would otherwise return a scalar,
+or the array starting at the fourth element if tt($foo) would return an
+array.  Note that with the option tt(KSH_ARRAYS) tt($foo) always returns
+a scalar (regardless of the use of the offset syntax) and a form
+such as tt($foo[*]:3) is required to extract elements of an array named
+tt(foo).
 
-Note that if var(offset) is negative, the tt(-) may not appear immediately
+If var(offset) is negative, the tt(-) may not appear immediately
 after the tt(:) as this indicates the
-tt(${)var(name)tt(:-)var(word)tt(}) form of substitution; a space
+tt(${)var(name)tt(:-)var(word)tt(}) form of substitution.  Instead, a space
 may be inserted before the tt(-).  Furthermore, neither var(offset) nor
 var(length) may begin with an alphabetic character or tt(&) as these are
-used to indicate history-style modifiers.
+used to indicate history-style modifiers.  To substitute a value from a
+variable, the recommended approach is to proceed it with a tt($) as this
+signifies the intention (parameter substitution can easily be rendered
+unreadable); however, as arithmetic substitution is performed, the
+expression tt(${var: offs}) does work, retrieving the offset from
+tt($offs).
 
 For further compatibility with other shells there is a special case
-when the tt(KSH_ARRAYS) option is active, as in emulation of
-Bourne-style shells.  In this case array subscript 0 usually refers to the
-first element of the array.  However, if the substitution refers to the
+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. tt($@) or tt($*), then offset 0
 instead refers to tt($0), offset 1 refers to tt($1), and so on.  In
 other words, the positional parameter array is effectively extended by
Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.111
diff -p -u -r1.111 subst.c
--- Src/subst.c	20 Nov 2010 23:46:26 -0000	1.111
+++ Src/subst.c	23 Nov 2010 11:09:34 -0000
@@ -1640,7 +1640,7 @@ paramsubst(LinkList l, LinkNode n, char 
     int subexp;
     /*
      * If we're referring to the positional parameters, then
-     * e.g ${*:1:1} refers to $1 even if KSH_ARRAYS is in effect.
+     * e.g ${*:1:1} refers to $1.
      * This is for compatibility.
      */
     int horrible_offset_hack = 0;
@@ -2768,16 +2768,15 @@ paramsubst(LinkList l, LinkNode n, char 
 			return NULL;
 		    }
 		}
-		if (!isset(KSHARRAYS) || horrible_offset_hack) {
+		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 array which includes offset 0, we use
-		     * $0.
+		     * style positional parameter array which includes
+		     * offset 0, we use $0.
 		     */
-		    if (isset(KSHARRAYS) && horrible_offset_hack &&
-			offset == 0 && isarr) {
+		    if (offset == 0 && isarr) {
 			offset_hack_argzero = 1;
 		    } else if (offset > 0) {
 			offset--;
Index: Test/D04parameter.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D04parameter.ztst,v
retrieving revision 1.46
diff -p -u -r1.46 D04parameter.ztst
--- Test/D04parameter.ztst	18 Nov 2010 13:57:19 -0000	1.46
+++ Test/D04parameter.ztst	23 Nov 2010 11:09:34 -0000
@@ -1268,15 +1268,15 @@
    print ${foo:$(echo 3 + 3):`echo 4 - 3`}
    print ${foo: -1}
    print ${foo: -10}
-0:Bash-style subscripts, scalar
->3456789
+0:Bash-style offsets, scalar
 >456789
 >56789
 >6789
->3
+>789
 >4
 >5
 >6
+>7
 >9
 >123456789
 
@@ -1291,15 +1291,15 @@
    print ${foo:$(echo 3 + 3):`echo 4 - 3`}
    print ${foo: -1}
    print ${foo: -10}
-0:Bash-style subscripts, array
->3 4 5 6 7 8 9
+0:Bash-style offsets, array
 >4 5 6 7 8 9
 >5 6 7 8 9
 >6 7 8 9
->3
+>7 8 9
 >4
 >5
 >6
+>7
 >9
 >1 2 3 4 5 6 7 8 9
 
@@ -1321,7 +1321,7 @@
      echo ${str: -1:1}
    }
    testfn
-0:Bash-style subscripts, Bourne-style indexing
+0:Bash-style offsets, Bourne-style indexing
 >1
 >2
 >3

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[relevance 3%]

* Re: `jobs' builtin does not work with pipe in scripts
  @ 2010-11-26  4:38  3%     ` ZyX
  0 siblings, 0 replies; 200+ results
From: ZyX @ 2010-11-26  4:38 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: Text/Plain, Size: 870 bytes --]

Reply to message «Re: `jobs' builtin does not work with pipe in scripts», 
sent 02:56:37 26 November 2010, Friday
by Marc Weber:

> I think you should provide more context. Its almost impossible to try to
> find a workaround. Eg you could use /bin/sh
> 
> /bin/sh -c 'sleep 1s & sleep 1s & jobs | cat ' | while read .. ?
> 
> Anyway you seem to have found something which works for you.
What more? `jobs -p | ...' is not working, I do not want to rewrite everything
in POSIX shell and I can't use interactive shell. `jobs -p | ...' is used in a
script that launches parallel processes and, when zsh catches CHLD, looks which
of them finished. You can see it here: http://vimpluginloader.hg.sourceforge.net/hgweb/vimpluginloader/dev-tools/file/tip/parjobs.zsh.
I do not like `ps --ppid $$' solution because it launches additional process,
but it works.

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[relevance 3%]

* [PATCH 1/2] Website Update: Add release notes for 4.3.11.
       [not found]     <21986.1292864174@csr.com>
@ 2010-12-20 20:16  3% ` Simon Ruderich
  0 siblings, 0 replies; 200+ results
From: Simon Ruderich @ 2010-12-20 20:16 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 8640 bytes --]

Hi all,

I just updated the website for 4.3.11. Please report any mistakes
you find.

Regards,
Simon
---
 News/index.html |    9 +++
 index.html      |    2 +-
 releases.html   |  168 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 178 insertions(+), 1 deletions(-)

diff --git a/News/index.html b/News/index.html
index d6331a2..94d366f 100644
--- a/News/index.html
+++ b/News/index.html
@@ -25,6 +25,15 @@
 <hr size=1 noshade>

 <dl>
+<dt><font size="+1"><font color="red">2010-12-20</font> : <b>Release 4.3.11</b></font></dt>
+<dd>Improved parameter expansion (${NAME:OFFSET} and ${NAME:OFFSET:LENGTH} for
+substrings and subarrays, (D) abbreviated directories, (Z) enhanced (z),
+{3..9..2} step in brace expansion, (P) adds word before each match),
+additional styles for zle_highlight ('suffix' for trailing /, 'special' for
+invalid multibyte chars), new option HIST_LEX_WORDS to perform "correct"
+splitting of history lines (not only on whitespace), multiple new POSIX_
+options to improve POSIX compliance and an improved SUN_KEYBOARD_HACK which is
+now called KEYBOARD_HACK.</dd>

 <dt><font size="+1"><font color="red">2009-06-01</font> : <b>Release 4.3.10</b></font></dt>
 <dd>Bug fixes and some minor improvements.</dd>
diff --git a/index.html b/index.html
index b04616c..2faf02d 100644
--- a/index.html
+++ b/index.html
@@ -22,7 +22,7 @@
   <td>
     <ul>
     <font size="+1" color="#600000"><b>Information</b></font>
-    <li><a href="News/">News</a> <font color=red><i>2009-06-01</i></font>
+    <li><a href="News/">News</a> <font color=red><i>2010-12-20</i></font>
     <li><a href="about.html">About these pages</a>
     <li><a href="releases.html">Release Notes</a>
     <li><a href="links.html">Useful links</a>
diff --git a/releases.html b/releases.html
index 8adbc94..1867fe7 100644
--- a/releases.html
+++ b/releases.html
@@ -27,6 +27,174 @@
 </table>
 <hr size=1 noshade>

+<h2>Changes between versions 4.3.10 and 4.3.11</h2>
+
+<p>
+Note also the list of incompatibilities in the README file.
+</p>
+
+<p>
+When the shell is invoked with the base name of a script, for example as
+`zsh scriptname', previous versions of zsh have used the name directly,
+whereas other shells use the value of $PATH to find the script.  The
+option PATH_SCRIPT has been added to provide the alternative behaviour.
+This is turned on where appropriate in compatibility modes.
+</p>
+
+<h3>Parameters, globbing, etc.</h3>
+
+<p>
+Parameter expansion has been enhanced to provide the ${NAME:OFFSET} and
+${NAME:OFFSET:LENGTH} syntax for substrings and subarrays present in
+several other shells.  OFFSET always uses zero-based indexing.  The only
+clash with existing zsh syntax occurs if OFFSET begins with an
+alphabetic character or `&amp;', which is not likely.
+</p>
+
+<p>
+The (D) flag in parameter expansion abbreviates directories in the
+substituted value.  The (q-) flag does minimal shell quotation of arguments
+for maximum human readability of the result.
+</p>
+
+<p>
+The (Z) flag in parameter expansion is an enhanced version of the (z)
+flag that takes an argument indicating how the string to be split
+is treated. (Z:c:) parses comments as strings; (Z:C:) parses comments
+and strips them; (Z:n:) treats newlines as ordinary whitespace: (z)
+has always treated unquoted newlines as shell delimiters and turned them
+into semicolons, though this was not previously documented.
+</p>
+
+<p>
+Numeric expansion with braces has been extended so that a step may be
+given, as in {3..9..2}.  The step may be negative as may the start and
+end of the range (this is also new).
+</p>
+
+<p>
+The glob qualifier P can be used to add a separate word before each
+match.  For example, *(P:-f:) produces the command line
+`-f file1 -f file2 ...'.
+</p>
+
+<p>
+Regular expression matches now use the same variables for storing matched
+components as shell pattern matching.  The function system now provides the
+function regexp-replace for replacing text using regular expressions.  The
+zle widget functions replace-string, replace-string-again, if defined with
+regex in the name (e.g. "zle -N replace-regexp replace-string"), perform
+regular expression matches.  In replacement text \& and \1 have the
+standard meaning.
+</p>
+
+<h3>Line editor and completion</h3>
+
+<p>
+The completion system now has a style path-completion.  Setting this to
+false inhibits completion of paths before the current path component,
+e.g. /u/b/z no longer completes to /usr/bin/zsh.  This is useful on systems
+where this form of completion is pathologically slow due to network
+performance.
+</p>
+
+<p>
+With the MULTIBYTE option, the line editor now highlights bytes in the
+input that are not part of a valid character in the current locale in hex
+as &lt;XX&gt; for hex digits X; highlighting is controlled by the "special"
+keyword in the zle_highlight array.  These can be distinguished from
+unprintable Unicode characters which also use "special" highlighting as the
+latter are always two or four bytes long, e.g. &lt;XXXX&gt;, &lt;XXXXXXXX&gt;.
+</p>
+
+<p>
+zle_highlight also controls highlighting of a removable completion
+suffix, e.g. the "/" automatically appended to directories.  This uses
+the keyword "suffix".
+</p>
+
+<p>
+The line editor now sets the variable ZLE_LINE_ABORTED if there is
+an error when editing the line.  The following code can be used
+to create a bindable editor widget to restore the aborted line:
+  recover-line() { LBUFFER=$ZLE_LINE_ABORTED RBUFFER=; }
+  zle -N recover-line
+and then either bind recover-line to a key sequence or use
+`M-x recover-line &lt;RET&gt;'.
+</p>
+
+<p>
+The parameter ZLE_STATE, available in user-defined line editor widgets,
+gives information on the state of the line editor.  Currently this is
+whether the line editor is in insert or overwrite mode.
+</p>
+
+<h3>Miscellaneous options</h3>
+
+<p>
+The new shell option HIST_LEX_WORDS causes history lines read in from
+a file to be split in the same way as normal shell lines, instead of
+simply on whitespace.  It's an option as although the result is more
+accurate it can take a long time when the history size is large.
+</p>
+
+<p>
+The shell option MONITOR can be set in non-interactive shells, and also in
+subshells (as created by surrounding commands with parentheses), turning on
+job control for that subshell.  The initial behaviour of a subshell is
+still to turn job control off, however if the new POSIX_JOBS option is set
+MONITOR remains active in subshells.
+</p>
+
+<p>
+The new shell option POSIX_CD, active in emulations of POSIX-based shells,
+makes the cd builtin POSIX-compatible.
+</p>
+
+<p>
+The POSIX_JOBS option already referred to has various other
+compatibility enchancements.
+</p>
+
+<p>
+The new shell option POSIX_STRINGS makes a null character in $'...'
+expansion terminate the string, as is already the case in bash.  This is
+not particularly useful behaviour but may become a POSIX requirement.
+</p>
+
+<p>
+The new shell option POSIX_TRAPS causes the EXIT trap to behave in the same
+way as in other shells, i.e. it is only run when the shell exits.
+</p>
+
+<p>
+The new shell option SOURCE_TRACE causes the shell to report files
+containing shell code that the shell executes directly, i.e. startup files
+or files run with the `source' or `.' builtins.
+</p>
+
+<p>
+The shell option SUN_KEYBOARD_HACK has been supplemented by a more general
+mechanism: the KEYBOARD_HACK variable defines the character to be ignored.
+</p>
+
+<h3>Add-on modules and function</h3>
+
+<p>
+The module zsh/system has a new "zsystem" builtin whose subcommands perform
+system level tasks.  Currently "zsystem flock" performs advisory file
+locking (for aficionados, this uses the fcntl() system call so works over
+the network on Linux).  This is a particularly convenient way of locking
+files for the length of a subshell.  "zsystem supports flock" provides a
+test for this feature.
+</p>
+
+<p>
+There is now a function system for recording and restoring recently
+entered directories in a persistent fashion, with support in completion
+and (if explicitly installed) dynamic directory expansion.  See the
+entry for cdr in the zshcontrib manual page.
+</p>

 <h2>Changes between versions 4.3.9 and 4.3.10</h2>

-- 
1.7.3.4

-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[relevance 3%]

* Re: 4.3.11 TRAPEXIT() on cygwin
  @ 2011-01-11  2:54  3%       ` Anthony Heading
  2011-01-11  3:25  0%         ` Mikael Magnusson
  0 siblings, 1 reply; 200+ results
From: Anthony Heading @ 2011-01-11  2:54 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: zsh-workers

On Tue, 11 Jan 2011 02:50 +0100, "Mikael Magnusson" <mikachu@gmail.com>
wrote:
> > echo $( trap 'echo exiting' EXIT)
> >
> > or similar substitutions.  That's quite clearly a subshell entering to
> > the same extent a ( ... ) is.
> 
> How is that different from what you wrote?

Well, the examples you quote are traps set within a subshell, which may
or may not propagate higher.

My problem is that the subshell is inheriting the parent trap action.

That seems obviously different, and POSIX seems pretty clear:

    When a subshell is entered, traps that are not being ignored shall
    be set to the default actions, except in the case of a command
    substitution containing only a single trap command, when the traps
    need not be altered.

Anthony


^ permalink raw reply	[relevance 3%]

* Re: 4.3.11 TRAPEXIT() on cygwin
  2011-01-11  2:54  3%       ` Anthony Heading
@ 2011-01-11  3:25  0%         ` Mikael Magnusson
    0 siblings, 1 reply; 200+ results
From: Mikael Magnusson @ 2011-01-11  3:25 UTC (permalink / raw)
  To: Anthony Heading; +Cc: zsh-workers

On 11 January 2011 03:54, Anthony Heading <anthony@ajrh.net> wrote:
> On Tue, 11 Jan 2011 02:50 +0100, "Mikael Magnusson" <mikachu@gmail.com>
> wrote:
>> > echo $( trap 'echo exiting' EXIT)
>> >
>> > or similar substitutions.  That's quite clearly a subshell entering to
>> > the same extent a ( ... ) is.
>>
>> How is that different from what you wrote?
>
> Well, the examples you quote are traps set within a subshell, which may
> or may not propagate higher.
>
> My problem is that the subshell is inheriting the parent trap action.
>
> That seems obviously different, and POSIX seems pretty clear:
>
>    When a subshell is entered, traps that are not being ignored shall
>    be set to the default actions, except in the case of a command
>    substitution containing only a single trap command, when the traps
>    need not be altered.

Ah, the manpage says this
       ( list )
              Execute  list  in a subshell.  Traps set by the trap
builtin are reset
              to their default values while executing list.

and it is true:
% trap 'echo hello >&2' EXIT
% a=$(ls)
% TRAPEXIT() { echo function hello >&2 }
% a=$(ls)
function hello

-- 
Mikael Magnusson


^ permalink raw reply	[relevance 0%]

* Re: 4.3.11 TRAPEXIT() on cygwin
  @ 2011-01-11  9:38  5%             ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2011-01-11  9:38 UTC (permalink / raw)
  To: zsh-workers

This tries to summarize the differences I know about.

Index: Doc/Zsh/func.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/func.yo,v
retrieving revision 1.25
diff -p -u -r1.25 func.yo
--- Doc/Zsh/func.yo	18 Feb 2009 17:17:27 -0000	1.25
+++ Doc/Zsh/func.yo	11 Jan 2011 09:34:58 -0000
@@ -348,19 +348,28 @@ enditem()
 
 findex(trap, use of)
 The functions beginning `tt(TRAP)' may alternatively be defined with the
-tt(trap) builtin:  this may be preferable for some uses, as they are then
-run in the environment of the calling process, rather than in their own
-function environment.  Apart from the difference in calling procedure and
-the fact that the function form appears in lists of functions, the forms
+tt(trap) builtin:  this may be preferable for some uses.  The forms
 
 example(TRAPNAL+LPAR()RPAR() { 
  # code
 })
 
-and
+('function traps') and
 
 example(trap '
  # code
 ' NAL)
 
-are equivalent.
+('list traps') are equivalent in most ways, the exceptions being the
+following:
+
+startitemize()
+itemiz(Function traps have all the properties of normal functions,
+appearing in the list of functions and being called with their own
+function context rather than the context where the trap was triggered.)
+itemiz(The return status from function traps is special, whereas a return
+from a list trap causes the surrounding context to return with the given
+status.)
+itemiz(Function traps are not reset within subshells, in accordance with
+zsh behaviour; list traps are reset, in accordance with POSIX behaviour.)
+enditemize()

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[relevance 5%]

* Re: sh compatibility issue
  @ 2011-02-18 10:30  2% ` Peter Stephenson
  2011-02-19 23:05  4%   ` Jilles Tjoelker
  0 siblings, 1 reply; 200+ results
From: Peter Stephenson @ 2011-02-18 10:30 UTC (permalink / raw)
  To: zsh-workers

On Thu, 17 Feb 2011 21:55:07 -0600
Vincent Stemen <vince.lists@hightek.org> wrote:
> I have encountered a minor compatibility issue when using zsh in place
> of /bin/sh on FreeBSD.
> The error comes from this piece of code in genscripts.sh
> 
>     # XXX: arm hack : until those file are merged back into the FSF
> repo, # just
>     # use the version in this directory.
>     if !(test -f ${CUSTOMIZER_SCRIPT}"";) then
>     CUSTOMIZER_SCRIPT="${srcdir}/emulparams/${EMULATION_NAME}.sh"
>     fi
> 
> What is happening is that zsh does not like the '!' being next to the
> opening '(' without a space in the if condition.  In my opinion, this
> is kind of an unorthodox syntax.  I'm not even sure if it is
> traditionally legal sh or ksh syntax.  Nevertheless, it works with
> BSD sh and bash. A simple test is
> 
>     if !(echo hello); then echo "XXXX"; fi
>     if ! (echo hello); then echo "XXXX"; fi
> 
> Zsh works fine in the second case, with a space after the '!'.

I don't think it is standard for this to work.  POSIX defines "!" as a
"reserved word", and if it's not followed by whitespace it's not a
word.

However, it looks like it's possible to get this to work specially in
this case without disrupting anything else; because the parentheses are
always special in one way another to zsh, the only other meaning (with
the exception below) would be a string "!" followed by something like a
globbing expression.  I can't think of a case where that other meaning
is useful (and it's sure as heck thoroughly confusing if you use it,
given all there are at least three meanings for "!" when not used
as a plain string).

The slightly odd handling is down to the fact ! isn't treated as
a token at this point since it's usually handled as a reserved word.

> I also tested without the space under ksh on NetBSD and got a strange
> result.  It ran the mail utility.  Weird.

That's because !(...) is globbing syntax in ksh.  It means "find all
files not matching the pattern in the parentheses".  So that can do
pretty much anything in command position.  So we need to avoid doing
this if the KSH_GLOB option is set (although the result isn't
particularly useful in practice).  Luckily KSH_GLOB isn't set for
emulating sh.

Index: Src/lex.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/lex.c,v
retrieving revision 1.63
diff -p -u -r1.63 lex.c
--- Src/lex.c	19 Dec 2010 17:42:10 -0000	1.63
+++ Src/lex.c	18 Feb 2011 10:18:13 -0000
@@ -487,6 +487,7 @@ ctxtlex(void)
 #define LX1_COMMENT 1
 #define LX1_NEWLIN 2
 #define LX1_SEMI 3
+#define LX1_BANG 4
 #define LX1_AMPER 5
 #define LX1_BAR 6
 #define LX1_INPAR 7
@@ -835,6 +836,30 @@ gettok(void)
 	hungetc(d);
 	lexstop = 0;
 	return SEMI;
+    case LX1_BANG:
+	/*
+	 * In command position, treat "!(" or "!{"
+	 * as "! (" or "! {".  "!" is a reserved word,
+	 * so not handled as a token at this level.
+	 * This is for compatibility; a "real"
+	 * reserved word wouldn't behave like this.
+	 *
+	 * With ksh globbing, !(...) is a special syntax.
+	 * Although it doesn't do anything very useful
+	 * in command position, we shouldn't disrupt it.
+	 */
+	if (incmdpos && !isset(KSHGLOB) && reswdtab->getnode(reswdtab, "!")) {
+	    d = hgetc();
+	    hungetc(d);
+	    lexstop = 0;
+	    if (d == '(' || d == '{') {
+		bptr = tokstr = (char *)hcalloc(2);
+		*bptr++ = '!';
+		*bptr++ = '\0';
+		return STRING;
+	    }
+	}
+	break;
     case LX1_AMPER:
 	d = hgetc();
 	if (d == '&')
Index: Test/A01grammar.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A01grammar.ztst,v
retrieving revision 1.27
diff -p -u -r1.27 A01grammar.ztst
--- Test/A01grammar.ztst	18 Mar 2010 16:30:58 -0000	1.27
+++ Test/A01grammar.ztst	18 Feb 2011 10:18:13 -0000
@@ -577,3 +577,11 @@
 0:$0 is traditionally if bizarrely set to the first argument with -c
 >myargzero
 >myargone
+
+  if ! (echo success1); then echo failure1; fi
+  if !(echo success2); then echo failure2; fi
+  if !{echo success3}; then echo failure3; fi
+0:Special handling of ! in command position.
+>success1
+>success2
+>success3

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[relevance 2%]

* Re: sh compatibility issue
  2011-02-18 10:30  2% ` Peter Stephenson
@ 2011-02-19 23:05  4%   ` Jilles Tjoelker
  2011-02-20  0:41  3%     ` Vincent Stemen
  2011-02-20 19:11  0%     ` Peter Stephenson
  0 siblings, 2 replies; 200+ results
From: Jilles Tjoelker @ 2011-02-19 23:05 UTC (permalink / raw)
  To: Zsh Hackers' List

> !(...) without space

I think the POSIX spec requires this to work, but that may not be
intentional. '(' is an operator and therefore it does not need a space
between it and other characters (except to disambiguate between two
adjacent operators and one two-character operator). It may not be
intentional because it conflicts with ksh extended pattern matching.

More generally, this rule also means that things like
  while(true)do(pwd)done
do not need any spaces. Although this example is contrived, I can
imagine there are real scripts that zsh fails to parse because of this;
the other shells I tried execute it correctly.

The situation for '!{' is different. '{' is a reserved word and
therefore it is not recognized. Instead, this describes a utility (or
alias) that probably does not exist. I do not recommend making special
allowances for it.

On a related note, here is another quite insidious sh compatibility
issue:
  sh -c 'exec </nonexistent/a; echo wrong'
This should not print "wrong" because exec is a special builtin and
redirection errors on special builtins are fatal. Most shells get this
right nowadays (bash only in POSIX mode) but zsh gets it wrong. Even
  set -o posixbuiltins
does not help.

-- 
Jilles Tjoelker


^ permalink raw reply	[relevance 4%]

* Re: sh compatibility issue
  2011-02-19 23:05  4%   ` Jilles Tjoelker
@ 2011-02-20  0:41  3%     ` Vincent Stemen
  2011-02-20 19:11  0%     ` Peter Stephenson
  1 sibling, 0 replies; 200+ results
From: Vincent Stemen @ 2011-02-20  0:41 UTC (permalink / raw)
  To: zsh-workers

On Sun, Feb 20, 2011 at 12:05:40AM +0100, Jilles Tjoelker wrote:
> > !(...) without space
> 
> I think the POSIX spec requires this to work, but that may not be
> intentional. '(' is an operator and therefore it does not need a space
> between it and other characters (except to disambiguate between two
> adjacent operators and one two-character operator). It may not be
> intentional because it conflicts with ksh extended pattern matching.
> 
> More generally, this rule also means that things like
>   while(true)do(pwd)done
> do not need any spaces. Although this example is contrived, I can
> imagine there are real scripts that zsh fails to parse because of this;
> the other shells I tried execute it correctly.
> 
> The situation for '!{' is different. '{' is a reserved word and
> therefore it is not recognized. Instead, this describes a utility (or
> alias) that probably does not exist. I do not recommend making special
> allowances for it.
> 
> On a related note, here is another quite insidious sh compatibility
> issue:
>   sh -c 'exec </nonexistent/a; echo wrong'
> This should not print "wrong" because exec is a special builtin and
> redirection errors on special builtins are fatal. Most shells get this
> right nowadays (bash only in POSIX mode) but zsh gets it wrong. Even
>   set -o posixbuiltins
> does not help.
> 
> -- 
> Jilles Tjoelker

Interesting.

I ran these two tests tests with sh, ksh, bash, and zsh.

while(true)do(pwd)done
    This worked in sh, ksh, and bash.  It failed only in zsh.

sh -c 'exec </nonexistent/a; echo wrong'
    This did not print "wrong" in sh and ksh.

    Zsh prints wrong in both sh and zsh mode and bash only prints "wrong"
    without the --posix switch.


Vince


^ permalink raw reply	[relevance 3%]

* Re: sh compatibility issue
  2011-02-19 23:05  4%   ` Jilles Tjoelker
  2011-02-20  0:41  3%     ` Vincent Stemen
@ 2011-02-20 19:11  0%     ` Peter Stephenson
  2011-02-20 20:17  0%       ` Peter Stephenson
       [not found]           ` <4D618A11.3050406@case.edu>
  1 sibling, 2 replies; 200+ results
From: Peter Stephenson @ 2011-02-20 19:11 UTC (permalink / raw)
  To: Zsh Hackers' List

On Sun, 20 Feb 2011 00:05:40 +0100
Jilles Tjoelker <jilles@stack.nl> wrote:
> > !(...) without space
> 
> I think the POSIX spec requires this to work, but that may not be
> intentional. '(' is an operator and therefore it does not need a space
> between it and other characters (except to disambiguate between two
> adjacent operators and one two-character operator). It may not be
> intentional because it conflicts with ksh extended pattern matching.
> 
> More generally, this rule also means that things like
>   while(true)do(pwd)done
> do not need any spaces. Although this example is contrived, I can
> imagine there are real scripts that zsh fails to parse because of this;
> the other shells I tried execute it correctly.

I think we can manage that when SH_GLOB is on (it'll screw up zsh
patterns royally otherwise), but it's quite a big change and we don't
have many tests for sh emulation, so someone ought to see what this
patch does before it goes much further.  All I've tested is what's in
the test patch.

This replaces the previous patch, but note that means you still need the
spaces in native zsh mode --- can't see a real problem there, in fact
it's probably safer as well as more consistent.

I had to exclude it with KSH_GLOB on because of the way we handle
KSH_GLOB expressions.  That's not the correct thing to do --- we should
handle KSH_GLOB expressions in the lexical analysis --- but KSH_GLOB
isn't on for normal sh emulation so I don't think it's a major problem.

> The situation for '!{' is different. '{' is a reserved word and
> therefore it is not recognized. Instead, this describes a utility (or
> alias) that probably does not exist. I do not recommend making special
> allowances for it.

You're right that '{' is different from '('.  I haven't done anything
special with it here.

> On a related note, here is another quite insidious sh compatibility
> issue:
>   sh -c 'exec </nonexistent/a; echo wrong'
> This should not print "wrong" because exec is a special builtin and
> redirection errors on special builtins are fatal. Most shells get this
> right nowadays (bash only in POSIX mode) but zsh gets it wrong. Even
>   set -o posixbuiltins
> does not help.

I think it does need to be fatal, but not because it's a special builtin
--- it looks like that's only a "may" rather than a "shall" --- but
because there is a rule for exec:

  If a redirection error occurs (see Consequences of Shell Errors ), the
  shell shall exit with a value in the range 1-125

which is certainly unambiguous on the subject.  This will need looking at.

Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.99
diff -p -u -r1.99 options.yo
--- Doc/Zsh/options.yo	16 Dec 2010 13:55:35 -0000	1.99
+++ Doc/Zsh/options.yo	20 Feb 2011 19:04:30 -0000
@@ -683,8 +683,12 @@ item(tt(SH_GLOB) <K> <S>)(
 Disables the special meaning of `tt(LPAR())', `tt(|)', `tt(RPAR())'
 and 'tt(<)' for globbing the result of parameter and command substitutions,
 and in some other places where
-the shell accepts patterns.  This option is set by default if zsh is
-invoked as tt(sh) or tt(ksh).
+the shell accepts patterns.  If tt(SH_GLOB) is set but tt(KSH_GLOB) is
+not, the shell allows the interpretation of
+subshell expressions enclosed in parentheses in some cases where there
+is no space before the opening parenthesis, e.g. tt(!LPAR()true+RPAR())
+is interpreted as if there were a space after the tt(!).  This option is
+set by default if zsh is invoked as tt(sh) or tt(ksh).
 )
 pindex(UNSET)
 pindex(NO_UNSET)
Index: Src/lex.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/lex.c,v
retrieving revision 1.63
diff -p -u -r1.63 lex.c
--- Src/lex.c	19 Dec 2010 17:42:10 -0000	1.63
+++ Src/lex.c	20 Feb 2011 19:04:30 -0000
@@ -877,7 +877,7 @@ gettok(void)
 		dbparens = 1;
 		return DINPAR;
 	    }
-	    if (incmdpos) {
+	    if (incmdpos || (isset(SHGLOB) && !isset(KSHGLOB))) {
 		len = 0;
 		bptr = tokstr = (char *) hcalloc(bsiz = 32);
 		switch (cmd_or_math(CS_MATH)) {
@@ -1141,6 +1141,8 @@ gettokstr(int c, int sub)
 		    break;
 		if (incasepat && !len)
 		    return INPAR;
+		if (!isset(KSHGLOB) && len)
+		    goto brk;
 	    }
 	    if (!in_brace_param) {
 		if (!sub) {
Index: Test/A01grammar.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A01grammar.ztst,v
retrieving revision 1.27
diff -p -u -r1.27 A01grammar.ztst
--- Test/A01grammar.ztst	18 Mar 2010 16:30:58 -0000	1.27
+++ Test/A01grammar.ztst	20 Feb 2011 19:04:30 -0000
@@ -577,3 +577,15 @@
 0:$0 is traditionally if bizarrely set to the first argument with -c
 >myargzero
 >myargone
+
+  (setopt shglob
+  eval '
+  if ! (echo success1); then echo failure1; fi
+  if !(echo success2); then echo failure2; fi
+  print -l one two | while(read foo)do(print read it)done
+  ')
+0:Parentheses in shglob
+>success1
+>success2
+>read it
+>read it


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


^ permalink raw reply	[relevance 0%]

* Re: sh compatibility issue
  2011-02-20 19:11  0%     ` Peter Stephenson
@ 2011-02-20 20:17  0%       ` Peter Stephenson
       [not found]           ` <4D618A11.3050406@case.edu>
  1 sibling, 0 replies; 200+ results
From: Peter Stephenson @ 2011-02-20 20:17 UTC (permalink / raw)
  To: Zsh Hackers' List

On Sun, 20 Feb 2011 19:11:59 +0000
Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> On Sun, 20 Feb 2011 00:05:40 +0100
> Jilles Tjoelker <jilles@stack.nl> wrote:
> > On a related note, here is another quite insidious sh compatibility
> > issue:
> >   sh -c 'exec </nonexistent/a; echo wrong'
> > This should not print "wrong" because exec is a special builtin and
> > redirection errors on special builtins are fatal. Most shells get this
> > right nowadays (bash only in POSIX mode) but zsh gets it wrong. Even
> >   set -o posixbuiltins
> > does not help.
> 
> I think it does need to be fatal, but not because it's a special builtin
> --- it looks like that's only a "may" rather than a "shall" --- but
> because there is a rule for exec:
> 
>   If a redirection error occurs (see Consequences of Shell Errors ), the
>   shell shall exit with a value in the range 1-125
> 
> which is certainly unambiguous on the subject.  This will need looking at.

I think this is unproblematic.  The relevant hooks are already mostly
there.

Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.99
diff -p -u -r1.99 options.yo
--- Doc/Zsh/options.yo	16 Dec 2010 13:55:35 -0000	1.99
+++ Doc/Zsh/options.yo	20 Feb 2011 20:11:45 -0000
@@ -1866,6 +1870,10 @@ tt(source),
 tt(times),
 tt(trap) and
 tt(unset).
+
+In addition, a failed redirection after tt(exec) causes a non-interactive
+shell to exit and an interactive shell to return to its top-level
+processing.
 )
 pindex(POSIX_IDENTIFIERS)
 pindex(NO_POSIX_IDENTIFIERS)
Index: Test/A04redirect.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A04redirect.ztst,v
retrieving revision 1.15
diff -p -u -r1.15 A04redirect.ztst
--- Test/A04redirect.ztst	14 Sep 2010 14:46:26 -0000	1.15
+++ Test/A04redirect.ztst	20 Feb 2011 20:11:45 -0000
@@ -366,3 +366,15 @@
 >more output:
 >This file contains data.
 >This file contains data.
+
+  $ZTST_testdir/../Src/zsh -fc 'exec >/nonexistent/nonexistent
+  echo output'
+0:failed exec redir, no POSIX_BUILTINS
+>output
+?zsh:1: no such file or directory: /nonexistent/nonexistent
+
+  $ZTST_testdir/../Src/zsh -f -o POSIX_BUILTINS -c '
+  exec >/nonexistent/nonexistent
+  echo output'
+1:failed exec redir, POSIX_BUILTINS
+?zsh:2: no such file or directory: /nonexistent/nonexistent
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.188
diff -p -u -r1.188 exec.c
--- Src/exec.c	17 Feb 2011 19:52:42 -0000	1.188
+++ Src/exec.c	20 Feb 2011 20:11:46 -0000
@@ -181,7 +181,15 @@ struct execstack *exstack;
 /**/
 mod_export Funcstack funcstack;
 
-#define execerr() if (!forked) { lastval = 1; goto done; } else _exit(1)
+#define execerr()				\
+    do {					\
+	if (!forked) {				\
+	    redir_err = lastval = 1;		\
+	    goto done;				\
+	} else {				\
+	    _exit(1);				\
+	}					\
+    } while (0)
 
 static int doneps4;
 static char *STTYval;
@@ -2312,7 +2320,7 @@ execcmd(Estate state, int input, int out
     struct multio *mfds[10];
     char *text;
     int save[10];
-    int fil, dfil, is_cursh, type, do_exec = 0, i, htok = 0;
+    int fil, dfil, is_cursh, type, do_exec = 0, redir_err = 0, i, htok = 0;
     int nullexec = 0, assign = 0, forked = 0;
     int is_shfunc = 0, is_builtin = 0, is_exec = 0, use_defpath = 0;
     /* Various flags to the command. */
@@ -3289,6 +3297,13 @@ execcmd(Estate state, int input, int out
     fixfds(save);
 
  done:
+    if (redir_err && isset(POSIXBUILTINS)) {
+	if (!isset(INTERACTIVE)) {
+	    /* We've already _exit'ed if forked */
+	    exit(1);
+	}
+	errflag = 1;
+    }
     if (newxtrerr) {
 	fil = fileno(newxtrerr);
 	fclose(newxtrerr);


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


^ permalink raw reply	[relevance 0%]

* Re: sh compatibility issue
       [not found]           ` <4D618A11.3050406@case.edu>
@ 2011-02-22 20:02  7%         ` Peter Stephenson
  2011-02-23  1:08  0%           ` Vincent Stemen
  2011-03-04 13:36  4%           ` Jilles Tjoelker
  0 siblings, 2 replies; 200+ results
From: Peter Stephenson @ 2011-02-22 20:02 UTC (permalink / raw)
  To: Zsh Hackers' List

On Sun, 20 Feb 2011 16:39:29 -0500
Chet Ramey <chet.ramey@case.edu> wrote:
> On 2/20/11 2:11 PM, Peter Stephenson wrote:
> >> On a related note, here is another quite insidious sh compatibility
> >> issue:
> >>   sh -c 'exec </nonexistent/a; echo wrong'
> >> This should not print "wrong" because exec is a special builtin and
> >> redirection errors on special builtins are fatal. Most shells get this
> >> right nowadays (bash only in POSIX mode) but zsh gets it wrong. Even
> >>   set -o posixbuiltins
> >> does not help.
> > 
> > I think it does need to be fatal, but not because it's a special builtin
> > --- it looks like that's only a "may" rather than a "shall" --- but
> > because there is a rule for exec:
> 
> No, that's actually a `shall'.  Section 2.8.1, special builtin, redirection
> error.

Thanks, didn't follow the link... it looks like the "may" here means
"may be required to".  The table shows essentially all errors for
special builtins are fatal.

I didn't actually test for a special builtin in the previous patch,
either.  Here's a revised patch with more careful tests.

Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.101
diff -p -u -r1.101 options.yo
--- Doc/Zsh/options.yo	21 Feb 2011 11:32:47 -0000	1.101
+++ Doc/Zsh/options.yo	22 Feb 2011 20:00:52 -0000
@@ -1871,9 +1871,9 @@ tt(times),
 tt(trap) and
 tt(unset).
 
-In addition, a failed redirection after tt(exec) causes a non-interactive
-shell to exit and an interactive shell to return to its top-level
-processing.
+In addition, various error conditions associated with the above builtins
+or tt(exec) cause a non-interactive shell to exit and an interactive
+shell to return to its top-level processing.
 )
 pindex(POSIX_IDENTIFIERS)
 pindex(NO_POSIX_IDENTIFIERS)
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.246
diff -p -u -r1.246 builtin.c
--- Src/builtin.c	7 Jan 2011 10:05:35 -0000	1.246
+++ Src/builtin.c	22 Feb 2011 20:00:53 -0000
@@ -4821,8 +4821,14 @@ bin_dot(char *name, char **argv, UNUSED(
 	freearray(pparams);
 	pparams = old;
     }
-    if (ret == SOURCE_NOT_FOUND)
-	zwarnnam(name, "%e: %s", errno, enam);
+    if (ret == SOURCE_NOT_FOUND) {
+	if (isset(POSIXBUILTINS)) {
+	    /* hard error in POSIX (we'll exit later) */
+	    zerrnam(name, "%e: %s", errno, enam);
+	} else {
+	    zwarnnam(name, "%e: %s", errno, enam);
+	}
+    }
     zsfree(arg0);
     if (old0) {
 	zsfree(argzero);
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.189
diff -p -u -r1.189 exec.c
--- Src/exec.c	21 Feb 2011 11:28:49 -0000	1.189
+++ Src/exec.c	22 Feb 2011 20:00:53 -0000
@@ -2416,6 +2416,8 @@ execcmd(Estate state, int input, int out
 		checked = !(cflags & BINF_BUILTIN);
 		break;
 	    }
+	    cflags &= ~BINF_BUILTIN & ~BINF_COMMAND;
+	    cflags |= hn->flags;
 	    if (!(hn->flags & BINF_PREFIX)) {
 		is_builtin = 1;
 
@@ -2425,8 +2427,6 @@ execcmd(Estate state, int input, int out
 		assign = (hn->flags & BINF_MAGICEQUALS);
 		break;
 	    }
-	    cflags &= ~BINF_BUILTIN & ~BINF_COMMAND;
-	    cflags |= hn->flags;
 	    checked = 0;
 	    if ((cflags & BINF_COMMAND) && nextnode(firstnode(args))) {
 		/* check for options to command builtin */
@@ -3297,12 +3297,20 @@ execcmd(Estate state, int input, int out
     fixfds(save);
 
  done:
-    if (redir_err && isset(POSIXBUILTINS)) {
-	if (!isset(INTERACTIVE)) {
-	    /* We've already _exit'ed if forked */
-	    exit(1);
+    if (isset(POSIXBUILTINS) &&
+	(cflags & (BINF_PSPECIAL|BINF_EXEC))) {
+	/*
+	 * For POSIX-compatibile behaviour with special
+	 * builtins (including exec which we don't usually
+	 * classify as a builtin, we treat all errors as fatal.
+	 */
+	if (redir_err || errflag) {
+	    if (!isset(INTERACTIVE)) {
+		/* We've already _exit'ed if forked */
+		exit(1);
+	    }
+	    errflag = 1;
 	}
-	errflag = 1;
     }
     if (newxtrerr) {
 	fil = fileno(newxtrerr);
Index: Test/A04redirect.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A04redirect.ztst,v
retrieving revision 1.16
diff -p -u -r1.16 A04redirect.ztst
--- Test/A04redirect.ztst	21 Feb 2011 11:28:49 -0000	1.16
+++ Test/A04redirect.ztst	22 Feb 2011 20:00:53 -0000
@@ -378,3 +378,52 @@
   echo output'
 1:failed exec redir, POSIX_BUILTINS
 ?zsh:2: no such file or directory: /nonexistent/nonexistent
+
+  $ZTST_testdir/../Src/zsh -f -o POSIX_BUILTINS -c '
+  set >/nonexistent/nonexistent
+  echo output'
+1:failed special builtin redir, POSIX_BUILTINS
+?zsh:2: no such file or directory: /nonexistent/nonexistent
+
+  $ZTST_testdir/../Src/zsh -f -o POSIX_BUILTINS -c '
+  echo >/nonexistent/nonexistent
+  echo output'
+0:failed unspecial builtin redir, POSIX_BUILTINS
+>output
+?zsh:2: no such file or directory: /nonexistent/nonexistent
+
+  $ZTST_testdir/../Src/zsh -f -o POSIX_BUILTINS -c '
+  . /nonexistent/nonexistent
+  echo output'
+1:failed dot, POSIX_BUILTINS
+?zsh:.:2: no such file or directory: /nonexistent/nonexistent
+
+  $ZTST_testdir/../Src/zsh -f -c '
+  . /nonexistent/nonexistent
+  echo output'
+0:failed dot, NO_POSIX_BUILTINS
+>output
+?zsh:.:2: no such file or directory: /nonexistent/nonexistent
+
+  $ZTST_testdir/../Src/zsh -f <<<'
+  readonly foo
+  foo=bar set output
+  echo output'
+0:failed assignment on posix special, NO_POSIX_BUILTINS
+>output
+?zsh: read-only variable: foo
+
+  $ZTST_testdir/../Src/zsh -f -o POSIX_BUILTINS <<<'
+  readonly foo
+  foo=bar set output
+  echo output'
+1:failed assignment on posix special, POSIX_BUILTINS
+?zsh: read-only variable: foo
+
+  $ZTST_testdir/../Src/zsh -f -o POSIX_BUILTINS <<<'
+  readonly foo
+  foo=bar echo output
+  echo output'
+0:failed assignment on non-posix-special, POSIX_BUILTINS
+>output
+?zsh: read-only variable: foo

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


^ permalink raw reply	[relevance 7%]

* Re: sh compatibility issue
  2011-02-22 20:02  7%         ` Peter Stephenson
@ 2011-02-23  1:08  0%           ` Vincent Stemen
  2011-02-23  1:51  3%             ` Bart Schaefer
  2011-03-04 13:36  4%           ` Jilles Tjoelker
  1 sibling, 1 reply; 200+ results
From: Vincent Stemen @ 2011-02-23  1:08 UTC (permalink / raw)
  To: zsh-workers

On Tue, Feb 22, 2011 at 08:02:59PM +0000, Peter Stephenson wrote:
> On Sun, 20 Feb 2011 16:39:29 -0500
> Chet Ramey <chet.ramey@case.edu> wrote:
> > On 2/20/11 2:11 PM, Peter Stephenson wrote:
> > >> On a related note, here is another quite insidious sh compatibility
> > >> issue:
> > >>   sh -c 'exec </nonexistent/a; echo wrong'
> > >> This should not print "wrong" because exec is a special builtin and
> > >> redirection errors on special builtins are fatal. Most shells get this
> > >> right nowadays (bash only in POSIX mode) but zsh gets it wrong. Even
> > >>   set -o posixbuiltins
> > >> does not help.
> > > 
> > > I think it does need to be fatal, but not because it's a special builtin
> > > --- it looks like that's only a "may" rather than a "shall" --- but
> > > because there is a rule for exec:
> > 
> > No, that's actually a `shall'.  Section 2.8.1, special builtin, redirection
> > error.
> 
> Thanks, didn't follow the link... it looks like the "may" here means
> "may be required to".  The table shows essentially all errors for
> special builtins are fatal.
> 
> I didn't actually test for a special builtin in the previous patch,
> either.  Here's a revised patch with more careful tests.

I don't think it worked.  With this patch added, the bahaviour did not
change from the previous patch.  Fatal error in sh mode not not in zsh
mode.

    $ /usr/bin/zsh -c 'exec </nonexistent/a; echo wrong'
    zsh:1: no such file or directory: /nonexistent/a
    wrong
    
    $ /usr/bin/zsh -c 'emulate sh; exec </nonexistent/a; echo wrong'
    zsh:1: no such file or directory: /nonexistent/a


^ permalink raw reply	[relevance 0%]

* Re: sh compatibility issue
  2011-02-23  1:08  0%           ` Vincent Stemen
@ 2011-02-23  1:51  3%             ` Bart Schaefer
  2011-02-23  2:30  0%               ` Vincent Stemen
  2011-02-23  9:25  4%               ` Peter Stephenson
  0 siblings, 2 replies; 200+ results
From: Bart Schaefer @ 2011-02-23  1:51 UTC (permalink / raw)
  To: zsh-workers

On Tuesday, February 22, 2011, Vincent Stemen <vince.lists@hightek.org> wrote:
>
> I don't think it worked.  With this patch added, the bahaviour did not
> change from the previous patch.  Fatal error in sh mode not not in zsh
> mode.

That's intentional.  Zsh is not a POSIX shell unless you tell it to
be, so in zsh mode it behaves the way zsh always has.

As I understand it, the patch should change the behavior of other
special builtins (in addition to exec), but only when POSIXBUILTINS is
set.


^ permalink raw reply	[relevance 3%]

* Re: sh compatibility issue
  2011-02-23  1:51  3%             ` Bart Schaefer
@ 2011-02-23  2:30  0%               ` Vincent Stemen
  2011-02-23  9:25  4%               ` Peter Stephenson
  1 sibling, 0 replies; 200+ results
From: Vincent Stemen @ 2011-02-23  2:30 UTC (permalink / raw)
  To: zsh-workers

On Tue, Feb 22, 2011 at 05:51:18PM -0800, Bart Schaefer wrote:
> On Tuesday, February 22, 2011, Vincent Stemen <vince.lists@hightek.org> wrote:
> >
> > I don't think it worked. ?With this patch added, the bahaviour did not
> > change from the previous patch. ?Fatal error in sh mode not not in zsh
> > mode.
> 
> That's intentional.  Zsh is not a POSIX shell unless you tell it to
> be, so in zsh mode it behaves the way zsh always has.
> 
> As I understand it, the patch should change the behavior of other
> special builtins (in addition to exec), but only when POSIXBUILTINS is
> set.

Oh.  OK.  If that's the case, then it does appear to work as intended 
on BSD :-).

    $ /usr/bin/zsh -c 'setopt posixbuiltins; exec </nonexistent/a; echo wrong'
    zsh:1: no such file or directory: /nonexistent/a



^ permalink raw reply	[relevance 0%]

* Re: sh compatibility issue
  2011-02-23  1:51  3%             ` Bart Schaefer
  2011-02-23  2:30  0%               ` Vincent Stemen
@ 2011-02-23  9:25  4%               ` Peter Stephenson
  1 sibling, 0 replies; 200+ results
From: Peter Stephenson @ 2011-02-23  9:25 UTC (permalink / raw)
  To: zsh-workers

On Tue, 22 Feb 2011 17:51:18 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Tuesday, February 22, 2011, Vincent Stemen <vince.lists@hightek.org> wrote:
> >
> > I don't think it worked.  With this patch added, the bahaviour did not
> > change from the previous patch.  Fatal error in sh mode not not in zsh
> > mode.
> 
> That's intentional.  Zsh is not a POSIX shell unless you tell it to
> be, so in zsh mode it behaves the way zsh always has.
> 
> As I understand it, the patch should change the behavior of other
> special builtins (in addition to exec), but only when POSIXBUILTINS is
> set.

Bart's right, sorry, I wasn't clear enough.  Yes, this is the
long-standing policy.

If we'd been designing zsh from scratch now, there would be no point in
all these small areas where it's a bit different from POSIX by accident
rather than design.  As it is, given the shell's manifold differences in
native mode, there's no point squeezing extra POSIX-compliance out of
native mode at the expense of backward compatibility.

By the way, one small tweak which should be rarely visible: now I've
upped the ante, there may be cases where we're forked at the point we
need to exit.

Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.190
diff -p -u -r1.190 exec.c
--- Src/exec.c	22 Feb 2011 20:09:20 -0000	1.190
+++ Src/exec.c	23 Feb 2011 09:21:32 -0000
@@ -3306,8 +3306,10 @@ execcmd(Estate state, int input, int out
 	 */
 	if (redir_err || errflag) {
 	    if (!isset(INTERACTIVE)) {
-		/* We've already _exit'ed if forked */
-		exit(1);
+		if (forked)
+		    _exit(1);
+		else
+		    exit(1);
 	    }
 	    errflag = 1;
 	}
-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[relevance 4%]

* typeset -p output gives shows variables which can't be read back in
@ 2011-02-27 11:44  3% Rocky Bernstein
    0 siblings, 1 reply; 200+ results
From: Rocky Bernstein @ 2011-02-27 11:44 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 2027 bytes --]

I would like to save to a file shell variables so that I can run a nested
zsh and then read these back in. It is becoming a bit of a challenge because
this in the output:

typeset -i10 -r !=0
typeset -i10 -r '#'=0
typeset -i10 -r '$'=15221
typeset -ar '*'
*=()
typeset -r -=569Xfy
typeset 0=_Dbg_do_shell
typeset -i10 -r '?'=0
typeset -ar @
@=()
typeset -rx _=-p

Failing a better solution, I think what I'll have to do is store IFS=''
typeset -p into an array and check each item of the array. But even this is
turning out to be a bit challenging.
One thing that one needs to do is look for read-only variables and then I
guess turn that into a test followed by the typeset. That is

typeset -p ARGC 2>/dev/null 1>/&2 && typeset -i10- r ARGC=0

Next one needs to check that the types valid which would weed out  the lines
above.

But then we come to the typeset -ar '*' line which I guess flows onto the
next line. At first I thought I could remove any lines that don't start with
"typeset", but this is wrong because I could have a line like:

typeset ZSH_DEBUG_CMD='if [ -d /etc/profile.d ]
then
for i in /etc/profile.d/*.sh
do
if [ -r $i ]
then
. $i
fi
done
unset i
fi'

and all of that will read back in fine.

Any suggestions?

A little bit of context of why I am doing this. Recently in the zsh debugger
I've added the ability to go into a nested zsh, and often one wants the
existing environment of the debugged program  preserved in this nested zsh.

Lastly, related on a different topic. I notice there's no option for
sourcing a startup file by name. Instead the closest thing is to create a
temporary directory and in that create a file called .zshenv and set
ZDOTDIR. This works, but strikes me as a bit awkward and more convoluted
than adding an option to indicated an additional profile to run.  Many
POSIX-like shell languages, notably ksh don't provide such an option, bash
does and it is called --init-file. And "higher-level" scripting languages
which have modules like Perl, Python, or Ruby all do as well.

^ permalink raw reply	[relevance 3%]

* Re: typeset -p output gives shows variables which can't be read back in
  @ 2011-03-01  3:09  4%       ` Rocky Bernstein
  0 siblings, 0 replies; 200+ results
From: Rocky Bernstein @ 2011-03-01  3:09 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 6152 bytes --]

Comments in line. In sum, thanks again for the code suggestion. A modified
version of that I now use in the debugger.

On Mon, Feb 28, 2011 at 2:09 AM, Bart Schaefer <schaefer@brasslantern.com>wrote:

> On Feb 28, 12:08am, Rocky Bernstein wrote:
> }
> } As for the typeset -T and typeset -p not showing -T associations, I think
> } that's a misfeature.
> }
> } Should I look into providing a patch for this?
>
> I think first there needs to be a bit of discussion about what the result
> should look like.
>
> E.g. if I have
>
>    typeset -T SCALAR=x:y:z array
>
> and then I do
>
>    typeset -p SCALAR
>    typeset -p array
>
> should I get the exact same output both times?
>

I don't understand the complexity let alone the ramifications here. If you
think it worthwhile or if others may be as confused as I am please
elaborate. (But I am probably not qualified to judge.)

In my simple-minded way of thinking, if I had previously issued:
   typeset -T SCALAR=x:y:z array

then "typeset -p" I would imagine would print:
   typeset -T SCALAR=x:y:z array

what "typeset -p array" prints is another issue and dependent on the
definition of "array".



> Also what should the value of $parameters[foo] look like?  My first idea
> is something like
>
>    array-tied:FOO
>
> but there may be problems with that which I haven't foreseen.
>

Again, you are probably in a better position than most to know about those
problems. I imagine if anyone else on the list has something to add, they
will.

>From my standpoint, even if nothing is done here but just adding the
simple-minded "typeset -p" for the tied array/scalar is an improvement.



> } Saving an environment for reloading into another session, whether
> } nested or not, might be useful in other contexts. Possibly the code
> } you or I have in zshdb could be turned into a function and put inside
> } the parameter module?
>
> Until you mentioned the debugger, I was completely at a loss to come up
> with an environment where you'd want to attempt to reload any parameter
> that is normally maintained by the shell internals (such as any of the
> variables in the $parameter module, or most of the other modules for
> that matter).  I still can't think of one.
>

Alas again I am not sure I understand you here.

Something I think likely is that I am inside a zsh session I've been playing
around writing definitions and trying tests and setting variables and want
to save out the environment so that sometime later I can come back into zsh
and set things up roughly as they were before.

Or perhaps in order to send back a bug report I want someone else to be able
to see the
relations of things. They might have to edit parts of that environment, but
still the bulk of the settings would be relevant.


> However, parameters that are marked "typeset -H" and thus have their
> values suppressed in the typeset -p output can only be saved/restored
> by tricks that would be better applied in a C function, so I can't
> really argue against it.
>
> } What I'm thinking of now is adding a function save_var which takes the
> } name of a variable one wants to persist.
>
> That makes a bit more sense, but in that case you have a list of the
> names and can do
>
>    for param in "${save_vars[@]}"
>    do case $parameters[$param] in
>       (*assoc*)
>         print -- "typeset -A $param; $param=( ${(P@kvqq)param} )";;
>       (*array*)
>         print -- "typeset -a $param; $param=( ${(P@qq)param} )";;
>       # etc.
>    done > $the_save_file
>
> The point being that one doesn't need to dump the entire output of
> typeset, only the parameters whose names are explicitly known.
>

I never suggested on a *restore* everything would be saved, although now
that I think of it, that would have the advantage of obviating having the
user indicate which variables should persist.

For now, I'll go with the more manual approach. It may in fact be that folks
*don't* want changes they make to persist. Thing can always be changed
later.

I am kind of mixed on how much I want to use zsh-specific idioms, rather
than, say using
eval which may be clunkier but works on all of the POSIX shells. The more
shell-specific code I have, the more maintenance I have across the 3 POSIX
shell debuggers.

That said, the code you have above is more shell idiomatic than the kind of
thing I have been writing. I suspect there is much that could be improved in
the debugger because at heart I'm not that good of a POSIX shell
programmer.

I hope you don't take offense, but the code you have above is a little bit
wrong. We don't want to issue typeset commands because that will cause the
*scope* to change.

In a debugger, one is in trap function which then invoked the nested shell.
The restore is done in the trap hook -- specifically in the debugger's
"shell" command. But the original definition of the variable (if there is
one) that a programmer typically wants to change will not be in the hook,
but farther away the call chain in the debugged program.


> } If there is something like a tie function like there is in Perl or a
> } discipline function on a varaible like ksh, that might be used, but
> } this would be on a per-variable basis.
>
> There's not, at this time.
>
> } On Sun, Feb 27, 2011 at 4:01 PM, Bart Schaefer <
> schaefer@brasslantern.com>wrote:
> } >
> } >    () {
> } >      local param type
> } >      for param type in "${(kv@)parameters}"
> } >      do
> } >        case "$type" in
> } >        (*local*) continue;;   # Skip loop variables
> } >        (*export*) continue;;  # No need to dump/restore if exported?
> } >        (*special*) continue;; # Maintained by the shell
> } >        (*readonly*) continue;;
> } >        (*) typeset -p "$param";;
> } >        esac
> } >      done
> } >    }
> }
> } But while we are being precise, let me point out that it is wrong to
> } say that a local variable is a "loop" variable as you suggest in the
> } code above.
>
> I was referring to skipping "param" and "type", the variables for the loop
> over ${(kv)parameters}.  There aren't any other locals in the anonymous
> scope (though there could be in a surrounding scope).
>

^ permalink raw reply	[relevance 4%]

* Re: sh compatibility issue
  2011-02-22 20:02  7%         ` Peter Stephenson
  2011-02-23  1:08  0%           ` Vincent Stemen
@ 2011-03-04 13:36  4%           ` Jilles Tjoelker
  2011-03-06 20:26  5%             ` Peter Stephenson
  1 sibling, 1 reply; 200+ results
From: Jilles Tjoelker @ 2011-03-04 13:36 UTC (permalink / raw)
  To: Zsh Hackers' List

I notice that the patches were committed. This indeed fixes some things
(FreeBSD sh testsuite errors/redirection-error.0 which checks that
redirection errors for special builtins are fatal) but breaks another
test which happened to pass before: errors/redirection-error3.0 which
checks that redirection errors are not fatal for special builtins
preceded by the command builtin.

Although 'command' is often implemented as some sort of precommand
modifier, the POSIX specification says it is a regular builtin,
therefore redirection errors are not fatal (and variable assignments do
not persist). The specification also says that 'command' causes operand
(syntax) errors to be non-fatal.

A useful example is in the Application Usage section of the 'command'
page:
  command exec > unwritable-file
This does not cause the shell to abort, so the exit status can be
checked by the script.

This works as specified in ksh93, bash --posix and FreeBSD 9 sh, for
example.

-- 
Jilles Tjoelker


^ permalink raw reply	[relevance 4%]

* Re: sh compatibility issue
  2011-03-04 13:36  4%           ` Jilles Tjoelker
@ 2011-03-06 20:26  5%             ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2011-03-06 20:26 UTC (permalink / raw)
  To: Zsh Hackers' List

On Fri, 4 Mar 2011 14:36:34 +0100
Jilles Tjoelker <jilles@stack.nl> wrote:
> Although 'command' is often implemented as some sort of precommand
> modifier, the POSIX specification says it is a regular builtin,
> therefore redirection errors are not fatal (and variable assignments do
> not persist). The specification also says that 'command' causes operand
> (syntax) errors to be non-fatal.

This should fix at least some such problems.

Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.191
diff -p -u -r1.191 exec.c
--- Src/exec.c	23 Feb 2011 09:47:06 -0000	1.191
+++ Src/exec.c	6 Mar 2011 20:25:15 -0000
@@ -2324,7 +2324,7 @@ execcmd(Estate state, int input, int out
     int nullexec = 0, assign = 0, forked = 0;
     int is_shfunc = 0, is_builtin = 0, is_exec = 0, use_defpath = 0;
     /* Various flags to the command. */
-    int cflags = 0, checked = 0, oautocont = -1;
+    int cflags = 0, orig_cflags = 0, checked = 0, oautocont = -1;
     LinkList redir;
     wordcode code;
     Wordcode beg = state->pc, varspc;
@@ -2416,6 +2416,7 @@ execcmd(Estate state, int input, int out
 		checked = !(cflags & BINF_BUILTIN);
 		break;
 	    }
+	    orig_cflags |= cflags;
 	    cflags &= ~BINF_BUILTIN & ~BINF_COMMAND;
 	    cflags |= hn->flags;
 	    if (!(hn->flags & BINF_PREFIX)) {
@@ -3298,11 +3299,13 @@ execcmd(Estate state, int input, int out
 
  done:
     if (isset(POSIXBUILTINS) &&
-	(cflags & (BINF_PSPECIAL|BINF_EXEC))) {
+	(cflags & (BINF_PSPECIAL|BINF_EXEC)) &&
+	!(orig_cflags & BINF_COMMAND)) {
 	/*
 	 * For POSIX-compatible behaviour with special
 	 * builtins (including exec which we don't usually
 	 * classify as a builtin) we treat all errors as fatal.
+	 * The "command" builtin is not special so resets this behaviour.
 	 */
 	if (redir_err || errflag) {
 	    if (!isset(INTERACTIVE)) {
Index: Test/A04redirect.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A04redirect.ztst,v
retrieving revision 1.17
diff -p -u -r1.17 A04redirect.ztst
--- Test/A04redirect.ztst	22 Feb 2011 20:09:20 -0000	1.17
+++ Test/A04redirect.ztst	6 Mar 2011 20:25:15 -0000
@@ -386,6 +386,13 @@
 ?zsh:2: no such file or directory: /nonexistent/nonexistent
 
   $ZTST_testdir/../Src/zsh -f -o POSIX_BUILTINS -c '
+  command set >/nonexistent/nonexistent
+  echo output'
+0:failed special builtin redir with command prefix, POSIX_BUILTINS
+>output
+?zsh:2: no such file or directory: /nonexistent/nonexistent
+
+  $ZTST_testdir/../Src/zsh -f -o POSIX_BUILTINS -c '
   echo >/nonexistent/nonexistent
   echo output'
 0:failed unspecial builtin redir, POSIX_BUILTINS

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


^ permalink raw reply	[relevance 5%]

* bug in ${##} expansion
@ 2011-03-11 19:07  3% Eric Blake
  2011-03-11 20:04  3% ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Eric Blake @ 2011-03-11 19:07 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 420 bytes --]

POSIX requires ${#parameter} to expand to the length of parameter as a
string.  It also requires that ${parameter#word} substitution have a
word (that is, ${parameter#} with a missing word is a zsh extension).

Therefore, this should output 2, not 11:

zsh -c 'set 1 2 3 4 5 6 7 8 9 10 11; echo ${##}'

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[relevance 3%]

* Re: bug in ${##} expansion
  2011-03-11 19:07  3% bug in ${##} expansion Eric Blake
@ 2011-03-11 20:04  3% ` Peter Stephenson
  2011-03-21 10:15  0%   ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Peter Stephenson @ 2011-03-11 20:04 UTC (permalink / raw)
  To: zsh-workers

On Fri, 11 Mar 2011 12:07:20 -0700
Eric Blake <eblake@redhat.com> wrote:
> POSIX requires ${#parameter} to expand to the length of parameter as a
> string.  It also requires that ${parameter#word} substitution have a
> word (that is, ${parameter#} with a missing word is a zsh extension).
> 
> Therefore, this should output 2, not 11:
> 
> zsh -c 'set 1 2 3 4 5 6 7 8 9 10 11; echo ${##}'

It's a straightforward bug, not specific to POSIX compatibility in
this case; testing for a name after the # is a special case which
covered some special names but not others.

Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.117
diff -p -u -r1.117 subst.c
--- Src/subst.c	11 Mar 2011 16:32:11 -0000	1.117
+++ Src/subst.c	11 Mar 2011 19:59:57 -0000
@@ -2039,6 +2039,7 @@ paramsubst(LinkList l, LinkNode n, char 
 	} else if ((c == '#' || c == Pound) &&
 		   (itype_end(s+1, IIDENT, 0) != s + 1
 		    || (cc = s[1]) == '*' || cc == Star || cc == '@'
+		    || cc == '#' || cc == Pound
 		    || cc == '-' || (cc == ':' && s[2] == '-')
 		    || (isstring(cc) && (s[2] == Inbrace || s[2] == Inpar)))) {
 	    getlen = 1 + whichlen, s++;
Index: Test/D04parameter.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D04parameter.ztst,v
retrieving revision 1.54
diff -p -u -r1.54 D04parameter.ztst
--- Test/D04parameter.ztst	18 Jan 2011 10:29:58 -0000	1.54
+++ Test/D04parameter.ztst	11 Mar 2011 19:59:57 -0000
@@ -175,6 +175,14 @@
 0:${#...}, $#...
 >8 8 8 8 8 8 8 8
 
+  set 1 2 3 4 5 6 7 8 9
+  print ${##}
+  set 1 2 3 4 5 6 7 8 9 10
+  print ${##}
+0:${##} is length of $#
+>1
+>2
+
   array=(once bitten twice shy)
   print IF${array}THEN
   print IF${^array}THEN

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


^ permalink raw reply	[relevance 3%]

* Re: bug in ${##} expansion
  2011-03-11 20:04  3% ` Peter Stephenson
@ 2011-03-21 10:15  0%   ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2011-03-21 10:15 UTC (permalink / raw)
  To: zsh-workers

On Fri, 11 Mar 2011 20:04:37 +0000
Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> On Fri, 11 Mar 2011 12:07:20 -0700
> Eric Blake <eblake@redhat.com> wrote:
> > POSIX requires ${#parameter} to expand to the length of parameter
> > as a string.  It also requires that ${parameter#word} substitution
> > have a word (that is, ${parameter#} with a missing word is a zsh
> > extension).
> > 
> > Therefore, this should output 2, not 11:
> > 
> > zsh -c 'set 1 2 3 4 5 6 7 8 9 10 11; echo ${##}'
> 
> It's a straightforward bug, not specific to POSIX compatibility in
> this case; testing for a name after the # is a special case which
> covered some special names but not others.

A couple more missing.

Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.118
diff -p -u -r1.118 subst.c
--- Src/subst.c	11 Mar 2011 21:06:00 -0000	1.118
+++ Src/subst.c	21 Mar 2011 10:13:00 -0000
@@ -2039,6 +2039,8 @@ paramsubst(LinkList l, LinkNode n, char 
 	} else if ((c == '#' || c == Pound) &&
 		   (itype_end(s+1, IIDENT, 0) != s + 1
 		    || (cc = s[1]) == '*' || cc == Star || cc == '@'
+		    || cc == '?' || cc == Quest
+		    || cc == '$' || cc == String || cc == Qstring
 		    || cc == '#' || cc == Pound
 		    || cc == '-' || (cc == ':' && s[2] == '-')
 		    || (isstring(cc) && (s[2] == Inbrace || s[2] == Inpar)))) {

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[relevance 0%]

* [PATCH v2] define _GNU_SOURCE
@ 2011-04-12 13:09  5% Valentin Ochs
      0 siblings, 2 replies; 200+ results
From: Valentin Ochs @ 2011-04-12 13:09 UTC (permalink / raw)
  To: zsh-workers

Sorry, haven't had my caffeine injection yet :)

The test for struct timezone needs _GNU_SOURCE as well, and it's
probably better to just use _POSIX_C_SOURCE for sigset_t.

Best regards,
Valentin

---
diff -upr -x configure -x config.h.in zsh-4.3.11/Src/system.h zsh/Src/system.h
--- zsh-4.3.11/Src/system.h     2010-02-22 11:12:31.000000000 +0100
+++ zsh/Src/system.h    2011-04-12 14:20:37.106000061 +0200
@@ -37,13 +37,12 @@
 #endif
 #endif

-#if defined(__linux) || defined(__GNU__) || defined(__GLIBC__)
 /*
  * Turn on numerous extensions.
  * This is in order to get the functions for manipulating /dev/ptmx.
  */
 #define _GNU_SOURCE 1
-#endif
+#define _POSIX_C_SOURCE 200809L

 /* NeXT has half-implemented POSIX support *
  * which currently fools configure         */
diff -upr -x configure -x config.h.in zsh-4.3.11/configure.ac zsh/configure.ac
--- zsh-4.3.11/configure.ac     2010-09-23 11:42:05.000000000 +0200
+++ zsh/configure.ac    2011-04-12 14:20:13.407000063 +0200
@@ -983,7 +983,8 @@ dnl <sys/types.h> and <signal.h>.  Other
 dnl to be added.
 AC_CACHE_CHECK(for sigset_t, zsh_cv_type_sigset_t,
 [AC_TRY_COMPILE(
-[#include <sys/types.h>
+[#define _POSIX_C_SOURCE 200809L
+#include <sys/types.h>
 #include <signal.h>], [sigset_t tempsigset;],
   zsh_cv_type_sigset_t=yes, zsh_cv_type_sigset_t=no)])
 AH_TEMPLATE([sigset_t],
@@ -1005,6 +1006,7 @@ AC_CHECK_MEMBERS([struct stat.st_atim.tv

 dnl Check for struct timezone since some old SCO versions do not define it
 zsh_TYPE_EXISTS([
+#define _GNU_SOURCE 1
 #ifdef HAVE_SYS_TIME_H
 # include <sys/time.h>
 #endif
--Valentin


^ permalink raw reply	[relevance 5%]

* Re: build on os x 10.6.7, xcode 3.2.6
  @ 2011-04-13 16:26  6%   ` Peter Stephenson
  2011-04-13 19:32  0%     ` S. Cowles
  0 siblings, 1 reply; 200+ results
From: Peter Stephenson @ 2011-04-13 16:26 UTC (permalink / raw)
  To: zsh-workers

On Wed, 13 Apr 2011 09:10:47 -0700
"S. Cowles" <scowles@ckhb.org> wrote:
> i have been building source from the sourceforge cvs repository on os
> x 10.6.x for the past two months with no issues, until this week.  as
> of rev4.3.11-dev-1, patchlevel 1.5245, i have begun getting the
> following build error
> 
> gcc -c -I. -I/opt/local/include -DHAVE_CONFIG_H -Wall
> -Wmissing-prototypes -O2  -o builtin.o builtin.c In file included
> from zsh.mdh:37, from builtin.c:33:
> exec.epro:29: error: 'RLIM_NLIMITS' undeclared here (not in a
> function) make[2]: *** [builtin.o] Error 1
> make[1]: *** [modobjs] Error 2
> make: *** [all] Error 1
> 
> previously, rev4.3.11-dev-1, patchlevel 1.5241, and prior, built with
> no problems.  i am still looking for what might cause the
> RLIM_NLIMITS definition to be missed, but wanted to find out if
> someone was already aware of this issue and might point out any
> possible mistake on my part.

No, but there's a good chance it's got something to do with this
change.  Changing random source code options often has side effects.
Does removing either _GNU_SOURCE or _POSIX_C_SOURCE help?

--- zsh-4.3.11/Src/system.h     2010-02-22 11:12:31.000000000 +0100
+++ zsh/Src/system.h    2011-04-12 14:20:37.106000061 +0200
@@ -37,13 +37,12 @@
 #endif
 #endif

-#if defined(__linux) || defined(__GNU__) || defined(__GLIBC__)
 /*
  * Turn on numerous extensions.
  * This is in order to get the functions for manipulating /dev/ptmx.
  */
 #define _GNU_SOURCE 1
-#endif
+#define _POSIX_C_SOURCE 200809L

 /* NeXT has half-implemented POSIX support *
  * which currently fools configure         */

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[relevance 6%]

* Re: build on os x 10.6.7, xcode 3.2.6
  2011-04-13 16:26  6%   ` Peter Stephenson
@ 2011-04-13 19:32  0%     ` S. Cowles
  0 siblings, 0 replies; 200+ results
From: S. Cowles @ 2011-04-13 19:32 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

On Wed, 13 Apr 2011, Peter Stephenson wrote:

> On Wed, 13 Apr 2011 09:10:47 -0700
> "S. Cowles" <scowles@ckhb.org> wrote:
>> i have been building source from the sourceforge cvs repository on os
>> x 10.6.x for the past two months with no issues, until this week.  as
>> of rev4.3.11-dev-1, patchlevel 1.5245, i have begun getting the
>> following build error
>>
>> gcc -c -I. -I/opt/local/include -DHAVE_CONFIG_H -Wall
>> -Wmissing-prototypes -O2  -o builtin.o builtin.c In file included
>> from zsh.mdh:37, from builtin.c:33:
>> exec.epro:29: error: 'RLIM_NLIMITS' undeclared here (not in a
>> function) make[2]: *** [builtin.o] Error 1
>> make[1]: *** [modobjs] Error 2
>> make: *** [all] Error 1
>>
>> previously, rev4.3.11-dev-1, patchlevel 1.5241, and prior, built with
>> no problems.  i am still looking for what might cause the
>> RLIM_NLIMITS definition to be missed, but wanted to find out if
>> someone was already aware of this issue and might point out any
>> possible mistake on my part.
>
> No, but there's a good chance it's got something to do with this
> change.  Changing random source code options often has side effects.
> Does removing either _GNU_SOURCE or _POSIX_C_SOURCE help?
>
> --- zsh-4.3.11/Src/system.h     2010-02-22 11:12:31.000000000 +0100
> +++ zsh/Src/system.h    2011-04-12 14:20:37.106000061 +0200
> @@ -37,13 +37,12 @@
> #endif
> #endif
>
> -#if defined(__linux) || defined(__GNU__) || defined(__GLIBC__)
> /*
>  * Turn on numerous extensions.
>  * This is in order to get the functions for manipulating /dev/ptmx.
>  */
> #define _GNU_SOURCE 1
> -#endif
> +#define _POSIX_C_SOURCE 200809L
>
> /* NeXT has half-implemented POSIX support *
>  * which currently fools configure         */


i checked all three cases:
 	1)
 		/* #define _GNU_SOURCE 1 /**/
 		#define _POSIX_C_SOURCE 200809L
 	2)
 		/* #define _GNU_SOURCE 1 /**/
 		/* #define _POSIX_C_SOURCE 200809L /**/
 	3)
 		#define _GNU_SOURCE 1
 		/* #define _POSIX_C_SOURCE 200809L /**/

cases 2 and 3 built patchlevel 1.5246 with no problem.  so, indeed,
removing _POSIX_C_SOURCE does help.  thank you very much for pinpointing
the search.

perhaps some directive such as the following might be sufficiently
restrictive to handle OS X and not interfere with other OS
installations on apple hardware:

#if !defined(__APPLE__) && !defined(__APPLE_CC__)
#define _POSIX_C_SOURCE 200809L
#endif


^ permalink raw reply	[relevance 0%]

* Re: [PATCH v2] define _GNU_SOURCE
  @ 2011-04-14  9:03  5%   ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2011-04-14  9:03 UTC (permalink / raw)
  To: zsh-workers; +Cc: Valentin Ochs

On Thu, 14 Apr 2011 09:35:23 +0100
Peter Stephenson <Peter.Stephenson@csr.com> wrote:

> On Tue, 12 Apr 2011 15:09:32 +0200
> Valentin Ochs <a@0au.de> wrote:
> > -#if defined(__linux) || defined(__GNU__) || defined(__GLIBC__)
> >  /*
> >   * Turn on numerous extensions.
> >   * This is in order to get the functions for
> > manipulating /dev/ptmx. */
> >  #define _GNU_SOURCE 1
> > -#endif
> > +#define _POSIX_C_SOURCE 200809L
> 
> Looks like we'll need to #ifdef these for the appropriate system,
> since it's causing mayhem elsewhere.  Can you provide a preprocessor
> test for the system you're fixing?

I couldn't see anything obvious in musl to test for.  For, I'll make it
so that it can be explicitly enabled with configure --enable-libc-musl.

Index: configure.ac
===================================================================
RCS file: /cvsroot/zsh/zsh/configure.ac,v
retrieving revision 1.133
diff -p -u -r1.133 configure.ac
--- configure.ac	12 Apr 2011 14:51:31 -0000	1.133
+++ configure.ac	14 Apr 2011 09:01:45 -0000
@@ -2466,6 +2466,17 @@ if test x$zsh_cv_c_unicode_support = xye
 fi
 
 dnl
+dnl musl support
+dnl
+AH_TEMPLATE([LIBC_MUSL],
+[Define to 1 if musl is being used as the C library])
+AC_ARG_ENABLE(libc-musl,
+AC_HELP_STRING([--enable-libc-musl], [compile with musl as the C library]),
+[if test x$enableval = xyes; then
+  AC_DEFINE(LIBC_MUSL)
+fi])
+
+dnl
 dnl static user lookup
 dnl
 AC_ARG_ENABLE(dynamic-nss,
Index: Src/system.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/system.h,v
retrieving revision 1.57
diff -p -u -r1.57 system.h
--- Src/system.h	12 Apr 2011 14:51:33 -0000	1.57
+++ Src/system.h	14 Apr 2011 09:01:45 -0000
@@ -37,12 +37,16 @@
 #endif
 #endif
 
+#if defined(__linux) || defined(__GNU__) || defined(__GLIBC__) || defined(LIBC_MUSL)
 /*
  * Turn on numerous extensions.
  * This is in order to get the functions for manipulating /dev/ptmx.
  */
 #define _GNU_SOURCE 1
+#endif
+#ifdef LIBC_MUSL
 #define _POSIX_C_SOURCE 200809L
+#endif
 
 /* NeXT has half-implemented POSIX support *
  * which currently fools configure         */


-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[relevance 5%]

* Re: SIGFPE crash
  @ 2011-05-09 10:21  3%       ` Vincent Lefevre
  0 siblings, 0 replies; 200+ results
From: Vincent Lefevre @ 2011-05-09 10:21 UTC (permalink / raw)
  To: zsh-workers

On 2011-05-08 00:27:30 +0200, Mikael Magnusson wrote:
> This is assuming we want to do this at all,

One should have a well-defined behavior.

> I am told that only division will generate an exception on x86, but
> presumably other arches behave differently,

Perhaps, but this also depends on the compiler. The operation
LONG_MIN/(-1) has an undefined behavior in two's complement
because the result is not representable. So, it should be avoided.

> and bash behaves the same way too (exception + die). Does some sort
> of standard have anything to say on the matter? I'm guessing someone
> has thought of it before and clearly nobody ever did anything about
> it.

It seems that POSIX just says:

  If the expression is invalid, the expansion fails and the shell
  shall write a message to standard error indicating the failure.

The behavior doesn't seem to be explicitly specified when there is
an overflow, and may be covered by an extension to provide a valid
result (e.g. using floating-point). Otherwise I suppose that the
behavior should not be worse than an invalid expression, e.g. a
crash shouldn't occur.

At least zsh should behave in a consistent way. For instance,
$((0/0)) returns an error, so that it should be the same case
with the minimum integer divided by -1.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)


^ permalink raw reply	[relevance 3%]

* Re: PATCH: expanding parameters like echo/print builtins
@ 2011-05-14 11:41  4% Jilles Tjoelker
  2011-05-14 18:41  3% ` Bart Schaefer
  0 siblings, 1 reply; 200+ results
From: Jilles Tjoelker @ 2011-05-14 11:41 UTC (permalink / raw)
  To: zsh-workers

> [${(g)parameter} expansion for expanding like echo/print]

Am I really strange in thinking this should really be done using command
substitution of echo, print or printf with appropriate options?

Admittedly, this requires precautions if trailing newlines are
significant, like (for expanding similar to the System V echo):

result=$(printf '%b@' "$v")
result=${result%@}

If trailing newlines are not significant, the syntax is very readable,
like:

result=$(printf '%b' "$v")

result=$(printf "$v") # careful with %

result=$(print - "$v")

Command substitution can be slow because it forks a subshell, but ksh93
and FreeBSD sh prove it need not be -- a subshell can be emulated
without a fork in many cases and POSIX is explicitly worded to allow
this.

Other tricks are using eval with $'...' (requires special care for ' and
is not in POSIX.1-2008).

In general, I think the ${(foo)parameter} forms are mostly write-only
code for interactive use, except perhaps if you use them a lot.

-- 
Jilles Tjoelker


^ permalink raw reply	[relevance 4%]

* Re: PATCH: expanding parameters like echo/print builtins
  2011-05-14 11:41  4% PATCH: expanding parameters like echo/print builtins Jilles Tjoelker
@ 2011-05-14 18:41  3% ` Bart Schaefer
  0 siblings, 0 replies; 200+ results
From: Bart Schaefer @ 2011-05-14 18:41 UTC (permalink / raw)
  To: zsh-workers

On May 14,  1:41pm, Jilles Tjoelker wrote:
} Subject: Re: PATCH: expanding parameters like echo/print builtins
}
} > [${(g)parameter} expansion for expanding like echo/print]
} 
} Am I really strange in thinking this should really be done using command
} substitution of echo, print or printf with appropriate options?

A lot of features added to zsh are things that could be done another
way but that it's more convenient to have a shortcut.

E.g., one could argue that $((5 + 3)) should really be done using
$(expr 5 + 3), etc.

} Admittedly, this requires precautions if trailing newlines are
} significant [...]
} Other tricks are using eval with $'...' (requires special care for '
} and is not in POSIX.1-2008).

It's often precisely to avoid those precautions and "special care"
cases that things like (g) get introduced.
 
} In general, I think the ${(foo)parameter} forms are mostly write-only
} code for interactive use, except perhaps if you use them a lot.

I think you've got that exactly backward. :-)  If these forms were
primarily for interactive use, the syntax would probably be a lot
less convoluted.  $'...' is for interactive use.  ${(g:oe:)...}, not
so much.


^ permalink raw reply	[relevance 3%]

* regression in ${##""}
@ 2011-06-03 18:00  3% Eric Blake
  2011-06-03 18:55  0% ` Mikael Magnusson
  0 siblings, 1 reply; 200+ results
From: Eric Blake @ 2011-06-03 18:00 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 520 bytes --]

POSIX requires ${##""} to be parsed as ${parameter#word} with parameter
of # and word of "", which results in the output of $# with the shortest
prefix of the empty string removed (aka ${#}).  But current zsh.git
rejects this:

$ ./Src/zsh -c 'set a b; echo ${##""}'
zsh:1: bad substitution

Worse, this is a regression:

$ zsh -c 'set a b; echo ${##""}'
2
$ rpm -q zsh
zsh-4.3.10-5.fc14.x86_64

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[relevance 3%]

* Re: regression in ${##""}
  2011-06-03 18:00  3% regression in ${##""} Eric Blake
@ 2011-06-03 18:55  0% ` Mikael Magnusson
  2011-06-03 19:16  3%   ` Eric Blake
  0 siblings, 1 reply; 200+ results
From: Mikael Magnusson @ 2011-06-03 18:55 UTC (permalink / raw)
  To: Eric Blake; +Cc: zsh-workers

On 3 June 2011 20:00, Eric Blake <eblake@redhat.com> wrote:
> POSIX requires ${##""} to be parsed as ${parameter#word} with parameter
> of # and word of "", which results in the output of $# with the shortest
> prefix of the empty string removed (aka ${#}).  But current zsh.git
> rejects this:
>
> $ ./Src/zsh -c 'set a b; echo ${##""}'
> zsh:1: bad substitution
>
> Worse, this is a regression:
>
> $ zsh -c 'set a b; echo ${##""}'
> 2
> $ rpm -q zsh
> zsh-4.3.10-5.fc14.x86_64

Not a surprise, this is due to

28889: ${##} should return the length of $#

-- 
Mikael Magnusson


^ permalink raw reply	[relevance 0%]

* Re: regression in ${##""}
  2011-06-03 18:55  0% ` Mikael Magnusson
@ 2011-06-03 19:16  3%   ` Eric Blake
  0 siblings, 0 replies; 200+ results
From: Eric Blake @ 2011-06-03 19:16 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1067 bytes --]

On 06/03/2011 12:55 PM, Mikael Magnusson wrote:
> On 3 June 2011 20:00, Eric Blake <eblake@redhat.com> wrote:
>> POSIX requires ${##""} to be parsed as ${parameter#word} with parameter
>> of # and word of "", which results in the output of $# with the shortest
>> prefix of the empty string removed (aka ${#}).  But current zsh.git
>> rejects this:
>>
>> $ ./Src/zsh -c 'set a b; echo ${##""}'
>> zsh:1: bad substitution
>>
>> Worse, this is a regression:
>>
>> $ zsh -c 'set a b; echo ${##""}'
>> 2
>> $ rpm -q zsh
>> zsh-4.3.10-5.fc14.x86_64
> 
> Not a surprise, this is due to
> 
> 28889: ${##} should return the length of $#

Before you go changing anything, though, I just filed a bug against POSIX:

http://austingroupbugs.net/view.php?id=457

which recommends that ${parameter#word} and ${parameter##word} be
changed to be unspecified if parameter is #; this relaxation in the
standard would permit current zsh behavior.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[relevance 3%]

* Re: 'continue' does not work in files sourced with dotcmd
       [not found]         ` <20110707144635.GA21272@gondor.apana.org.au>
@ 2011-07-07 15:18  5%       ` Eric Blake
  0 siblings, 0 replies; 200+ results
From: Eric Blake @ 2011-07-07 15:18 UTC (permalink / raw)
  To: Herbert Xu; +Cc: Taylan Ulrich B., dash, zsh-workers

[-- Attachment #1: Type: text/plain, Size: 2328 bytes --]

[adding zsh list]

On 07/07/2011 08:46 AM, Herbert Xu wrote:
> On Thu, Jul 07, 2011 at 07:26:50AM -0600, Eric Blake wrote:
>>
>> zsh rejected the continue statement (no containing loop within the
>> current scoping of the dot script), and as a result also aborted the
>> overall dot script - but in doing so, it properly emitted an error message.
> 
> dash does not warn in this case because it never prints a warning
> on continue anywhere.
> 
> This behaviour (not warning) is consistent with that of ksh.

Interesting!  And bash indeed behaves differently: in POSIX mode it is
silent, while in bash mode it issues a warning but does not affect exit
status - in line with the fact that in POSIX mode, bash obeys the rule
that if an application is diagnosing something to stderr, then the exit
status should be non-zero (and warnings don't affect exit status, hence
warnings should not be issued in POSIX mode).

Zsh is treating it as a syntax error, which is different from all the
other shells:

$ bash -c 'continue; echo $?'
bash: line 0: continue: only meaningful in a `for', `while', or `until' loop
0
$ bash --posix -c 'continue; echo $?'
0
$ dash -c 'continue; echo $?'
0
$ ksh -c 'continue; echo $?'
0
$ zsh -c 'emulate sh; continue; echo $?'
zsh:continue:1: not in while, until, select, or repeat loop
$ echo $?
1

POSIX states "If n is greater than the number of enclosing loops, the
outermost enclosing loop shall be exited."  But this is admittedly
silent on the behavior when there is no outermost enclosing loop, so I'm
not sure whether zsh treating this as a syntax error is appropriate.

Meanwhile, I still have to wonder about dash behavior - if dash is _not_
treating continue as a syntax error, then why is it aborting the dot
script?  Compare:

$ dash -c 'continue
echo $?'
0
$ dash -c 'printf "continue\\necho 0.\$?\\n" > f; for i in 1; do . ./f;
echo 1.$?; done; echo 2.$?'
1.0
2.0

In isolation, execution after an un-nested continue resumed with the
next statement, but in the dot script, execution after the "un-nested"
continue (at least, from the dot script perspective) aborted the dot
script, but without affecting exit status.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[relevance 5%]

* Re: syntax error with anonymous functions when an argument begins with (
@ 2011-07-31 14:17  4% Jilles Tjoelker
  0 siblings, 0 replies; 200+ results
From: Jilles Tjoelker @ 2011-07-31 14:17 UTC (permalink / raw)
  To: zsh-workers

> [people want stuff like () { echo yay } (a|b)]

In fact, the closing brace may validly be followed by certain keywords
in older zsh, for example

  if :; then () { echo hi; } else () { echo bye; } fi

prints "hi" in zsh 4.3.12 from FreeBSD ports.

If a regular function definition is used, like

  if :; then f() { echo hi; } else f() { echo bye; } fi; f

then the construct is POSIX compliant and works in all shells I tried
(not including patched versions of zsh).

The same applies if the function definition contains a different kind of
compound command such as if, which is unusual but POSIX compliant and
portable. For example, between two "fi" keywords a space suffices.

(On the other hand, if another command follows, such as ... fi; if ...,
a separator is required.)

So I think that unfortunately passing arguments to anonymous functions
requires an uglier syntax to avoid breaking compatibility. In any case,
placing a keyword after a closing brace that is not an anonymous
function's main command is valid and should be recognized as such.

-- 
Jilles Tjoelker


^ permalink raw reply	[relevance 4%]

* PATCH: zsh/datetime $EPOCHREALTIME
@ 2011-08-10 11:21  2% Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2011-08-10 11:21 UTC (permalink / raw)
  To: Zsh Hackers' List

I had a need for the current time to better than one second precision in
a shell function, which currently (as far as I can see) the shell
doesn't do.  It does for SECONDS, but that's not useful for comparison
with times used by the rest of the system.

Adding a floating point variable to zsh/datetime seems to be the natural
way to go.  It's called EPOCHREALTIME because it's using CLOCK_REALTIME,
which is a bit of arcane knowledge the shell user doesn't need to know,
and is tautologous since that by definition measures time since the
epoch, but since EPOCHSECONDS is already taken I had to make something
up.  The state of the art (POSIX) appears to be clock_gettime(), rather
than gettimeofday() that's used elsewhere in the shell, but it will
fall back if that's not available; we already assume gettimeofday() is
present so I haven't bothered testing for it.

Linux hides clock_gettime() in a library called librt.  I'm not sure how
standard that is, but it's another reason for the HAVE_... test.

Index: configure.ac
===================================================================
RCS file: /cvsroot/zsh/zsh/configure.ac,v
retrieving revision 1.136
diff -p -u -r1.136 configure.ac
--- configure.ac	14 May 2011 00:07:41 -0000	1.136
+++ configure.ac	10 Aug 2011 11:12:33 -0000
@@ -693,6 +693,8 @@ AC_CHECK_LIB(c, printf, [LIBS="$LIBS -lc
 
 AC_CHECK_LIB(m, pow)
 
+AC_CHECK_LIB(rt, clock_gettime)
+
 dnl Various features of ncurses depend on having the right header
 dnl (the system's own curses.h may well not be good enough).
 dnl So don't search for ncurses unless we found the header.
@@ -1170,7 +1172,7 @@ dnl need to integrate this function
 dnl AC_FUNC_STRFTIME
 
 AC_CHECK_FUNCS(strftime strptime mktime timelocal \
-	       difftime gettimeofday \
+	       difftime gettimeofday clock_gettime \
 	       select poll \
 	       readlink faccessx fchdir ftruncate \
 	       fstat lstat lchown fchown fchmod \
Index: Doc/Zsh/mod_datetime.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/mod_datetime.yo,v
retrieving revision 1.3
diff -p -u -r1.3 mod_datetime.yo
--- Doc/Zsh/mod_datetime.yo	17 Aug 2006 15:28:11 -0000	1.3
+++ Doc/Zsh/mod_datetime.yo	10 Aug 2011 11:12:33 -0000
@@ -30,9 +30,17 @@ in seconds if tt(-r) is given) to var(sc
 )
 enditem()
 
-The tt(zsh/datetime) module makes available one parameter:
+The tt(zsh/datetime) module makes available several parameters:
 
 startitem()
+vindex(EPOCHREALTIME)
+item(tt(EPOCHREALTIME))(
+A floating point value representing the number of seconds since
+the epoch.  The notional accuracy is to nanoseconds if the
+tt(clock_gettime) call is available and to microseconds otherwise,
+but in practice the range of double precision floating point and
+shell scheduling latencies may be significant effects.
+)
 vindex(EPOCHSECONDS)
 item(tt(EPOCHSECONDS))(
 An integer value representing the number of seconds since the
Index: Src/module.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/module.c,v
retrieving revision 1.42
diff -p -u -r1.42 module.c
--- Src/module.c	14 Jun 2010 11:57:08 -0000	1.42
+++ Src/module.c	10 Aug 2011 11:12:33 -0000
@@ -1081,6 +1081,11 @@ addparamdef(Paramdef d)
 	    pm->gsu.i = d->gsu ? (GsuInteger)d->gsu : &varinteger_gsu;
 	    break;
 
+	case PM_FFLOAT:
+	case PM_EFLOAT:
+	    pm->gsu.f = d->gsu;
+	    break;
+
 	case PM_ARRAY:
 	    pm->gsu.a = d->gsu ? (GsuArray)d->gsu : &vararray_gsu;
 	    break;
Index: Src/Modules/datetime.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/datetime.c,v
retrieving revision 1.22
diff -p -u -r1.22 datetime.c
--- Src/Modules/datetime.c	13 May 2011 18:12:06 -0000	1.22
+++ Src/Modules/datetime.c	10 Aug 2011 11:12:33 -0000
@@ -151,6 +151,28 @@ getcurrentsecs(UNUSED(Param pm))
     return (zlong) time(NULL);
 }
 
+static double
+getcurrentrealtime(UNUSED(Param pm))
+{
+#ifdef HAVE_CLOCK_GETTIME
+    struct timespec now;
+
+    if (clock_gettime(CLOCK_REALTIME, &now) < 0) {
+	zwarn("EPOCHREALTIME: unable to retrieve time: %e", errno);
+	return (double)0.0;
+    }
+
+    return (double)now.tv_sec + (double)now.tv_nsec * 1e-9;
+#else
+    struct timeval now;
+    struct timezone dummy_tz;
+
+    gettimeofday(&now, &dummy_tz);
+
+    return (double)now.tv_sec + (double)now.tv_usec * 1e-6;
+#endif
+}
+
 static struct builtin bintab[] = {
     BUILTIN("strftime",    0, bin_strftime,    2,   2, 0, "qrs:", NULL),
 };
@@ -158,9 +180,14 @@ static struct builtin bintab[] = {
 static const struct gsu_integer epochseconds_gsu =
 { getcurrentsecs, NULL, stdunsetfn };
 
+static const struct gsu_float epochrealtime_gsu =
+{ getcurrentrealtime, NULL, stdunsetfn };
+
 static struct paramdef patab[] = {
     SPECIALPMDEF("EPOCHSECONDS", PM_INTEGER|PM_READONLY,
 		 &epochseconds_gsu, NULL, NULL),
+    SPECIALPMDEF("EPOCHREALTIME", PM_FFLOAT|PM_READONLY,
+		 &epochrealtime_gsu, NULL, NULL)
 };
 
 static struct features module_features = {


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[relevance 2%]

* Re: How to misplace an entire pipeline
  @ 2011-09-12 13:51  3%               ` Alexey I. Froloff
  2011-09-12 16:03  3%                 ` Bart Schaefer
  0 siblings, 1 reply; 200+ results
From: Alexey I. Froloff @ 2011-09-12 13:51 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1572 bytes --]

On Sat, Aug 13, 2011 at 11:52:08AM -0700, Bart Schaefer wrote:
>  	if (findproc(pid, &jn, &pn, 0)) {
> +	    if (((jn->stat & STAT_BUILTIN) ||
> +		 (list_pipe && (jobtab[thisjob].stat & STAT_BUILTIN))) &&
> +		WIFSTOPPED(status) && WSTOPSIG(status) == SIGTSTP) {
> +		killjb(jn, SIGCONT);
> +		zwarn("job can't be suspended");
> +	    } else {
Sometimes, zsh segfaults here while doing B03print.ztst in POSIX
locale with thisjob equals to -1.  Not 100% reproducable, though.

$ LC_ALL=C zsh +Z -f ./ztst.zsh ./B03print.ztst
./B03print.ztst: starting.
[1]    20076 segmentation fault (core dumped)  LC_ALL=C zsh +Z -f ./ztst.zsh ./B03print.ztst
...

Core was generated by `zsh +Z -f ./ztst.zsh ./B03print.ztst'.
Program terminated with signal 11, Segmentation fault.
#0  0x00000000004745b1 in wait_for_processes () at signals.c:494
494                      (list_pipe && (jobtab[thisjob].stat & STAT_BUILTIN))) &&
(gdb) list
489              * Find the process and job containing this pid and
490              * update it.
491              */
492             if (findproc(pid, &jn, &pn, 0)) {
493                 if (((jn->stat & STAT_BUILTIN) ||
494                      (list_pipe && (jobtab[thisjob].stat & STAT_BUILTIN))) &&
495                     WIFSTOPPED(status) && WSTOPSIG(status) == SIGTSTP) {
496                     killjb(jn, SIGCONT);
497                     zwarn("job can't be suspended");
498                 } else {
(gdb) p thisjob
$1 = -1

-- 
Regards,    --
Sir Raorn.   --- http://thousandsofhate.blogspot.com/

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[relevance 3%]

* Re: How to misplace an entire pipeline
  2011-09-12 13:51  3%               ` Alexey I. Froloff
@ 2011-09-12 16:03  3%                 ` Bart Schaefer
  0 siblings, 0 replies; 200+ results
From: Bart Schaefer @ 2011-09-12 16:03 UTC (permalink / raw)
  To: zsh-workers

On Sep 12,  5:51pm, Alexey I. Froloff wrote:
}
} Sometimes, zsh segfaults here while doing B03print.ztst in POSIX
} locale with thisjob equals to -1.  Not 100% reproducable, though.

This is why I wondered in the original patch message:
: At this point list_pipe is true but the job receiving the stop signal
: is not in the process list of the current job (thisjob), so it's
: necessary to check whether the current job is a builtin.  Unless you
: can think of a case where thisjob would not correctly identify the
: foreground job at the time the signal is handled?

If I understand correctly, thisjob == -1 means there is no foreground
job.  I'm scratching my head over how list_pipe can be true when there
is no job in the foreground.  Could you please run

    ZTST_verbose=2 make TESTNUM=B03 check

to verify which test is causing the segmentation fault?  I suspect it's
the very last test with "print -lO ... | while read ..." but I'd like
to be sure.  (OTOH it may not be possible to reproduce the fault with
verbose output, but it's worth a try.)

I further suspect the signal is arriving during foo=$line[i] or some
other part of the inner loop where no actual command is being run, but
list_pipe remains true because of the outer loop.


^ permalink raw reply	[relevance 3%]

* Re: 4.3.13 changes
  @ 2011-09-25 22:48  3%     ` Bart Schaefer
  0 siblings, 0 replies; 200+ results
From: Bart Schaefer @ 2011-09-25 22:48 UTC (permalink / raw)
  To: Zsh Hackers' List

On Sep 12,  8:51pm, Peter Stephenson wrote:
} Subject: Re: 4.3.13 changes
}
} On Fri, 22 Jul 2011 13:13:49 +0200
} Nikolai Weibull <now@bitwi.se> wrote:
} > Can you please have a look at the '*:: :->file' problem [...] ?
} > The gist of it is that options don't complete after
} > arguments if you use "::" instead of ":".
} 
} I can't see any evidence not being able to complete options thereafter
} is deliberate.

I suspect the internals that support _arguments assume that you don't
mix arguments with options except when the arguments are those of a
particular option; that is, that a command always looks like

	command-name command-options command-arguments

where command-options may be zero or more sets of

	option option-arguments

I seem to recall discussions on the austin-group (POSIX) list about
the correctess of allowing more options to follow command-arguments, and
incompatibilities introduced by variant utilities which allow that.

The very fact that NORMARG is defined as "_the_ position of the first
normal argument" (my emphasis) seems to imply that comparguments does
not expect there to be more than one cluster of options, with all the
non-option arguments following it.


^ permalink raw reply	[relevance 3%]

* Next release
@ 2011-12-09 14:11  3% Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2011-12-09 14:11 UTC (permalink / raw)
  To: Zsh Hackers' List

As 4.3 seems to be pretty stable I'd like to release 5.0 shortly without
any further major changes.  The release number won't change until I
actually do that --- the policy is that version numbers always
increment, so 5.0_mumble comes after 5.0 --- although nearer the time
when everything looks ready I may bump the number to 4.99-test-X for the
final test releases just to indicate the intention.

The only significant thing to do for this is rework the source
documentation (NEWS, release notes, etc.) to show changes since 4.2
rather than within 4.3.  If anyone thinks they can make a good attempt
at this, they're welcome.  Otherwise, I will try to make a start on
that.

It would also be useful to document any bugs or major unexpected
restrictions that aren't already documented.  I'm aware of a couple of
weak areas in completion: correspondence classes don't handle multibyte
characters, and nested quoted completion where the contents of the
quotes are interpreted non-trivial (e.g. as a command line by a call to
another shell) are buggy.  This is *not* a call for feature requests.
Any undocumented derogations from POSIX behaviour can be added to the
FAQ.

If you think there's anything significant left to do, it would be a good
time either to do it or try to persuade someone else (good luck with
that).

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[relevance 3%]

* Re: Bug in sh emulation
  @ 2011-12-12 10:14  3%                 ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2011-12-12 10:14 UTC (permalink / raw)
  To: zsh-workers

On Mon, 12 Dec 2011 10:01:00 +0000
Peter Stephenson <Peter.Stephenson@csr.com> wrote:
> So I think (i) the attachtty() works in the subprocess so long as
> SIGTTOU is blocked

POSIX is explicit this works:

  Attempts to use tcsetpgrp() from a process which is a member of a
  background process group on a fildes associated with its controlling
  terminal shall cause the process group to be sent a SIGTTOU signal. If
  the calling process is blocking or ignoring SIGTTOU signals, the process
  shall be allowed to perform the operation, and no signal is sent.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[relevance 3%]

* Re: bug
  @ 2011-12-21 22:32 12%   ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
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	[relevance 12%]

* '>;' redirection operator [was: [1003.1(2008)/Issue 7 0000530]: Support in-place editing in sed  (-iEXTENSION)]
       [not found]     <201112221539.pBMFdlaj011933@penguin.research.att.com>
@ 2011-12-22 21:03  3% ` Eric Blake
    0 siblings, 1 reply; 200+ results
From: Eric Blake @ 2011-12-22 21:03 UTC (permalink / raw)
  To: David Korn, austin-group-l; +Cc: Bash - Bug, zsh-workers, dash, miros-discuss

[-- Attachment #1: Type: text/plain, Size: 2100 bytes --]

[cc'ing bash, dash, mksh, and zsh developers; feel free to avoid
cross-posted replies on content not relevant to all the groups]

On 12/22/2011 08:39 AM, David Korn wrote:
> Subject: Re: Re: [1003.1(2008)/Issue 7 0000530]: Support in-place editing in sed  (-iEXTENSION)
> --------
> 
> There are many commands other than sed that want the output to replace
> an input file.  That is why I added the >; redirection operator to ksh93.
> 
> With >; you can do
> 	sed -e s/foo/bar/ file >; file
> to do in place sed.  The >; operator generates the output in a temporary file
> and moves the file to the original file only if the command terminates
> with 0 exit status.

I agree that engineering a single fix into the shell that can apply to
multiple situations, rather than chasing down a set of applications to
add an in-place editing option to each, is a much more flexible and
powerful approach.  Can we get buy-in from other shell developers to
support '>;' as an atomic temp-file replacement-on-success idiom, if
POSIX were to standardize the existing practice of ksh93 as the basis?

I assume on the ksh implementation that the temp file is discarded if
the command (simple or compound) feeding the redirection failed?  If the
redirection is used on a simple command, is there any shorthand for
specifying that the destination name on success also be fed as an
argument to the command, to avoid the redundancy of having to type
'file' both before and after the '>;' operator?  I assume that this is
like any other redirection operator, where an optional fd number can be
prepended, as in '2>; file' to collect stderr and overwrite file on
success?  What happens if there is more than one '>;' redirection in the
same command, and both target the same end file (whether or not by the
same file name)?  What happens if the command succeeds, but the rename
of the temp file to the destination fails?  Are there clobber ('>|') or
append ('>>') variants?

-- 
Eric Blake   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 620 bytes --]

^ permalink raw reply	[relevance 3%]

* Re: '>;' redirection operator
  @ 2011-12-22 23:34  4%     ` Thorsten Glaser
  0 siblings, 0 replies; 200+ results
From: Thorsten Glaser @ 2011-12-22 23:34 UTC (permalink / raw)
  To: Eric Blake, Bruce Korb
  Cc: David Korn, austin-group-l, Bash - Bug, zsh-workers, dash, miros-discuss

Eric Blake dixit:

>powerful approach.  Can we get buy-in from other shell developers to
>support '>;' as an atomic temp-file replacement-on-success idiom, if

Urgh, PLEASE NOT!

People complain about the readability of code enough already, and as
practice shows, things like [[ have been around and nobody uses them
anyway (often using just POSIX, but not even knowing – myself included
– that POSIX sh has $((…))⁺; or even using less-than-POSIX, e.g. in
autoconf, which means that anything we were to introduce now would not
be used in the places where it counts anyway, for compatibility).

⁺) Reminds me to write to the list about that. Buried in dayjob work
   atm though. Expect something about that next year.


Bruce Korb dixit:

> slide on slippery slopes.  Shells can always add some useful builtins:
>
>   sh_move_if_changed
>   sh_save_on_success
>   sh_save_on_failure

In mksh, practice is to keep such things out of the core code and
optionally put it into ~/.mkshrc instead. The pushd/popd/dirs code
is a prime example of it. Also, this way, the shell is extended in
shell instead of in C. (I’ve seen the C201x draft this week. This
drives home _that_ point even better. That’s bloat, not C any more.)

Many languages have standard libraries written in that language
itself, for better portability and easier maintenance, so I’d say
do it like that. Heck, https://evolvis.org/projects/shellsnippets/
(disclaimer: a pet project of a coworker and me) is waiting for
more contributions. (Hosted at my current employer, that’s why I
untypically-for-me chose git so nobody needs to fear they could
take it down.)


Oh, and: sed. has. no. -i. option. either. Please. There’s a
perfectly fine ed, man! man ed! for that.

bye,
//mirabilos
-- 
FWIW, I'm quite impressed with mksh interactively. I thought it was much
*much* more bare bones. But it turns out it beats the living hell out of
ksh93 in that respect. I'd even consider it for my daily use if I hadn't
wasted half my life on my zsh setup. :-) -- Frank Terbeck in #!/bin/mksh


^ permalink raw reply	[relevance 4%]

* Re: $pipestatus broken?
  @ 2011-12-23 10:49  5%     ` Frank Terbeck
  0 siblings, 0 replies; 200+ results
From: Frank Terbeck @ 2011-12-23 10:49 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer wrote:
[...]
> With that loop, I get a single "1" 100% of the time unless I attach to
> the process with GDB, in which case it becomes random.


It's correct that this should output "0 0", though, right? With the right
hand side of the pipe being a loop, the last return code of the loop is
return code of the loop, correct?

If that's correct, the following adds a new test, that checks if the
problem happens on a given system (actually, if the problem appears at
least once in 2048 test runs - which has been triggered every time on my
test system so far). I didn't see anything about tests that are *expected*
to fail in `B01cd.ztst', so this makes the test suite fail at least once.
Therefore, I don't know if adding this is a good idea or not.

Regards, Frank


diff --git a/Test/A04redirect.ztst b/Test/A04redirect.ztst
index 3911b06..d349f33 100644
--- a/Test/A04redirect.ztst
+++ b/Test/A04redirect.ztst
@@ -441,3 +441,13 @@
 0:failed assignment on non-posix-special, POSIX_BUILTINS
 >output
 ?zsh: read-only variable: foo
+
+  repeat 2048; do (: | while read a; do
+                           :
+                       done;
+                       print "${pipestatus[@]}")
+  done | sort -u
+0:Check whether `$pipestatus[]' behaves.
+>0 0
+F:This test checks for a bug in `$pipestatus[]' handling.  If it breaks then
+F:the bug is still there or it reappeared. See workers-29973 for details.


^ permalink raw reply	[relevance 5%]

* Re: Bug with sh emulation; shouldn't KSH_TYPESET be set?
  @ 2012-01-30 20:43  5% ` Frank Terbeck
  2012-01-30 21:46  0%   ` Felipe Contreras
  2012-01-31  9:43  3% ` Peter Stephenson
  1 sibling, 1 reply; 200+ results
From: Frank Terbeck @ 2012-01-30 20:43 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: zsh-workers

Felipe Contreras wrote:
[...]
> 	local t=$(echo foo --bar)
[...]
> But not in zsh, with sh emulation. Enabling KSH_TYPESET makes it work.
>
> Shouldn't it be enabled with sh emulation?
>
> BTW. What exactly is 'emulate sh' supposed to emulate? I would like to
> run that shell to check for compatibility issues, and apparently it's
> not bash.

"emulate sh" is POSIX shell emulation (we did amend this mode in the
past to work as much as possible as POSIX describes). Neither typeset
nor local are part of POSIX (at least not SUSv3 - I don't know about
v4).

So, I don't think it should be enabled.

FWIW, dash and posh behave like zsh's sh-mode here. Ksh93 doesn't work
at all, because it has no `local' (only typeset). Mksh, pdksh and bash
work like KSH_TYPESET was set in zsh.

Regards, Frank


^ permalink raw reply	[relevance 5%]

* Re: Bug with sh emulation; shouldn't KSH_TYPESET be set?
  2012-01-30 20:43  5% ` Frank Terbeck
@ 2012-01-30 21:46  0%   ` Felipe Contreras
  2012-01-30 22:17  4%     ` Frank Terbeck
  2012-01-30 22:20  0%     ` Vincent Lefevre
  0 siblings, 2 replies; 200+ results
From: Felipe Contreras @ 2012-01-30 21:46 UTC (permalink / raw)
  To: Frank Terbeck; +Cc: zsh-workers, Felipe Contreras

On Mon, Jan 30, 2012 at 10:43 PM, Frank Terbeck <ft@bewatermyfriend.org> wrote:
> Felipe Contreras wrote:
> [...]
>>       local t=$(echo foo --bar)
> [...]
>> But not in zsh, with sh emulation. Enabling KSH_TYPESET makes it work.
>>
>> Shouldn't it be enabled with sh emulation?
>>
>> BTW. What exactly is 'emulate sh' supposed to emulate? I would like to
>> run that shell to check for compatibility issues, and apparently it's
>> not bash.
>
> "emulate sh" is POSIX shell emulation (we did amend this mode in the
> past to work as much as possible as POSIX describes). Neither typeset
> nor local are part of POSIX (at least not SUSv3 - I don't know about
> v4).
>
> So, I don't think it should be enabled.

But it wouldn't hurt either, right? It would be nice to have some
'bash' emulation mode, but since there isn't any, why not enable this
harmless option?

> FWIW, dash and posh behave like zsh's sh-mode here. Ksh93 doesn't work
> at all, because it has no `local' (only typeset). Mksh, pdksh and bash
> work like KSH_TYPESET was set in zsh.

Hmm, I see, but there's no bash emulation mode =/

I guess it's time to compare the differences between ksh and sh
emulation to see which is closer.

-- 
Felipe Contreras


^ permalink raw reply	[relevance 0%]

* Re: Bug with sh emulation; shouldn't KSH_TYPESET be set?
  2012-01-30 21:46  0%   ` Felipe Contreras
  2012-01-30 22:17  4%     ` Frank Terbeck
@ 2012-01-30 22:20  0%     ` Vincent Lefevre
  1 sibling, 0 replies; 200+ results
From: Vincent Lefevre @ 2012-01-30 22:20 UTC (permalink / raw)
  To: zsh-workers

On 2012-01-30 23:46:46 +0200, Felipe Contreras wrote:
> On Mon, Jan 30, 2012 at 10:43 PM, Frank Terbeck <ft@bewatermyfriend.org> wrote:
> > Felipe Contreras wrote:
> > [...]
> >>       local t=$(echo foo --bar)
> > [...]
> >> But not in zsh, with sh emulation. Enabling KSH_TYPESET makes it work.
> >>
> >> Shouldn't it be enabled with sh emulation?
> >>
> >> BTW. What exactly is 'emulate sh' supposed to emulate? I would like to
> >> run that shell to check for compatibility issues, and apparently it's
> >> not bash.
> >
> > "emulate sh" is POSIX shell emulation (we did amend this mode in the
> > past to work as much as possible as POSIX describes). Neither typeset
> > nor local are part of POSIX (at least not SUSv3 - I don't know about
> > v4).
> >
> > So, I don't think it should be enabled.
> 
> But it wouldn't hurt either, right?

Not sure. What if you have some executable named "local" in the path?

> It would be nice to have some 'bash' emulation mode, but since there
> isn't any, why not enable this harmless option?

Instead of changing options for sh emulation, why not add a 'bash'
emulation mode, even though it may not be perfect (it would be better
than sh anyway).

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


^ permalink raw reply	[relevance 0%]

* Re: Bug with sh emulation; shouldn't KSH_TYPESET be set?
  2012-01-30 21:46  0%   ` Felipe Contreras
@ 2012-01-30 22:17  4%     ` Frank Terbeck
  2012-01-30 22:20  0%     ` Vincent Lefevre
  1 sibling, 0 replies; 200+ results
From: Frank Terbeck @ 2012-01-30 22:17 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: zsh-workers

Felipe Contreras wrote:
> Frank Terbeck <ft@bewatermyfriend.org> wrote:
[...]
>> So, I don't think it should be enabled.
>
> But it wouldn't hurt either, right? It would be nice to have some
> 'bash' emulation mode, but since there isn't any, why not enable this
> harmless option?

I'm unsure (personally, I wouldn't mind), as to whether the
argument-handling semantics of a random builtin can be changed with
POSIX in mind. Maybe someone with deeper understanding of the standard
can shed some light here.

I'd just do

    local foo="$(bar --baz)"

and be done with it. That should be portable over pretty much every
bourne-line shell that supports $(...) and `local',

>> FWIW, dash and posh behave like zsh's sh-mode here. Ksh93 doesn't work
>> at all, because it has no `local' (only typeset). Mksh, pdksh and bash
>> work like KSH_TYPESET was set in zsh.
>
> Hmm, I see, but there's no bash emulation mode =/
>
> I guess it's time to compare the differences between ksh and sh
> emulation to see which is closer.

Unsure, due to fairly limited knowledge of bash's extensions to POSIX.

Regards, Frank

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925


^ permalink raw reply	[relevance 4%]

* Re: Bug with sh emulation; shouldn't KSH_TYPESET be set?
    2012-01-30 20:43  5% ` Frank Terbeck
@ 2012-01-31  9:43  3% ` Peter Stephenson
  1 sibling, 0 replies; 200+ results
From: Peter Stephenson @ 2012-01-31  9:43 UTC (permalink / raw)
  To: zsh-workers

On Mon, 30 Jan 2012 22:21:52 +0200
Felipe Contreras <felipe.contreras@gmail.com> wrote:
> This works on bash
> 
> ---
> _test ()
> {
> 	local t=$(echo foo --bar)
> }
> _test
> ---
> 
> But not in zsh, with sh emulation. Enabling KSH_TYPESET makes it work.
> 
> Shouldn't it be enabled with sh emulation?

Possibly --- I seem to remember there's a change request in POSIX to do
with this kind of stuff, but I'm not sure if it covered this case.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[relevance 3%]

* Re: Bug with bash emulation regarding ':'
  @ 2012-02-05 20:11  2%       ` Peter Stephenson
  2012-02-05 21:21  3%         ` Bart Schaefer
    0 siblings, 2 replies; 200+ results
From: Peter Stephenson @ 2012-02-05 20:11 UTC (permalink / raw)
  To: zsh-workers

On Wed, 01 Feb 2012 08:29:29 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Jan 31,  8:29pm, Bart Schaefer wrote:
> }
> } 2657               opts[SHWORDSPLIT] = 0;
> } 2658               multsub(&val, 0, NULL, &isarr, NULL);
> } 
> } The problem is that we want to suppress any further splitting in the
> } current shell, but when we enter the subshell for $(...) it should
> } revert to the original setting.
> 
> I can verify this by defining _test with "emulate sh -c ..." so that
> the SHWORDSPLIT option becomes sticky in that function.
> 
> I'm still not sure what to do about it.  The question goes a bit deeper
> in that there are several ways that shell code might get invoked during
> stringsubst() -- the (e::) glob flag, dynamic directory names, etc. --
> and presumably those should also all use the original splitting style,
> whereas simple nested expansions should not.

Realistically, I think we either have to bite the bullet and find
something ugly that works or forget about it entirely.

How about this for the original problem?  It's at least a simple change,
tied to one documented C variable.  It doesn't address the related areas
you mentioned, but I think those are less important, because they don't
affect Bourne/POSIX emulation and though in principle we should
certainly make all combinations of features behave consistently, in
practice I'm not keen on encouraging native zsh programmers to use
arbitrary option settings.  (Actually, I don't really want to think
about what 'a native zsh programmer' might mean...)

There's still a difference from bash, where the output includes newlines
(i.e. the literal function output), whereas zsh turns the newlines into
spaces.  We use IFS to split the value returned by the function, but
bash doesn't.  Defining an IFS without $'\n' gives us what bash does,
but that's not the difference since bash has $'\n' in the default IFS,
too.  So this difference is somewhere in word splitting for parameter
substitution, too.  I haven't looked into the details, but I would guess
that in bash

: ${...:=$(...)}

does what we would do with

: ${...:="$(...)"}

However, KSH_TYPESET doesn't change this (and as noted recently is not
on for bash anyway).  I would guess KSH_TYPESET *should* have that
effect, and am inclining to the view turning it on for SH mode would be
sensible.  So more investigation is needed.  Feel free.

Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.207
diff -p -u -r1.207 exec.c
--- Src/exec.c	16 Jan 2012 22:14:11 -0000	1.207
+++ Src/exec.c	5 Feb 2012 19:39:50 -0000
@@ -3724,6 +3724,19 @@ getoutput(char *cmd, int qt)
     redup(pipes[1], 1);
     entersubsh(ESUB_PGRP|ESUB_NOMONITOR);
     cmdpush(CS_CMDSUBST);
+    /*
+     * Special case if this is a command substitution called
+     * recursively from parameter substitution.  In that
+     * case we've tampered with SHWORDSPLIT in order to fix
+     * up parameter substitution arguments.  However, here
+     * we're back at command level, so we need to restore
+     * it to whatever it was before.  Then we'll pretend
+     * we never tampered with it.
+     */
+    if (real_shwordsplit != -1) {
+	opts[SHWORDSPLIT] = real_shwordsplit;
+	real_shwordsplit = -1;
+    }
     execode(prog, 0, 1, "cmdsubst");
     cmdpop();
     close(1);
Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.130
diff -p -u -r1.130 subst.c
--- Src/subst.c	21 Dec 2011 22:39:28 -0000	1.130
+++ Src/subst.c	5 Feb 2012 19:39:50 -0000
@@ -35,6 +35,22 @@
 /**/
 char nulstring[] = {Nularg, '\0'};
 
+/*
+ * The real value of the option SH_WORD_SPLIT.
+ * We need this because of the following hierarchy:
+ * - paramsubst alters SH_WORD_SPLIT
+ * - multsub() does some substitution with SH_WORD_SPLIT off
+ * - a nested $(...) executes commands.  This should reflect
+ *   the original value of SH_WORD_SPLIT.
+ *
+ * -1 indicates this isn't in use.
+ *
+ * Even so, yuk.  This will be done properly in the object-oriented rewrite
+ * of zsh currently scheduled for the year 3712, weather permitting.
+ */
+/**/
+int real_shwordsplit = -1;
+
 /* Do substitutions before fork. These are:
  *  - Process substitution: <(...), >(...), =(...)
  *  - Parameter substitution
@@ -213,7 +229,16 @@ stringsubst(LinkList list, LinkNode node
 		setdata(node, (void *) str3);
 		continue;
 	    } else {
+		/*
+		 * Save and restore the value of SHWORDSPLIT.
+		 * See notes on real_shwordsplit above.
+		 * The restore so that we don't use real_shwordsplit
+		 * outside code called from paramsubst().
+		 */
+		char old_shwordsplit;
+		old_shwordsplit = real_shwordsplit = opts[SHWORDSPLIT];
 		node = paramsubst(list, node, &str, qt, ssub);
+		real_shwordsplit = old_shwordsplit;
 		if (errflag || !node)
 		    return NULL;
 		str3 = (char *)getdata(node);
Index: Test/D04parameter.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D04parameter.ztst,v
retrieving revision 1.60
diff -p -u -r1.60 D04parameter.ztst
--- Test/D04parameter.ztst	17 Aug 2011 19:00:10 -0000	1.60
+++ Test/D04parameter.ztst	5 Feb 2012 19:39:51 -0000
@@ -255,6 +255,20 @@
 >two
 >words
 
+  (setopt shwordsplit # ensure this doesn't get set in main shell...
+  test_splitting ()
+  {
+    array="one two three"
+    for e in $array; do
+      echo "'$e'"
+    done
+  }
+  test_split_var=
+  : ${test_split_var:=$(test_splitting)}
+  echo "_${test_split_var}_")
+0:SH_WORD_SPLIT inside $(...) inside ${...}
+>_'one' 'two' 'three'_
+
   print -l "${(f)$(print first line\\nsecond line\\nthird line)}"
 0:${(f)$(...)}
 >first line

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


^ permalink raw reply	[relevance 2%]

* Re: Bug with bash emulation regarding ':'
  2012-02-05 20:11  2%       ` Peter Stephenson
@ 2012-02-05 21:21  3%         ` Bart Schaefer
    1 sibling, 0 replies; 200+ results
From: Bart Schaefer @ 2012-02-05 21:21 UTC (permalink / raw)
  To: zsh-workers

On Feb 5,  8:11pm, Peter Stephenson wrote:
}
} How about this for the original problem?  It's at least a simple change,
} tied to one documented C variable.  It doesn't address the related areas
} you mentioned, but I think those are less important, because they don't
} affect Bourne/POSIX emulation

Seems reasonable to me.  I was hunting for a way to do it without adding
another global, but what you've done is probably the most expedient.

(I wonder if changing the boolean "split" parameter to multsub() into a
set of bitflags would suffice.)

I don't have anything more to add on the rest of this discussion, a this
point ...


^ permalink raw reply	[relevance 3%]

* Re: Bug with bash emulation regarding ':'
@ 2012-02-10 11:08  4% Jilles Tjoelker
  0 siblings, 0 replies; 200+ results
From: Jilles Tjoelker @ 2012-02-10 11:08 UTC (permalink / raw)
  To: Zsh Hackers' List, Peter Stephenson

> [zsh performs word splitting on ${...:=$(...)}]

It seems strange to perform word splitting on word in ${var=word}
because a single word is required to assign to var. Indeed, zsh pastes
the resulting words back together to a single word to assign.

Historically, there have been two ways to perform word splitting here:
either by expanding the construct as ${var-word} or by expanding $var
after assignment. POSIX requires the latter. This implies that quoting
characters inside word does not prevent word splitting and pathname
generation. (Quoting the entire expansion does.)

In either case, if assignment takes place, the assigned value is the
expanded value of word with quote removal performed on it. (POSIX lacked
the detail of quote removal, formally requiring the assigned value to
retain the quoting characters; an interpretation has been issued.)

-- 
Jilles Tjoelker


^ permalink raw reply	[relevance 4%]

* Re: Bug with bash emulation regarding ':'
  @ 2012-02-14 23:30  3%           ` Chet Ramey
  2012-02-15 12:36  0%             ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Chet Ramey @ 2012-02-14 23:30 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers, chet.ramey

On 2/14/12 12:41 PM, Peter Stephenson wrote:
> On Sun, 5 Feb 2012 20:11:33 +0000
> Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
>> There's still a difference from bash...
> 
> namely that in bash
> 
>   test_split_var=
>   : ${test_split_var:=$(echo "one
>   two
>   three")}
>   echo "$test_split_var"
> 
> outputs the original string, with no splitting on the returned variable
> from the command substitution.  zsh does split the command substitution
> before the assignment when in sh emulation (the same split array that
> later gets substituted onto the command line), so the newlines turn into
> spaces when the string is joined up again.

Bash doesn't split word in ${parameter:OPword} because Posix says not
to:

"word shall be subjected to tilde expansion, parameter expansion, command
substitution, and arithmetic expansion."

A later interpretation adds quote removal to the list.

> 
> However,
> 
>   test_split_var=
>   echo ${test_split_var:=$(echo "one
>   two
>   three")}
> 
> does perform splitting, evidently after the assignment has been done
> because the value assigned to test_split_var is (of course) as before.

The same thing actually happens in both examples; you just look at the
results of the expansion in the second case.  The rhs gets expanded,
but not split, assigned to test_split_var, and that becomes the result
of the parameter expansion.  Those results get split, since the param
expansion doesn't occur within double quotes, and passed to `:' and echo
as arguments.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


^ permalink raw reply	[relevance 3%]

* printf %<n>s in UTF-8 is not always POSIX-compliant
@ 2012-02-15  2:15 10% Vincent Lefevre
  2012-02-15  8:14  5% ` Bart Schaefer
  0 siblings, 1 reply; 200+ results
From: Vincent Lefevre @ 2012-02-15  2:15 UTC (permalink / raw)
  To: zsh-workers

Hi,

I've reported the following bug:

  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=659932

In UTF-8 locales:

xvii% printf ".%2s.\n" é
. é.
xvii% emulate sh
xvii% printf ".%2s.\n" é
.é.
xvii% emulate ksh       
xvii% printf ".%2s.\n" é
. é.

It is correct in sh mode (according to POSIX[*]), but not in ksh mode,
which should also follow the POSIX behavior. What about zsh mode?

[*] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html
and
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap05.html#tag_05
for %<n>s.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


^ permalink raw reply	[relevance 10%]

* Re: printf %<n>s in UTF-8 is not always POSIX-compliant
  2012-02-15  2:15 10% printf %<n>s in UTF-8 is not always POSIX-compliant Vincent Lefevre
@ 2012-02-15  8:14  5% ` Bart Schaefer
  2012-02-15  9:10  5%   ` Vincent Lefevre
                     ` (2 more replies)
  0 siblings, 3 replies; 200+ results
From: Bart Schaefer @ 2012-02-15  8:14 UTC (permalink / raw)
  To: zsh-workers

On Feb 15,  3:15am, Vincent Lefevre wrote:
}
} In UTF-8 locales:
} 
} xvii% printf ".%2s.\n" é
} .é.

Am I understanding correctly that the intent here is that é is a two-
byte character so %2s should print the two literal bytes, rather than
print the single logical character in a field two logical characters
wide?

The reason it's different for "emulate sh" is that sh emulation turns
off all support for multibyte characters (unsetopt multibyte).  If you
were to do
	emulate sh -c 'setopt multibyte; printf ".%2s.\n" é'
then I believe you'd see the same behavior as with "emulate ksh".

As to whether it's correct ... I think I'd prefer the logical rather
than literal interpretation, but it'll be difficult [or a hack that
requires looking at the global emulation state, so it won't be possible
to reproduce it with plain setopts] to turn off multibyte processing in
printf for ksh emulation but not native zsh.


^ permalink raw reply	[relevance 5%]

* Re: printf %<n>s in UTF-8 is not always POSIX-compliant
  2012-02-15  8:14  5% ` Bart Schaefer
@ 2012-02-15  9:10  5%   ` Vincent Lefevre
  2012-02-15 11:05  8%   ` Peter Stephenson
  2012-02-15 14:42  9%   ` Oliver Kiddle
  2 siblings, 0 replies; 200+ results
From: Vincent Lefevre @ 2012-02-15  9:10 UTC (permalink / raw)
  To: zsh-workers

On 2012-02-15 00:14:12 -0800, Bart Schaefer wrote:
> On Feb 15,  3:15am, Vincent Lefevre wrote:
> }
> } In UTF-8 locales:
> } 
> } xvii% printf ".%2s.\n" é
> } .é.
> 
> Am I understanding correctly that the intent here is that é is a two-
> byte character so %2s should print the two literal bytes, rather than
> print the single logical character in a field two logical characters
> wide?

Yes, the number is the size in bytes, not in characters. I think
that the intent is to deal with internal structures (e.g. with
file formats where some fields have a fixed or limited size, and
the same syntax can be used in C to avoid buffer overflows).
Note that there's the same problem with:

xvii% printf ".%.3s.\n" éabcd
.éab.
xvii% emulate ksh
xvii% printf ".%.3s.\n" éabcd
.éab.
xvii% emulate sh             
xvii% printf ".%.3s.\n" éabcd
.éa.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


^ permalink raw reply	[relevance 5%]

* Re: printf %<n>s in UTF-8 is not always POSIX-compliant
  2012-02-15  8:14  5% ` Bart Schaefer
  2012-02-15  9:10  5%   ` Vincent Lefevre
@ 2012-02-15 11:05  8%   ` Peter Stephenson
  2012-02-15 11:53  5%     ` Vincent Lefevre
  2012-02-15 14:42  9%   ` Oliver Kiddle
  2 siblings, 1 reply; 200+ results
From: Peter Stephenson @ 2012-02-15 11:05 UTC (permalink / raw)
  To: zsh-workers

On Wed, 15 Feb 2012 00:14:12 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> The reason it's different for "emulate sh" is that sh emulation turns
> off all support for multibyte characters (unsetopt multibyte).  If you
> were to do
> 	emulate sh -c 'setopt multibyte; printf ".%2s.\n" é'
> then I believe you'd see the same behavior as with "emulate ksh".
> 
> As to whether it's correct ... I think I'd prefer the logical rather
> than literal interpretation, but it'll be difficult [or a hack that
> requires looking at the global emulation state, so it won't be possible
> to reproduce it with plain setopts] to turn off multibyte processing in
> printf for ksh emulation but not native zsh.

This sounds correct... We've never promised ksh mode would be a complete
representation of ksh anyway.  I realise that, for historical reasons
related to standards rather than zsh, you'd expect ksh mode to be POSIX
compatible, but actually we don't tend to bother because ksh mode isn't
that widely used and so doesn't get a lot of attention (I certainly
never use it).  If you really want compatibility native zsh mode or sh
mode are the sensible choices.

So probably the fix is to spread fear, uncertainty and doubt about ksh
mode.  I'll start right now.

If there is a hard-core ksh mode user who'd like to maintain it, of
course, that's another story.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[relevance 8%]

* Re: printf %<n>s in UTF-8 is not always POSIX-compliant
  2012-02-15 11:05  8%   ` Peter Stephenson
@ 2012-02-15 11:53  5%     ` Vincent Lefevre
  2012-02-15 12:09  5%       ` Frank Terbeck
  0 siblings, 1 reply; 200+ results
From: Vincent Lefevre @ 2012-02-15 11:53 UTC (permalink / raw)
  To: zsh-workers

On 2012-02-15 11:05:19 +0000, Peter Stephenson wrote:
> This sounds correct... We've never promised ksh mode would be a complete
> representation of ksh anyway.  I realise that, for historical reasons
> related to standards rather than zsh, you'd expect ksh mode to be POSIX
> compatible, but actually we don't tend to bother because ksh mode isn't
> that widely used and so doesn't get a lot of attention (I certainly
> never use it).  If you really want compatibility native zsh mode or sh
> mode are the sensible choices.

The problem is that on some machines, one has a symlink ksh -> zsh.
If I type ksh or run a script with #!/usr/bin/ksh, I expect this to
behave as a real ksh.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


^ permalink raw reply	[relevance 5%]

* Re: printf %<n>s in UTF-8 is not always POSIX-compliant
  2012-02-15 11:53  5%     ` Vincent Lefevre
@ 2012-02-15 12:09  5%       ` Frank Terbeck
  2012-02-15 12:23  8%         ` Peter Stephenson
  2012-02-15 12:42  5%         ` Vincent Lefevre
  0 siblings, 2 replies; 200+ results
From: Frank Terbeck @ 2012-02-15 12:09 UTC (permalink / raw)
  To: zsh-workers

Vincent Lefevre wrote:
> On 2012-02-15 11:05:19 +0000, Peter Stephenson wrote:
>> This sounds correct... We've never promised ksh mode would be a complete
>> representation of ksh anyway.
[...]
> The problem is that on some machines, one has a symlink ksh -> zsh.
> If I type ksh or run a script with #!/usr/bin/ksh, I expect this to
> behave as a real ksh.

Frankly, that would be the vendor's fault then. There are many *MANY*
ksh implementations, that make for a reasonable link target (ksh93,
pdksh or mksh - to name just a few). Zsh is not one of them.

IMHO, ksh-emulation is a little bit like csh emulation: It's meant to
make users with ksh background feel more "at home", not as a strict
bug-for-bug emulation.

Regards, Frank


^ permalink raw reply	[relevance 5%]

* Re: printf %<n>s in UTF-8 is not always POSIX-compliant
  2012-02-15 12:09  5%       ` Frank Terbeck
@ 2012-02-15 12:23  8%         ` Peter Stephenson
  2012-02-15 12:42  5%         ` Vincent Lefevre
  1 sibling, 0 replies; 200+ results
From: Peter Stephenson @ 2012-02-15 12:23 UTC (permalink / raw)
  To: zsh-workers

On Wed, 15 Feb 2012 13:09:17 +0100
Frank Terbeck <ft@bewatermyfriend.org> wrote:
> IMHO, ksh-emulation is a little bit like csh emulation: It's meant to
> make users with ksh background feel more "at home", not as a strict
> bug-for-bug emulation.

That's basically how I see it.  It doesn't mean we can't do better --- but
I don't think we can do better by people who don't really use the mode
initiating random tweaks in the hope that the world becomes a better
place.  We really would need someone who is in a position to take a
global view of how changes to the mode affect the emulation.

This is a rather different case from POSIX emulation, where there's (i)
a standard (ii) quite a lot of visibility of what the effect of changes
are.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[relevance 8%]

* Re: Bug with bash emulation regarding ':'
  2012-02-14 23:30  3%           ` Chet Ramey
@ 2012-02-15 12:36  0%             ` Peter Stephenson
    0 siblings, 1 reply; 200+ results
From: Peter Stephenson @ 2012-02-15 12:36 UTC (permalink / raw)
  To: zsh-workers; +Cc: chet.ramey

On Tue, 14 Feb 2012 18:30:21 -0500
Chet Ramey <chet.ramey@case.edu> wrote:
> Bash doesn't split word in ${parameter:OPword} because Posix says not
> to:
>..
> The same thing actually happens in both examples; you just look at the
> results of the expansion in the second case.  The rhs gets expanded,
> but not split, assigned to test_split_var, and that becomes the result
> of the parameter expansion.  Those results get split, since the param
> expansion doesn't occur within double quotes, and passed to `:' and echo
> as arguments.

Thanks, that's along the lines I supposed but more detailed.

To get this behaviour in zsh we'd have to do the assignment earlier
than we currently do.  The assignments around line 2705 of subst.c would
need to buried inside multsub() in such a way that any splitting owing to
the top-level settings happened later --- which is very difficult since
we rely on the nested substitution to do the splitting we see in the
top-level parameter expansion because it parses it so knows how to split
it.  Whether there are remaining gotchas owing to ordering I don't know.

Yuk.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[relevance 0%]

* Re: printf %<n>s in UTF-8 is not always POSIX-compliant
  2012-02-15 12:09  5%       ` Frank Terbeck
  2012-02-15 12:23  8%         ` Peter Stephenson
@ 2012-02-15 12:42  5%         ` Vincent Lefevre
  1 sibling, 0 replies; 200+ results
From: Vincent Lefevre @ 2012-02-15 12:42 UTC (permalink / raw)
  To: zsh-workers

On 2012-02-15 13:09:17 +0100, Frank Terbeck wrote:
> Frankly, that would be the vendor's fault then. There are many *MANY*
> ksh implementations, that make for a reasonable link target (ksh93,
> pdksh or mksh - to name just a few). Zsh is not one of them.

OK, bug reported.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


^ permalink raw reply	[relevance 5%]

* Re: printf %<n>s in UTF-8 is not always POSIX-compliant
  2012-02-15  8:14  5% ` Bart Schaefer
  2012-02-15  9:10  5%   ` Vincent Lefevre
  2012-02-15 11:05  8%   ` Peter Stephenson
@ 2012-02-15 14:42  9%   ` Oliver Kiddle
  2012-02-15 14:56  5%     ` Vincent Lefevre
  2 siblings, 1 reply; 200+ results
From: Oliver Kiddle @ 2012-02-15 14:42 UTC (permalink / raw)
  To: zsh-workers

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 870 bytes --]

Bart wrote:
> 
> Am I understanding correctly that the intent here is that é is a two-
> byte character so %2s should print the two literal bytes, rather than
> print the single logical character in a field two logical characters
> wide?

That's correct. The POSIX definition uses bytes. For multibyte
behaviour, there is an L modifier. I don't really see the sense in it
myself: I don't want to write low-level stuff in the shell.

Frank Terbeck wrote:
> Frankly, that would be the vendor's fault then. There are many *MANY*
> ksh implementations, that make for a reasonable link target (ksh93,
> pdksh or mksh - to name just a few). Zsh is not one of them.

The fact that zsh is far from a perfect emulation doesn't stop it from
being useful. I don't necessarily want to install a separate ksh package
and zsh will run ksh scripts at least as well as pdksh.

Oliver


^ permalink raw reply	[relevance 9%]

* Re: printf %<n>s in UTF-8 is not always POSIX-compliant
  2012-02-15 14:42  9%   ` Oliver Kiddle
@ 2012-02-15 14:56  5%     ` Vincent Lefevre
  0 siblings, 0 replies; 200+ results
From: Vincent Lefevre @ 2012-02-15 14:56 UTC (permalink / raw)
  To: zsh-workers

On 2012-02-15 15:42:15 +0100, Oliver Kiddle wrote:
> Bart wrote:
> > Am I understanding correctly that the intent here is that ?? is a two-
> > byte character so %2s should print the two literal bytes, rather than
> > print the single logical character in a field two logical characters
> > wide?
> 
> That's correct. The POSIX definition uses bytes. For multibyte
> behaviour, there is an L modifier. I don't really see the sense in it
> myself: I don't want to write low-level stuff in the shell.

I think that's for consistency with C. Also, the shell could then
be used as a front-end to test string-related things.

> Frank Terbeck wrote:
> > Frankly, that would be the vendor's fault then. There are many *MANY*
> > ksh implementations, that make for a reasonable link target (ksh93,
> > pdksh or mksh - to name just a few). Zsh is not one of them.
> 
> The fact that zsh is far from a perfect emulation doesn't stop it from
> being useful. I don't necessarily want to install a separate ksh package
> and zsh will run ksh scripts at least as well as pdksh.

But then the emulation should be correct.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


^ permalink raw reply	[relevance 5%]

* Re: Bug with bash emulation regarding ':'
  @ 2012-02-20  8:48  5%                 ` Bart Schaefer
  2012-02-20 10:59  3%                 ` Peter Stephenson
  1 sibling, 0 replies; 200+ results
From: Bart Schaefer @ 2012-02-20  8:48 UTC (permalink / raw)
  To: zsh-workers

On Feb 19,  3:45pm, Bart Schaefer wrote:
}
} Consequently I tried this:
} 
}  		if (spsep || !arrasg) {
} -		    multsub(&val, PREFORK_NOSHWORDSPLIT, NULL, &isarr, NULL);
} +		    multsub(&val, PREFORK_SINGLE|PREFORK_NOSHWORDSPLIT, NULL,
} &isarr, NULL);
} 
} This faithfully reproduces the bash behavior in several tests I tried.

I should note that this wouldn't have been anywhere near this easy if
PWS hadn't done the background work on passing the bitflags.

Although all tests still pass (except the new one introduced by 30203
which must be tweaked), I should note the above changes the "native"
zsh behavior as well.  I woudn't imagine this is going to cause much
trouble -- I found no uses of ${...=...} in the default $fpath, which
includes the whole completion suite, etc. -- but it does mean we might
want to make it conditional upon something.  For example:

Index: Src/subst.c
--- ../zsh-forge/current/Src/subst.c	2012-02-12 13:31:49.000000000 -0800
+++ Src/subst.c	2012-02-20 00:32:30.000000000 -0800
@@ -2693,7 +2693,12 @@
 		*idend = '\0';
 		val = dupstring(s);
 		if (spsep || !arrasg) {
-		    multsub(&val, PREFORK_NOSHWORDSPLIT, NULL, &isarr, NULL);
+		    /* POSIX requires PREFORK_SINGLE semantics here, but
+		     * traditional zsh used PREFORK_NOSHWORDSPLIT.  Base
+		     * behavior on caller choice of PREFORK_SHWORDSPLIT. */
+		    multsub(&val,
+			    spbreak ? PREFORK_SINGLE : PREFORK_NOSHWORDSPLIT,
+			    NULL, &isarr, NULL);
 		} else {
 		    if (spbreak)
 			split_flags = PREFORK_SPLIT|PREFORK_SHWORDSPLIT;

I'd be just as happy going with PREFORK_SINGLE unconditionally, I think,
but I hesitate to change anything arbitrarily.  Either way, here is the
tweak to the test suite:

Index: Test/D04parameter.ztst
--- ../zsh-forge/current/Test/D04parameter.ztst	2012-02-12 13:31:49.000000000 -0800
+++ Test/D04parameter.ztst	2012-02-19 23:46:19.000000000 -0800
@@ -267,7 +267,9 @@
   : ${test_split_var:=$(test_splitting)}
   echo "_${test_split_var}_")
 0:SH_WORD_SPLIT inside $(...) inside ${...}
->_'one' 'two' 'three'_
+>_'one'
+>'two'
+>'three'_
 
   print -l "${(f)$(print first line\\nsecond line\\nthird line)}"
 0:${(f)$(...)}


^ permalink raw reply	[relevance 5%]

* Re: Bug with bash emulation regarding ':'
    2012-02-20  8:48  5%                 ` Bart Schaefer
@ 2012-02-20 10:59  3%                 ` Peter Stephenson
  2012-02-20 17:09  3%                   ` Bart Schaefer
  1 sibling, 1 reply; 200+ results
From: Peter Stephenson @ 2012-02-20 10:59 UTC (permalink / raw)
  To: zsh-workers

On Sun, 19 Feb 2012 15:45:15 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> Hence it appears "we rely on the nested substitution to do the splitting
> we see in the top-level parameter expansion" is incorrect, at least in
> this instance?

That's good.  Maybe we're only relying on it to get the assigned value,
after all, so the splitting is done in the same order as bash (just
hitherto with different options applied at each stage).

> In fact it may be that PREFORK_SINGLE is the only thing needed there,
> and PREFORK_NOSHWORDSPLIT is extraneous?

The basic behaviour is certainly given with PREFORK_SINGLE only (spbreak
initialisation around line 1540); there's one oddity where we'll use
SHWORDSPLIT on its own to determine the default for (@) behaviour if not
forced on around line 1652.  That's rather confusing and my previous
change may already have had some impact on this, since we've reduced the
number of cases where SHWORDSPLIT is forced on.

> Although all tests still pass (except the new one introduced by 30203
> which must be tweaked), I should note the above changes the "native"
> zsh behavior as well.  I woudn't imagine this is going to cause much
> trouble -- I found no uses of ${...=...} in the default $fpath, which
> includes the whole completion suite, etc. -- but it does mean we might
> want to make it conditional upon something.  For example:

> +			    spbreak ? PREFORK_SINGLE : PREFORK_NOSHWORDSPLIT,

I suppose that's as good as anything.  Goodness knows how to document
this.  I'm not sure I really understand how the ramifications of one
option cause so much divergence internally, but as far as I can see (and
I can't, really) that should cover the two obvious cases where
SHWORDSPLIT is or is not on at the top level.  Whether it covers
explicit splitting in nested substitutions or (@) processing is another
matter.

However, given we don't tend to rely on ${...=...}, and the shenanigans
with parameter flags don't apply to POSIX, it doesn't seem worth doing
any more research, so I think this is probably as good as we need.
Thanks.

It might be worth folding this in and making 4.3.17 immediately, there's
no real point in releasing only a partial fix.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[relevance 3%]

* Re: Bug with bash emulation regarding ':'
  2012-02-20 10:59  3%                 ` Peter Stephenson
@ 2012-02-20 17:09  3%                   ` Bart Schaefer
  0 siblings, 0 replies; 200+ results
From: Bart Schaefer @ 2012-02-20 17:09 UTC (permalink / raw)
  To: zsh-workers

On Feb 20, 10:59am, Peter Stephenson wrote:
} Subject: Re: Bug with bash emulation regarding ':'
}
} On Sun, 19 Feb 2012 15:45:15 -0800
} Bart Schaefer <schaefer@brasslantern.com> wrote:
} > In fact it may be that PREFORK_SINGLE is the only thing needed there,
} > and PREFORK_NOSHWORDSPLIT is extraneous?
} 
} The basic behaviour is certainly given with PREFORK_SINGLE only (spbreak
} initialisation around line 1540); there's one oddity where we'll use
} SHWORDSPLIT on its own to determine the default for (@) behaviour if not
} forced on around line 1652. [...]
} 
} > +			    spbreak ? PREFORK_SINGLE : PREFORK_NOSHWORDSPLIT,

Hrm.  That may imply that we should do

    spbreak ? (PREFORK_SINGLE|PREFORK_SHWORDPSLIT) : PREFORK_NOSHWORDSPLIT

As you later pointed out, this would only affects some strange cases
like ${(@)=...=...}, because SINGLE beats SHWORDSPLIT at line 1540; in
those cases the workaround must previously always have been to use
additional nested expansions to turn the flags on in the right places.

So I think we're safe with just SINGLE there.

} I suppose that's as good as anything.  Goodness knows how to document
} this.  I'm not sure I really understand how the ramifications of one
} option cause so much divergence internally

Well, it's because we've overloaded its meaning from the original one
of "split words on IFS" to instead mean "split words on IFS in exactly
the same circumstances and manner the POSIX shell would do so."  Plus
keeping the non-POSIXy behavior of the traditional shell when it's not
set, which is the real divergence.

} It might be worth folding this in and making 4.3.17 immediately, there's
} no real point in releasing only a partial fix.

I'll commit shortly if you haven't already.


^ permalink raw reply	[relevance 3%]

* Re: zsh behavior when fork() failed
  @ 2012-02-26 19:52  2%         ` Bart Schaefer
  0 siblings, 0 replies; 200+ results
From: Bart Schaefer @ 2012-02-26 19:52 UTC (permalink / raw)
  To: Dipak Gaigole, zsh-workers

On Feb 25, 10:03pm, Dipak Gaigole wrote:
} Subject: Re: zsh behavior when fork() failed
}
} > Section 2.8.1 lists command execution failures where a non-interactive
} > shell "shall exit", but fork failure is not among them.
} 
} Got it.

That doesn't mean I didn't miss something.  (I was kind of in a hurry
on Friday ...)

This also raises the question of whether a non-interactive shell should
exit on a botched "exec" (see zsh-workers/30111 and subsequent thread,
and comment on line 3364 excerpted below).

} But I don't want to add a check of $? after each command in
} the scripts specially in cases where scripts are 1000+ lines.

Would "set -e" (setopt err_exit) do what you need?

} Is there any zsh option to make sure script exit when fork fails? Else
} can I patch the zsh code to make script exit on fork failure?

It's entirely possible that "return;" on lines 2818 and 2824 in exec.c:

2814         if (pipe(synch) < 0) {
2815             zerr("pipe failed: %e", errno);
2816             if (oautocont >= 0)
2817                 opts[AUTOCONTINUE] = oautocont;
2818             return;
2819         } else if ((pid = zfork(&bgtime)) == -1) {
2820             close(synch[0]);
2821             close(synch[1]);
2822             if (oautocont >= 0)
2823                 opts[AUTOCONTINUE] = oautocont;
2824             return;
2825         }

should instead behave the way POSIXBUILTINS does:

3362         /*
3363          * For POSIX-compatible behaviour with special
3364          * builtins (including exec which we don't usually
3365          * classify as a builtin) we treat all errors as fatal.
3366          * The "command" builtin is not special so resets this behaviour.
3367          */
3368         if (redir_err || errflag) {
3369             if (!isset(INTERACTIVE)) {
3370                 if (forked)
3371                     _exit(1);
3372                 else
3373                     exit(1);
3374             }
3375             errflag = 1;
3376         }

There are a couple of other cases (e.g., around line 1680) where's also
possible the error should be considered unrecoverable.

That would make a full patch look something like the following (which
still exits with 1, rather than with 128 like bash, but does exit).
The oautocont stuff goes away because it's handled below the "fatal"
label (outside the visible diff context).  The second hunk still might
not cause a proper exit, it's in execpline2() from which it's less clear
to me how to reach the "fatal" condition but it's pretty obvious that
it shouldn't just be falling through in those error states.


Index: Src/exec.c
--- ../zsh-forge/current/Src/exec.c	2012-02-12 13:31:49.000000000 -0800
+++ Src/exec.c	2012-02-26 11:47:48.000000000 -0800
@@ -1617,9 +1617,8 @@
 		 (list_pipe || (pline_level && !(jn->stat & STAT_SUBJOB)))))
 		deletejob(jn, 0);
 	    thisjob = pj;
-
 	}
-	if (slflags & WC_SUBLIST_NOT)
+	if ((slflags & WC_SUBLIST_NOT) && !errflag)
 	    lastval = !lastval;
     }
     if (!pline_level)
@@ -1679,9 +1678,13 @@
 
 	    if (pipe(synch) < 0) {
 		zerr("pipe failed: %e", errno);
+		lastval = errflag = 1;
+		return;
 	    } else if ((pid = zfork(&bgtime)) == -1) {
 		close(synch[0]);
 		close(synch[1]);
+		lastval = errflag = 1;
+		return;
 	    } else if (pid) {
 		char dummy, *text;
 
@@ -2490,7 +2493,7 @@
 		    if (!firstnode(args)) {
 			zerr("exec requires a command to execute");
 			errflag = lastval = 1;
-			return;
+			goto fatal;
 		    }
 		    uremnode(args, firstnode(args));
 		    if (!strcmp(next, "--"))
@@ -2507,12 +2510,12 @@
 				if (!firstnode(args)) {
 				    zerr("exec requires a command to execute");
 				    errflag = lastval = 1;
-				    return;
+				    goto fatal;
 				}
 				if (!nextnode(firstnode(args))) {
 				    zerr("exec flag -a requires a parameter");
 				    errflag = lastval = 1;
-				    return;
+				    goto fatal;
 				}
 				exec_argv0 = (char *)
 				    getdata(nextnode(firstnode(args)));
@@ -2813,15 +2816,12 @@
 
 	if (pipe(synch) < 0) {
 	    zerr("pipe failed: %e", errno);
-	    if (oautocont >= 0)
-		opts[AUTOCONTINUE] = oautocont;
-	    return;
+	    goto fatal;
 	} else if ((pid = zfork(&bgtime)) == -1) {
 	    close(synch[0]);
 	    close(synch[1]);
-	    if (oautocont >= 0)
-		opts[AUTOCONTINUE] = oautocont;
-	    return;
+	    lastval = errflag = 1;
+	    goto fatal;
 	}
 	if (pid) {
 
@@ -3365,6 +3365,7 @@
 	 * classify as a builtin) we treat all errors as fatal.
 	 * The "command" builtin is not special so resets this behaviour.
 	 */
+    fatal:
 	if (redir_err || errflag) {
 	    if (!isset(INTERACTIVE)) {
 		if (forked)


^ permalink raw reply	[relevance 2%]

* PATCH: NEWS updated for 5.0.
@ 2012-04-13 22:14  8% Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2012-04-13 22:14 UTC (permalink / raw)
  To: Zsh Hackers' List

Here's my first go at condensing the NEWS for 4.3 into a single group
between 4.2 and 5.0.  The old 4.3 news has moved into Etc.

Probably easier to look through and comment on after I've committed it.


Index: NEWS
===================================================================
RCS file: /cvsroot/zsh/zsh/NEWS,v
retrieving revision 1.48
diff -p -u -r1.48 NEWS
--- NEWS	15 Feb 2012 20:41:41 -0000	1.48
+++ NEWS	13 Apr 2012 22:11:37 -0000
@@ -4,357 +4,272 @@ CHANGES FROM PREVIOUS VERSIONS OF ZSH
 
 Note also the list of incompatibilities in the README file.
 
-Changes since 4.3.15
---------------------
+Changes between 4.2 and 5.0
+---------------------------
 
-The option HASH_EXECUTABLES_ONLY has been added.  When this is set,
-directories in the command path will be checked for executables before
-they are added to the command table (hash); otherwise, all files in the
-directory are added.  The effect of this option was present in 4.3.15,
-which could cause significant delays when hashing on systems with
-network directories in the path.
-
-Changes since 4.3.12
---------------------
-
-There are no significant feature changes to the shell itself, although
-many bug fixes and improvements to functions.
-
-Changes since 4.3.11
---------------------
-
-The zsh/parameter module has a new readonly associative array
-$usergroups whose keys are the names of system groups of which the
-current user is a member and whose values are the corresponding
-group identifiers.
-
-The region_highlight array, which controls highlighting of the
-command line from zle widgets, is now updated dynamically as
-the command line is edited.
-
-In POSIX emulation ("emulate sh") the shell is more accurate about
-when it should or should not exit on errors.
-
-The ${NAME:OFFSET:LENGTH} syntax now supports negative LENGTH, which
-counts back from the end of the string.
-
-The (g:opts:) flag in parameter expansion processes escape sequences like
-the echo and print builtins.  opts can be any combination of o, e and c.
-With e, acts like print rather than echo except for octal escapes which
-are controlled separately by the o option.  With c, interpret control
-sequences like "^X" as bindkey does.  Regardless of the opts, \c is not
-interpreted.
-
-Changes between versions 4.3.10 and 4.3.11
-------------------------------------------
-
-When the shell is invoked with the base name of a script, for example as
-`zsh scriptname', previous versions of zsh have used the name directly,
-whereas other shells use the value of $PATH to find the script.  The
-option PATH_SCRIPT has been added to provide the alternative behaviour.
-This is turned on where appropriate in compatibility modes.
-
-Parameters, globbing, etc.
--+-+-+-+-+-+-+-+-+-+-+-+-+
-
-Parameter expansion has been enhanced to provide the ${NAME:OFFSET} and
-${NAME:OFFSET:LENGTH} syntax for substrings and subarrays present in
-several other shells.  OFFSET always uses zero-based indexing.  The only
-clash with existing zsh syntax occurs if OFFSET begins with an
-alphabetic character or `&', which is not likely.
-
-The (D) flag in parameter expansion abbreviates directories in the
-substituted value.  The (q-) flag does minimal shell quotation of arguments
-for maximum human readability of the result.
-
-The (Z) flag in parameter expansion is an enhanced version of the (z)
-flag that takes an argument indicating how the string to be split
-is treated. (Z:c:) parses comments as strings; (Z:C:) parses comments
-and strips them; (Z:n:) treats newlines as ordinary whitespace: (z)
-has always treated unquoted newlines as shell delimiters and turned them
-into semicolons, though this was not previously documented.
-
-Numeric expansion with braces has been extended so that a step may be
-given, as in {3..9..2}.  The step may be negative as may the start and
-end of the range (this is also new).
-
-The glob qualifier P can be used to add a separate word before each
-match.  For example, *(P:-f:) produces the command line
-`-f file1 -f file2 ...'.
-
-Regular expression matches now use the same variables for storing matched
-components as shell pattern matching.  The function system now provides the
-function regexp-replace for replacing text using regular expressions.  The
-zle widget functions replace-string, replace-string-again, if defined with
-regex in the name (e.g. "zle -N replace-regexp replace-string"), perform
-regular expression matches.  In replacement text \& and \1 have the
-standard meaning.
-
-Line editor and completion
--+-+-+-+-+-+-+-+-+-+-+-+-+
-
-The completion system now has a style path-completion.  Setting this to
-false inhibits completion of paths before the current path component,
-e.g. /u/b/z no longer completes to /usr/bin/zsh.  This is useful on systems
-where this form of completion is pathologically slow due to network
-performance.
-
-With the MULTIBYTE option, the line editor now highlights bytes in the
-input that are not part of a valid character in the current locale in hex
-as <XX> for hex digits X; highlighting is controlled by the "special"
-keyword in the zle_highlight array.  These can be distinguished from
-unprintable Unicode characters which also use "special" highlighting as the
-latter are always two or four bytes long, e.g. <XXXX>, <XXXXXXXX>.
-
-zle_highlight also controls highlighting of a removable completion
-suffix, e.g. the "/" automatically appended to directories.  This uses
-the keyword "suffix".
-
-The line editor now sets the variable ZLE_LINE_ABORTED if there is
-an error when editing the line.  The following code can be used
-to create a bindable editor widget to restore the aborted line:
-  recover-line() { LBUFFER=$ZLE_LINE_ABORTED RBUFFER=; }
-  zle -N recover-line
-and then either bind recover-line to a key sequence or use
-`M-x recover-line <RET>'.
-
-The parameter ZLE_STATE, available in user-defined line editor widgets,
-gives information on the state of the line editor.  Currently this is
-whether the line editor is in insert or overwrite mode.
+The following changes first appeared in the 4.3 series of releases;
+see also the file Etc/NEWS-4.3.
 
-Miscellaneous options
--+-+-+-+-+-+-+-+-+-+-
-
-The new shell option HIST_LEX_WORDS causes history lines read in from
-a file to be split in the same way as normal shell lines, instead of
-simply on whitespace.  It's an option as although the result is more
-accurate it can take a long time when the history size is large.
-
-The shell option MONITOR can be set in non-interactive shells, and also in
-subshells (as created by surrounding commands with parentheses), turning on
-job control for that subshell.  The initial behaviour of a subshell is
-still to turn job control off, however if the new POSIX_JOBS option is set
-MONITOR remains active in subshells.
-
-The new shell option POSIX_CD, active in emulations of POSIX-based shells,
-makes the cd builtin POSIX-compatible.
-
-The POSIX_JOBS option already referred to has various other
-compatibility enchancements.
-
-The new shell option POSIX_STRINGS makes a null character in $'...'
-expansion terminate the string, as is already the case in bash.  This is
-not particularly useful behaviour but may become a POSIX requirement.
-
-The new shell option POSIX_TRAPS causes the EXIT trap to behave in the same
-way as in other shells, i.e. it is only run when the shell exits.
-
-The new shell option SOURCE_TRACE causes the shell to report files
-containing shell code that the shell executes directly, i.e. startup files
-or files run with the `source' or `.' builtins.
-
-The shell option SUN_KEYBOARD_HACK has been supplemented by a more general
-mechanism: the KEYBOARD_HACK variable defines the character to be ignored.
-
-Add-on modules and function
--+-+-+-+-+-+-+-+-+-+-+-+-+-
-
-The module zsh/system has a new "zsystem" builtin whose subcommands perform
-system level tasks.  Currently "zsystem flock" performs advisory file
-locking (for aficionados, this uses the fcntl() system call so works over
-the network on Linux).  This is a particularly convenient way of locking
-files for the length of a subshell.  "zsystem supports flock" provides a
-test for this feature.
-
-There is now a function system for recording and restoring recently
-entered directories in a persistent fashion, with support in completion
-and (if explicitly installed) dynamic directory expansion.  See the
-entry for cdr in the zshcontrib manual page.
-
-
-Changes between versions 4.3.9 and 4.3.10
------------------------------------------
+Here is a summary of the most significant changes:
 
-The command "emulate <mode> -c ..." evaluates an expression in a given
-emulation.  The emulation is sticky for functions defined within the
-expression.
+- Multibyte characters strings are supported throughout the shell.
+  Various options, editor features, and expansion flags have been
+  added to aid in using them.
+
+- The following new options have appeared: COMBINING_CHARS,
+  DEBUG_BEFORE_CMD, HASH_EXECUTABLES_ONLY, HIST_FCNTL_LOCK,
+  HIST_LEX_WORDS, HIST_SAVE_BY_COPY, MULTIBYTE, NO_MULTI_FUNCDEF,
+  PATH_SCRIPT, POSIX_ALIASES, POSIX_CD, POSIX_JOBS, POSIX_STRINGS,
+  POSIX_TRAPS, PROMPT_SP, SOURCE_TRACE.
+
+- Highlighting and colouring of the command line is supported.
+
+- Job control is supported in non-interactive shells and subshells.
+
+- The zshroadmap manual page provides a slightly more helpful
+  introduction to the shell manual than was available hitherto.
+
+Expansion (parameters, globbing, etc.) and redirection
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+- The character group tests [[:IDENT:]], [[:IFS:]], [[:IFSSPACE:]],
+  [[:WORD:]] in patterns allow testing if a character can be
+  part of an identifier, is an IFS character, is an IFS whitespace
+  character, or is considered part of the word using the line editor's
+  logic based on the shell variable WORDCHARS.
+
+- In extended globbing, "(#cN,M)" means "match the preceding group
+  at least N but no more than M times".
+
+- The glob qualifier P can be used with an argument to add an extra
+  word before each glob match.
+
+- The syntax ~[...] provides dynamic directory naming by means
+  of the shell function zsh_directory_name or associated hook functions.
+  This is useful for expanding paths with many variable components as
+  commonly found in software development.
+
+- Parameter expansion has the ${NAME:OFFSET} and ${NAME:OFFSET:LENGTH}
+  syntax for compatibility with other shells (and zero-based indexing
+  is used to enhance compatibility).  LENGTH may be negative to count
+  from the end.
+
+- The parameter expansion flag (D) abbreviates directories in parameters
+  using the familiary ~ form.
+
+- The parameter expansion flag (g) can take delimited arguments o, e and
+  c to provide echo- and print-style expansion: (g::) provides basic
+  echo-style expansion; (g:e:) provides the extended capabilities of
+  print; (g:o:) provides octal escapes without a leading zero; (g:c:)
+  additional expands "^c" style control characters as for bindkey.
+  Options may be combined, e.g. (g:eoc:).
+
+- The parameter expansion flag (q-) picks the most minimal way of
+  quoting the parameter words, to make the result as readable as possible.
+
+- The parameter expansion flag (Z), a variant of (z), takes arguments
+  describing how to split a variable using shell syntax: (Z:c:) parses
+  comments as strings (the default is not to treat comment characters
+  specially); (Z:C:) parses comments and strips them; (Z:n:) treats
+  newlines as ordinary whitespace (the default is to turn unquoted
+  newlines into semicolons; this is now documented).
+
+- The parameter subscript flag (e) forces the argument to be treated
+  as a string, never a pattern, e.g. ${array[(ie)*]} looks for the
+  index of the array element containing the literal string "*".
+
+- Numeric expansions can have a positive or negative step
+  e.g. "{3..9..2}".  Negative start and end of ranges are also now
+  supported.
+
+- =(<<<...) is optimised to eliminate the need for an external process.
+  It writes the given string to a file and substitutes the name on the
+  command line.
+
+- The redirection operations "{myfd}>file" and "{myfd}>&-" open and
+  close a new file descriptor (at least 10) contained in the shell
+  variable myfd, which can be written to with ">&$myfd".  This allows
+  arbitrary file descriptors rather than the explicit range 0 to 9.
+
+- New prompt escapes:
+  %x and %I show source file and line number, usefil
+    in $PS4 (the existing %N and %i show names and lines in the execution
+    environment rather than the source file).
+  %F, %K, %f, %k allow colouring of prompts both using ANSI colour names
+    and values supported by individual terminal emulators.
+
+Builtins and shell functions
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+- Directory changing builtins take an option -q to suppress side
+  effects such as printing directories or calling the chpwd hook functions.
+
+- Various enhancements have been made to traps:
+  - The option DEBUG_BEFORE_CMD is on by default, so DEBUG traps
+    can be used to debug code about to be run
+  - $ZSH_DEBUG_CMD in such a trap gives the code to be run
+  - "setopt ERR_EXIT" in a DEBUG trap causes the code not to be executed
+
+- The "fc" builtin is now more useful non-interactively.
+
+Shell variables (parameters)
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+- New variables:
+  CORRECT_IGNORE can be set to a pattern to be ignored in spelling correction.
+  KEYBOARD_HACK defines characters to be ignored if typed unmatched at
+    the end of the line (an extension of the SUN_KEYBOARD_HACK option).
+  ZSH_PATCHLEVEL provides a unique indication of the code compiled to
+    make the shell even between releases.
+  ZSH_SUBSHELL indicates the subshell live, incremented once per fork, at
+    which the code is being run.
+
+Options
+-+-+-+-
+
+- New options:
+  COMBINING_CHARS: assume that the terminal displays combining
+    characters correctly.  The shell cannot determine this by itself,
+    hence the option.  This is highly recommended for MacOS X where
+    file names are stored with accented characters split into basic
+    and combining characters.
+  DEBUG_BEFORE_CMD (on by default): execute debug traps before the
+    code they refer to.  This is a change of the default behaviour
+    as the new behaviour is much more useful.
+  HASH_EXECUTABLES_ONLY: don't insert non-executable files into the
+    command hash used e.g. by completion.  This may be very slow
+    on network paths.
+  HIST_FCNTL_LOCK: Use the system's file locking mechanism instead
+    of an ad-hoc mechanism for locking history files.
+  HIST_LEX_WORDS: Perform lexical analysis on history lines read from
+    files, so the words are more accurately determined.  May be very slow.
+  HIST_SAVE_BY_COPY (on by default): if unset, write a history file in
+    place by truncating the old one.  Only needs to be turned off in
+    special circumstances.
+  MULTIBYTE (on by default if available): both variables and editor
+    command lines are treated as sequences of multibyte characters
+    rather than raw bytes depending on the locale.  May be turned off
+    within functions to perform bytewise operations.
+  MULTI_FUNCDEF (on by default): "foo bar () { ... }" defines two
+    functions.  This is often found to be confusing and bug-prone.
+  PATH_SCRIPT: search the path for a script specified as the first
+    argument to the shell on invocation.
+  POSIX_ALIASES: reserved words are not candidates for alias expansion.
+  POSIX_CD: make directory changing more POSIX-compatible.
+  POSIX_JOBS: make job control more POSIX compliant.
+  POSIX_STRINGS: $'...\0...' always processes \0 as a NULL, but if the
+    option is set the remainder of the string is ignored.
+  POSIX_TRAPS: EXIT traps are not executed on return from shell functions.
+  PROMPT_SP: improves display of lines not ending with newlines when
+    PROMPT_CR is in effect.
+  SOURCE_TRACE: print information as files are executed with ".",
+    "source", or as startup or shutdown files.
+
+Line editor
+-+-+-+-+-+-
+
+- New builtin widgets:
+  arguments-base: allow non-decimal numeric arguments
+  history-incremental-pattern-search-{backward,forward}: support
+    patterns in incremental searches.
+
+- New special variables:
+  region_highlight allows arbitrary highlighting of parts of the
+    command line; it is maintained dynamically.
+  UNDO_CHANGE_NO gives a unique record of the current change state of
+    the command line, for undoing back to a particular point using
+    the undo widget.
+  zle_highlight provides master control of highlighting for special
+    modes, e.g. unprintable characters.
+  ZLE_LINE_ABORTED records an editor line that was aborted by an error
+    or C-g.  It can be used to recover aborted lines.
+  ZLE_STATE give miscellaneous information, currently whether the line
+    editor is in insert or overwrite mode.
+
+- The undo widget takes an argument, a previuos value of $UNDO_CHANGE_NO.
+
+Completion
+-+-+-+-+-+
+
+- Many new and enhanced completion functions
+
+- New styles:
+  accept-exact-dirs:  suppress path expansion of directory components
+    that already exist, speeding up completion significantly on slow
+    network directories.
+  path-completion:  can be used to suppress directory components before
+    the current one completely, so e.g. /u/b<TAB> only completes after the
+    "b", not the "u".
+
+- New special variables:
+  ZLE_REMOVE_SUFFIX_CHARS, ZLE_SPACE_SUFFIX_CHARS provide enhanced
+    flexibility over suffix removal.
+
+Syntax and compatibility
+-+-+-+-+-+-+-+-+-+-+-+-+
+
+- Substitutions of the form ${var:-"$@"} and ${var:+"$@"} now behave
+  much more like other shells when appropriate (e.g. with the
+  SH_WORD_SPLIT option).
+
+- Assignments within variable substitutions, such as ${var=value},
+  are also more compatible with other shells where appropriate.
+
+- The emulate command can now be passed an expression to be evaluated
+  in a "sticky" emulation, so that functions defined there always
+  behave in the appropriate emulation.
+
+- "emulate sh" and similar modes have improved compatibility with
+  respect to deciding whether the shell should exit on errors.
+
+- Signals now accept SIG as part of the name.
+
+Modules
+-+-+-+-
+
+- Modules now present "features", specific builtins (b:), parameters
+  (p:), conditions (c:) and math functions (f:), allowing more control
+  over what is imported from a module.
+
+- The zsh/curses module provides access to the "curses" screen
+  manipulation package.
+
+- The zsh/datetime module has a calendar utility, although it is not
+  as robust as standalone calendar utilities.
+
+- The zsh/newuser module and associated functions has facilities for
+  setting up startup files for a first-time user.
+
+- The zsh/parameter module contains some new arrays to aid in tracing
+  of the shell's call stack: $funcsourcetrace and $funcfiletrace.
+
+- The zsh/parameter module provides $usergroups, an associative arrays
+  whose keys are the names of groups the current user belongs to, with
+  the group identifier as the corresponding value.
+
+- The zsh/system module has a zsystem builtin which provides file
+  locking and also a forward-compatible means for testing subcommands
+  supported.
 
-The variable CORRECT_IGNORE gives a pattern that can be ignored
-in spelling correction.  CORRECT_IGNORE='_*' ignores completion functions.
-
-The option POSIX_ALIASES improves compatibility of aliases with other
-shells.
-
-The variable ZSH_PATCHLEVEL can be used to test for unreleased versions of
-the shell; it is present but less useful in released versions.
-
-The variables ZLE_REMOVE_SUFFIX_CHARS and ZLE_SPACE_SUFFIX_CHARS allow more
-control over the way automatically removed suffixes are treated in
-completion.
-
-Major changes between versions 4.3.6 and 4.3.9
-----------------------------------------------
-
-The option COMBINING_CHARS has been added.  When it is set, the
-line editor assumes the terminal is capable of displaying zero-width
-combining characters (typically accents) correctly as modifications
-to the base character, and will act accordingly.  Note it is not set
-by default owing to vagaries of terminals.  The system is reported
-to work on MacOS, where this is particularly important as accented
-characters in file names are stored in their decomposed form (i.e.
-with base and combining characters).
-
-The option HIST_FCNTL_LOCK has been added to provide locking of history
-files using the system call fcntl().  On recent NFS implementations this
-may provide better reliability.
-
-The syntax ~[...] provides a dynamic form of directory naming,
-supplementing the existing static ~name syntax.  A user-defined shell
-function, zsh_directory_name, is used to handle both expansion of names to
-directories and contraction of directories to names.
-
-Patterns can now be used in incremental searches with the new widgets
-history-incremental-pattern-search-backward and
-history-incremental-pattern-search-forward.  These are not bound to
-keys by default.
-
-Highlighting and colouring of sections of the command line is now
-supported, controlled by the array parameter zle_highlight and the ZLE
-special parameter region_highlight.
-
-Colouring of prompts is now supported within the shell by prompt
-escapes.  The prompt theme system has been updated.
-
-Various changes have been added to make debugging of shell code easier:
-  - As noted in README, the option DEBUG_BEFORE_CMD is now set by default.
-  - In DEBUG traps, $ZSH_DEBUG_CMD gives the code for which the trap is
-    called as a string.
-  - "setopt ERR_EXIT" in a DEBUG trap causes the code not to be executed.
-  - $ZSH_SUBSHELL indicates the subshell level at which code is being
-    executed.
-  - The zsh/parameter module has various additional arrays similar to
-    the existing $funcstack and $functrace, namely $funcsourcetrace
-    and $funcfiletrace.  The consistency and informativeness of
-    the output of all these arrays has been improved.
-  - Prompt escapes %x and %I show the source file and line number in
-    debug prompts (compare %N and %i which show names and line numbers
-    in the execution environment).
-  - The option NO_MULTI_FUNCDEF can turn off multiple definition of
-    functions at once, a rarely used feature that can cause problems
-    with misplaced "()".
-  - The "fc" builtin has been enhanced to make non-interactive use possible
-    and output consistent when the history is manipulated with "print -s".
-
-The completion style accept-exact-dirs has been added.  When true, this
-suppresses attempts to complete non-final directory segments of a filename
-path when the directory exists.  (For example, /home/pws/src/zsh/<TAB>
-discovers that /home/pws/src/zsh exists and leaves the directory component
-alone, while /h/p/s/z/<TAB> completes to /home/pws/src/zsh/... as before.)
-This should improve completion behaviour noticeably in special cases, such
-as remote paths under Cygwin.
-
-Major changes between versions 4.3.5 and 4.3.6
-----------------------------------------------
-
-cd, chdir, pushd and popd now take a -q option to suppress side effects
-including printing the directory stack (for pushd and popd) and executing
-the chpwd hook functions (for all four).
-
-The parameter subscript (e) flag now forces the argument to be treated
-as a string where it would previously have been treated as a pattern,
-for example ${array[(ie)*]} substitutes the index of the element whose
-value is "*".
-
-Major changes between versions 4.3.4 and 4.3.5
-----------------------------------------------
-
-- The new extended globbing flag (#cN,M) behaves similarly to the extended
-  regular expression syntax {N,M}.
+Internal improvements
+-+-+-+-+-+-+-+-+-+-+-
 
-- The zsh/datetime module has been enhanced and a calendar function
-  system has been added along the lines of (but much enhanced from)
-  the traditional Unix "calendar" utility.  This is still under
-  development.  See the zshcalsys manual.  (The calendar functions
-  were in 4.3.4 but were not listed in this file.  There have been
-  significant enhancements since 4.3.4.)
-
-- A new module zsh/curses provides a builtin zcurses for access to
-  to the curses screen manipulation package.  See the entry for zsh/curses
-  in the zshmodules manual.
-
-- The module system has been enhanced to support the notion of "features"
-  that give more control over which builtins, parameters, conditions
-  and math functions are loaded from a module.  In particular,
-  "zmodload -F zsh/stat b:zstat" makes the builtin previously called
-  "stat" available as "zstat" (only) to avoid clashes with a system
-  command named "stat".
-
-Major changes between versions 4.2 and 4.3.4
---------------------------------------------
-
-- There is support for multibyte character sets.  This is now reasonably
-  close to complete, although Unicode combining characters don't work
-  properly.  See Multibyte Character Support in INSTALL.
-
-- The shell can now run an installation function for a new user
-  (a user with no .zshrc, .zshenv, .zprofile or .zlogin file) without
-  any additional setting up by the administrator.  See "THE ZSH/NEWUSER
-  MODULE" in the zshmodules manual page.
-
-- The manual now has a Roadmap section (manual page zshroadmap) to
-  give new users an indication of the most interesting parts of the
-  manual.
-
-- New option PROMPT_SP (on by default): works around the problem that the
-  line editor can overwrite output with no newline at the end.  See the
-  zshoptions manual page.
-
-- New option HIST_SAVE_BY_COPY (on by default): history is saved by
-  copying and renaming instead of directly overwriting.  See the
-  zshoptions manual page.
-
-- New redirection syntax e.g. {myfd}>file opens a new file descriptor
-  and stores the number in $myfd, so that >&$myfd will work.  Chosen
-  not to break existing code (and to be compatible with proposals for the
-  Korn shell).  See the section REDIRECTION in the zshmisc manual page.
-
-- Substitutions of the form ${var:-"$@"}, ${var:+"$@"} and similar where
-  word-splitting is applied to the text after the :- or :+ (in particular,
-  where the SH_WORD_SPLIT option is in effect for compatibility) now
-  behave as in other Bourne- and POSIX-compatible shells when in the
-  appropriate emulation mode.
-
-- New Posix-style zsh-specific tests [[:IDENT:]], [[:IFS:]],
-  [[:IFSSPACE:]], [[:WORD:]] test if character can appear in identifier,
-  is an IFS character, is an IFS whitespace character, or is considered
-  as part of a word (is alphanumeric or appears in $WORDCHARS).  These
-  works correctly on multibyte characters if the appropriate support
-  is present.  See the section FILENAME GENERATION in the zshexpn
-  manual page.
-
-- Time comparisons on files when sorting or using test operators will
-  use high-resolution timestamps when available.  This gives a
-  resolution of a nanosecond instead of a second.
-
-- The idiom =(<<<...) is optimised so that the shell internally turns
-  the ... into the contents of a file whose name is then substituted.
-  The syntax has always been usable by means of the NULLCMD feature,
-  but previously it generated an intermediate process; it has now
-  been rewritten along the same lines as the optimisation for $(<...)
-  that inserts a file into the command line without the use of an
-  external programme.
-
-- Supplied functions catch and throw provide limited support for
-  exception handling using the `{ ... } always { ... }' syntax.
-  See the section EXCEPTION HANDLING in the zshcontrib manual page.
+- High resolution timestamps are used internally for certain
+  comparisons when available.
 
-- Signals now accept the SIG as part of the name for compatibility with
-  other shells.
+Add-on functions
+-+-+-+-+-+-+-+-+
 
-- Editor function argument-base allows non-decimal arguments for
-  editor widgets.  See the entry in the zshzle manual page.
+- The VCS_Info system provides a way of keeping track of the state
+  of numerous version control systems within the shell.
 
-- As always, there are many enhancements to completion functions.
+- cdr etc.: change to a directory from a list that persists between
+  shell instances, with completion support.
+
+- regexp-replace replaces text in variables using regular expressions;
+  it may be used by zle function widgets based on the functions
+  replace-string and replace-string-again to provide regular expression
+  replacements in the line editor.
 
 Changes in 4.2 since version 4.2.0
 ----------------------------------
Index: Etc/NEWS-4.3
===================================================================
RCS file: Etc/NEWS-4.3
diff -N Etc/NEWS-4.3
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Etc/NEWS-4.3	13 Apr 2012 22:11:37 -0000
@@ -0,0 +1,356 @@
+This file describes changes made during the 4.3 series of releases;
+it is superseded by the description of changes between 4.2 and 5.0
+in the main NEWS file.
+
+
+Changes since 4.3.15
+--------------------
+
+The option HASH_EXECUTABLES_ONLY has been added.  When this is set,
+directories in the command path will be checked for executables before
+they are added to the command table (hash); otherwise, all files in the
+directory are added.  The effect of this option was present in 4.3.15,
+which could cause significant delays when hashing on systems with
+network directories in the path.
+
+Changes since 4.3.12
+--------------------
+
+There are no significant feature changes to the shell itself, although
+many bug fixes and improvements to functions.
+
+Changes since 4.3.11
+--------------------
+
+The zsh/parameter module has a new readonly associative array
+$usergroups whose keys are the names of system groups of which the
+current user is a member and whose values are the corresponding
+group identifiers.
+
+The region_highlight array, which controls highlighting of the
+command line from zle widgets, is now updated dynamically as
+the command line is edited.
+
+In POSIX emulation ("emulate sh") the shell is more accurate about
+when it should or should not exit on errors.
+
+The ${NAME:OFFSET:LENGTH} syntax now supports negative LENGTH, which
+counts back from the end of the string.
+
+The (g:opts:) flag in parameter expansion processes escape sequences like
+the echo and print builtins.  opts can be any combination of o, e and c.
+With e, acts like print rather than echo except for octal escapes which
+are controlled separately by the o option.  With c, interpret control
+sequences like "^X" as bindkey does.  Regardless of the opts, \c is not
+interpreted.
+
+Changes between versions 4.3.10 and 4.3.11
+------------------------------------------
+
+When the shell is invoked with the base name of a script, for example as
+`zsh scriptname', previous versions of zsh have used the name directly,
+whereas other shells use the value of $PATH to find the script.  The
+option PATH_SCRIPT has been added to provide the alternative behaviour.
+This is turned on where appropriate in compatibility modes.
+
+Parameters, globbing, etc.
+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+Parameter expansion has been enhanced to provide the ${NAME:OFFSET} and
+${NAME:OFFSET:LENGTH} syntax for substrings and subarrays present in
+several other shells.  OFFSET always uses zero-based indexing.  The only
+clash with existing zsh syntax occurs if OFFSET begins with an
+alphabetic character or `&', which is not likely.
+
+The (D) flag in parameter expansion abbreviates directories in the
+substituted value.  The (q-) flag does minimal shell quotation of arguments
+for maximum human readability of the result.
+
+The (Z) flag in parameter expansion is an enhanced version of the (z)
+flag that takes an argument indicating how the string to be split
+is treated. (Z:c:) parses comments as strings; (Z:C:) parses comments
+and strips them; (Z:n:) treats newlines as ordinary whitespace: (z)
+has always treated unquoted newlines as shell delimiters and turned them
+into semicolons, though this was not previously documented.
+
+Numeric expansion with braces has been extended so that a step may be
+given, as in {3..9..2}.  The step may be negative as may the start and
+end of the range (this is also new).
+
+The glob qualifier P can be used to add a separate word before each
+match.  For example, *(P:-f:) produces the command line
+`-f file1 -f file2 ...'.
+
+Regular expression matches now use the same variables for storing matched
+components as shell pattern matching.  The function system now provides the
+function regexp-replace for replacing text using regular expressions.  The
+zle widget functions replace-string, replace-string-again, if defined with
+regex in the name (e.g. "zle -N replace-regexp replace-string"), perform
+regular expression matches.  In replacement text \& and \1 have the
+standard meaning.
+
+Line editor and completion
+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+The completion system now has a style path-completion.  Setting this to
+false inhibits completion of paths before the current path component,
+e.g. /u/b/z no longer completes to /usr/bin/zsh.  This is useful on systems
+where this form of completion is pathologically slow due to network
+performance.
+
+With the MULTIBYTE option, the line editor now highlights bytes in the
+input that are not part of a valid character in the current locale in hex
+as <XX> for hex digits X; highlighting is controlled by the "special"
+keyword in the zle_highlight array.  These can be distinguished from
+unprintable Unicode characters which also use "special" highlighting as the
+latter are always two or four bytes long, e.g. <XXXX>, <XXXXXXXX>.
+
+zle_highlight also controls highlighting of a removable completion
+suffix, e.g. the "/" automatically appended to directories.  This uses
+the keyword "suffix".
+
+The line editor now sets the variable ZLE_LINE_ABORTED if there is
+an error when editing the line.  The following code can be used
+to create a bindable editor widget to restore the aborted line:
+  recover-line() { LBUFFER=$ZLE_LINE_ABORTED RBUFFER=; }
+  zle -N recover-line
+and then either bind recover-line to a key sequence or use
+`M-x recover-line <RET>'.
+
+The parameter ZLE_STATE, available in user-defined line editor widgets,
+gives information on the state of the line editor.  Currently this is
+whether the line editor is in insert or overwrite mode.
+
+Miscellaneous options
+-+-+-+-+-+-+-+-+-+-+-
+
+The new shell option HIST_LEX_WORDS causes history lines read in from
+a file to be split in the same way as normal shell lines, instead of
+simply on whitespace.  It's an option as although the result is more
+accurate it can take a long time when the history size is large.
+
+The shell option MONITOR can be set in non-interactive shells, and also in
+subshells (as created by surrounding commands with parentheses), turning on
+job control for that subshell.  The initial behaviour of a subshell is
+still to turn job control off, however if the new POSIX_JOBS option is set
+MONITOR remains active in subshells.
+
+The new shell option POSIX_CD, active in emulations of POSIX-based shells,
+makes the cd builtin POSIX-compatible.
+
+The POSIX_JOBS option already referred to has various other
+compatibility enchancements.
+
+The new shell option POSIX_STRINGS makes a null character in $'...'
+expansion terminate the string, as is already the case in bash.  This is
+not particularly useful behaviour but may become a POSIX requirement.
+
+The new shell option POSIX_TRAPS causes the EXIT trap to behave in the same
+way as in other shells, i.e. it is only run when the shell exits.
+
+The new shell option SOURCE_TRACE causes the shell to report files
+containing shell code that the shell executes directly, i.e. startup files
+or files run with the `source' or `.' builtins.
+
+The shell option SUN_KEYBOARD_HACK has been supplemented by a more general
+mechanism: the KEYBOARD_HACK variable defines the character to be ignored.
+
+Add-on modules and function
+-+-+-+-+-+-+-+-+-+-+-+-+-+-
+
+The module zsh/system has a new "zsystem" builtin whose subcommands perform
+system level tasks.  Currently "zsystem flock" performs advisory file
+locking (for aficionados, this uses the fcntl() system call so works over
+the network on Linux).  This is a particularly convenient way of locking
+files for the length of a subshell.  "zsystem supports flock" provides a
+test for this feature.
+
+There is now a function system for recording and restoring recently
+entered directories in a persistent fashion, with support in completion
+and (if explicitly installed) dynamic directory expansion.  See the
+entry for cdr in the zshcontrib manual page.
+
+
+Changes between versions 4.3.9 and 4.3.10
+-----------------------------------------
+
+The command "emulate <mode> -c ..." evaluates an expression in a given
+emulation.  The emulation is sticky for functions defined within the
+expression.
+
+The variable CORRECT_IGNORE gives a pattern that can be ignored
+in spelling correction.  CORRECT_IGNORE='_*' ignores completion functions.
+
+The option POSIX_ALIASES improves compatibility of aliases with other
+shells.
+
+The variable ZSH_PATCHLEVEL can be used to test for unreleased versions of
+the shell; it is present but less useful in released versions.
+
+The variables ZLE_REMOVE_SUFFIX_CHARS and ZLE_SPACE_SUFFIX_CHARS allow more
+control over the way automatically removed suffixes are treated in
+completion.
+
+Major changes between versions 4.3.6 and 4.3.9
+----------------------------------------------
+
+The option COMBINING_CHARS has been added.  When it is set, the
+line editor assumes the terminal is capable of displaying zero-width
+combining characters (typically accents) correctly as modifications
+to the base character, and will act accordingly.  Note it is not set
+by default owing to vagaries of terminals.  The system is reported
+to work on MacOS, where this is particularly important as accented
+characters in file names are stored in their decomposed form (i.e.
+with base and combining characters).
+
+The option HIST_FCNTL_LOCK has been added to provide locking of history
+files using the system call fcntl().  On recent NFS implementations this
+may provide better reliability.
+
+The syntax ~[...] provides a dynamic form of directory naming,
+supplementing the existing static ~name syntax.  A user-defined shell
+function, zsh_directory_name, is used to handle both expansion of names to
+directories and contraction of directories to names.
+
+Patterns can now be used in incremental searches with the new widgets
+history-incremental-pattern-search-backward and
+history-incremental-pattern-search-forward.  These are not bound to
+keys by default.
+
+Highlighting and colouring of sections of the command line is now
+supported, controlled by the array parameter zle_highlight and the ZLE
+special parameter region_highlight.
+
+Colouring of prompts is now supported within the shell by prompt
+escapes.  The prompt theme system has been updated.
+
+Various changes have been added to make debugging of shell code easier:
+  - As noted in README, the option DEBUG_BEFORE_CMD is now set by default.
+  - In DEBUG traps, $ZSH_DEBUG_CMD gives the code for which the trap is
+    called as a string.
+  - "setopt ERR_EXIT" in a DEBUG trap causes the code not to be executed.
+  - $ZSH_SUBSHELL indicates the subshell level at which code is being
+    executed.
+  - The zsh/parameter module has various additional arrays similar to
+    the existing $funcstack and $functrace, namely $funcsourcetrace
+    and $funcfiletrace.  The consistency and informativeness of
+    the output of all these arrays has been improved.
+  - Prompt escapes %x and %I show the source file and line number in
+    debug prompts (compare %N and %i which show names and line numbers
+    in the execution environment).
+  - The option NO_MULTI_FUNCDEF can turn off multiple definition of
+    functions at once, a rarely used feature that can cause problems
+    with misplaced "()".
+  - The "fc" builtin has been enhanced to make non-interactive use possible
+    and output consistent when the history is manipulated with "print -s".
+
+The completion style accept-exact-dirs has been added.  When true, this
+suppresses attempts to complete non-final directory segments of a filename
+path when the directory exists.  (For example, /home/pws/src/zsh/<TAB>
+discovers that /home/pws/src/zsh exists and leaves the directory component
+alone, while /h/p/s/z/<TAB> completes to /home/pws/src/zsh/... as before.)
+This should improve completion behaviour noticeably in special cases, such
+as remote paths under Cygwin.
+
+Major changes between versions 4.3.5 and 4.3.6
+----------------------------------------------
+
+cd, chdir, pushd and popd now take a -q option to suppress side effects
+including printing the directory stack (for pushd and popd) and executing
+the chpwd hook functions (for all four).
+
+The parameter subscript (e) flag now forces the argument to be treated
+as a string where it would previously have been treated as a pattern,
+for example ${array[(ie)*]} substitutes the index of the element whose
+value is "*".
+
+Major changes between versions 4.3.4 and 4.3.5
+----------------------------------------------
+
+- The new extended globbing flag (#cN,M) behaves similarly to the extended
+  regular expression syntax {N,M}.
+
+- The zsh/datetime module has been enhanced and a calendar function
+  system has been added along the lines of (but much enhanced from)
+  the traditional Unix "calendar" utility.  This is still under
+  development.  See the zshcalsys manual.  (The calendar functions
+  were in 4.3.4 but were not listed in this file.  There have been
+  significant enhancements since 4.3.4.)
+
+- A new module zsh/curses provides a builtin zcurses for access to
+  to the curses screen manipulation package.  See the entry for zsh/curses
+  in the zshmodules manual.
+
+- The module system has been enhanced to support the notion of "features"
+  that give more control over which builtins, parameters, conditions
+  and math functions are loaded from a module.  In particular,
+  "zmodload -F zsh/stat b:zstat" makes the builtin previously called
+  "stat" available as "zstat" (only) to avoid clashes with a system
+  command named "stat".
+
+Major changes between versions 4.2 and 4.3.4
+--------------------------------------------
+
+- There is support for multibyte character sets.  This is now reasonably
+  close to complete, although Unicode combining characters don't work
+  properly.  See Multibyte Character Support in INSTALL.
+
+- The shell can now run an installation function for a new user
+  (a user with no .zshrc, .zshenv, .zprofile or .zlogin file) without
+  any additional setting up by the administrator.  See "THE ZSH/NEWUSER
+  MODULE" in the zshmodules manual page.
+
+- The manual now has a Roadmap section (manual page zshroadmap) to
+  give new users an indication of the most interesting parts of the
+  manual.
+
+- New option PROMPT_SP (on by default): works around the problem that the
+  line editor can overwrite output with no newline at the end.  See the
+  zshoptions manual page.
+
+- New option HIST_SAVE_BY_COPY (on by default): history is saved by
+  copying and renaming instead of directly overwriting.  See the
+  zshoptions manual page.
+
+- New redirection syntax e.g. {myfd}>file opens a new file descriptor
+  and stores the number in $myfd, so that >&$myfd will work.  Chosen
+  not to break existing code (and to be compatible with proposals for the
+  Korn shell).  See the section REDIRECTION in the zshmisc manual page.
+
+- Substitutions of the form ${var:-"$@"}, ${var:+"$@"} and similar where
+  word-splitting is applied to the text after the :- or :+ (in particular,
+  where the SH_WORD_SPLIT option is in effect for compatibility) now
+  behave as in other Bourne- and POSIX-compatible shells when in the
+  appropriate emulation mode.
+
+- New Posix-style zsh-specific tests [[:IDENT:]], [[:IFS:]],
+  [[:IFSSPACE:]], [[:WORD:]] test if character can appear in identifier,
+  is an IFS character, is an IFS whitespace character, or is considered
+  as part of a word (is alphanumeric or appears in $WORDCHARS).  These
+  works correctly on multibyte characters if the appropriate support
+  is present.  See the section FILENAME GENERATION in the zshexpn
+  manual page.
+
+- Time comparisons on files when sorting or using test operators will
+  use high-resolution timestamps when available.  This gives a
+  resolution of a nanosecond instead of a second.
+
+- The idiom =(<<<...) is optimised so that the shell internally turns
+  the ... into the contents of a file whose name is then substituted.
+  The syntax has always been usable by means of the NULLCMD feature,
+  but previously it generated an intermediate process; it has now
+  been rewritten along the same lines as the optimisation for $(<...)
+  that inserts a file into the command line without the use of an
+  external programme.
+
+- Supplied functions catch and throw provide limited support for
+  exception handling using the `{ ... } always { ... }' syntax.
+  See the section EXCEPTION HANDLING in the zshcontrib manual page.
+
+- Signals now accept the SIG as part of the name for compatibility with
+  other shells.
+
+- Editor function argument-base allows non-decimal arguments for
+  editor widgets.  See the entry in the zshzle manual page.
+
+- As always, there are many enhancements to completion functions.

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


^ permalink raw reply	[relevance 8%]

* Re: Possible 4.3.18?
  @ 2012-06-15 18:42  4%   ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2012-06-15 18:42 UTC (permalink / raw)
  To: zsh-workers

On Mon, 11 Jun 2012 17:24:03 +0100
Peter Stephenson <Peter.Stephenson@csr.com> wrote:
> Next proper release should be 5.0.0.  I don't think there's anything
> major standing in the way of that, however it does require a bit more
> thinking about what's missing and a bit more documentation about what
> still doesn't work which I haven't done yet.

I can't see anything obvious that needs changing, apart for a few minor
documentation updates.

Phil was suggesting he might need to make a change before big release,
is that still the case?

> It probably needs a few more cycles of testing than usual, even when
> everything's sorted out, so I wouldn't expect it to be instant.

I'll start producing test releases shortly: as usually they'll be
4.3.17-test-* until the actual release to preserve version number
ordering.  It would be good to get the MACHINES file up to date.

Index: FEATURES
===================================================================
RCS file: /cvsroot/zsh/zsh/FEATURES,v
retrieving revision 1.4
diff -p -u -r1.4 FEATURES
--- FEATURES	13 Jan 2010 12:05:26 -0000	1.4
+++ FEATURES	15 Jun 2012 18:38:38 -0000
@@ -2,6 +2,10 @@
 ZSH FEATURES
 ------------
 
+(Note that this file only lists basic shell features, for those who
+may not have encountered zsh before.  Those familiar with zsh are
+unlikely to find anything new here.)
+
 very close to ksh/sh grammar, with csh additions
 most features of ksh, bash, and tcsh
 can emulate ksh or POSIX sh
Index: README
===================================================================
RCS file: /cvsroot/zsh/zsh/README,v
retrieving revision 1.76
diff -p -u -r1.76 README
--- README	23 Feb 2012 21:39:30 -0000	1.76
+++ README	15 Jun 2012 18:38:38 -0000
@@ -5,11 +5,11 @@ THE Z SHELL (ZSH)
 Version
 -------
 
-This is version 4.3.17 of the shell.  This is a development release,
-but is believed to be reasonably stable.  Sites where the users need to
-edit command lines with multibyte characters (in particular UTF-8)
-will probably want to upgrade.  The previous widely released version
-of the shell was 4.3.15.
+This is version 5.0.0 of the shell.  This is a stable release.
+There have been only incremental changes since the last development
+version, 4.3.17.  The new major version number represents the
+substantial changes since the 4.2 stable release series.  The
+changes are detailed in the file NEWS.
 
 Installing Zsh
 --------------
@@ -33,16 +33,8 @@ details, see the documentation.
 Possible incompatibilities
 ---------------------------
 
-In some 4.3.X releases of zsh, the completion system added a ".."  as a
-trial completion whenever completing directories.  This was a bug: as
-documented in the zshcompsys manual, this feature needs to be turned on by
-a style:
-
-  zstyle ':completion:*' special-dirs true
-
-
-The rest of this section documents incompatibilities in the shell since the
-4.2 series of releases.
+Here are some incompatibilities in the shell since the 4.2 series of
+releases.  It is hoped most users will not be adversely affected by these.
 
 In previous releases of the shell, builtin commands and precommand
 modifiers that did not accept options also did not recognize the
Index: Etc/FAQ.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Etc/FAQ.yo,v
retrieving revision 1.64
diff -p -u -r1.64 FAQ.yo
--- Etc/FAQ.yo	7 Mar 2012 06:10:42 -0000	1.64
+++ Etc/FAQ.yo	15 Jun 2012 18:38:39 -0000
@@ -52,8 +52,8 @@ myreport(Z-Shell Frequently-Asked Questi
 COMMENT(-- the following are for Usenet and must appear first)\
 description(\
 mydit(Archive-Name:) unix-faq/shell/zsh
-mydit(Last-Modified:) 2010/02/15
-mydit(Submitted-By:) email(pws@pwstephenson.fsnet.co.uk (Peter Stephenson))
+mydit(Last-Modified:) 2012/06/15
+mydit(Submitted-By:) email(coordinator@zsh.org (Peter Stephenson))
 mydit(Posting-Frequency:) Monthly
 mydit(Copyright:) (C) P.W. Stephenson, 1995--2010 (see end of document)
 )
@@ -301,13 +301,9 @@ sect(On what machines will it run?)
 
 sect(What's the latest version?)
 
-  Zsh 4.2.7 is the latest production version.  The latest development
-  version is 4.3.17; this contains support for multibyte character strings
-  (such as UTF-8 locales).  All the main features for multibyte
-  support are now in place and this is likely soon to become the
-  stable series 5.0.
-
-  There will not be any further 4.2 releases.
+  Zsh 5.0.0 is the latest production version, replacing the now
+  rather antiquated 4.2.7.  For details of all the changes, see
+  the NEWS file in the source distribution.
 
   A beta of the next version is sometimes available.  Development of zsh is
   patch by patch, with each intermediate version publicly available.  Note

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


^ permalink raw reply	[relevance 4%]

* Re: zsh 5.0.0 released, finally
  @ 2012-07-24 16:11 12%   ` Simon Ruderich
  0 siblings, 0 replies; 200+ results
From: Simon Ruderich @ 2012-07-24 16:11 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1525 bytes --]

On Tue, Jul 24, 2012 at 05:59:53PM +0200, Simon Ruderich wrote:
>
> I updated the website for 5.0.0 [1]. The commits are in the
> public web repository [2] (199c59f..7e0689e; tag zsh-5.0.0). If
> you find any problems/mistakes please inform me.
>
> [snip]

I noticed two typos in NEWS, the following patch fixes them:

diff --git a/NEWS b/NEWS
index 23097b6..68a9935 100644
--- a/NEWS
+++ b/NEWS
@@ -29,7 +29,7 @@ Here is a summary of the most significant changes:
 - The zshroadmap manual page provides a slightly more helpful
   introduction to the shell manual than was previously available.
 
-- There have been some notable enhancements to POSIX comptability
+- There have been some notable enhancements to POSIX compatibility
   when the shell is in a corresponding emulation (e.g. "emulate sh").
 
 Expansion (parameters, globbing, etc.) and redirection
@@ -78,7 +78,7 @@ Expansion (parameters, globbing, etc.) and redirection
   calculated by the (l) and (r) flags or the # operator should take
   account of the printing width of characters in multibyte mode, whether
   0, 1 or more.  (mm) causes printing characters to count as 1 and
-  non-printing chracters to count as 0.
+  non-printing characters to count as 0.
 
 - The parameter substitution flag (q-) picks the most minimal way of
   quoting the parameter words, to make the result as readable as possible.

Regards,
Simon
-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[relevance 12%]

* Re: pkgsrc patches for zsh [was Re: tgoto issue in zsh-5.0.0]
  @ 2012-08-17  9:38  4%               ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2012-08-17  9:38 UTC (permalink / raw)
  To: Thomas Klausner, zsh-workers

On Fri, 17 Aug 2012 10:11:09 +0200
Thomas Klausner <tk@giga.or.at> wrote:
> One more issue: Recently NetBSD added support for per-user thread (not
> process) limits. zsh doesn't seem to support this.

It should be as simple as this, though I can't test it directly.

Index: configure.ac
===================================================================
RCS file: /cvsroot/zsh/zsh/configure.ac,v
retrieving revision 1.139
diff -p -u -r1.139 configure.ac
--- configure.ac	21 Jun 2012 08:45:02 -0000	1.139
+++ configure.ac	17 Aug 2012 09:36:54 -0000
@@ -1799,6 +1799,7 @@ zsh_LIMIT_PRESENT(RLIMIT_AS)
 zsh_LIMIT_PRESENT(RLIMIT_LOCKS)
 zsh_LIMIT_PRESENT(RLIMIT_MEMLOCK)
 zsh_LIMIT_PRESENT(RLIMIT_NPROC)
+zsh_LIMIT_PRESENT(RLIMIT_NTHR)
 zsh_LIMIT_PRESENT(RLIMIT_NOFILE)
 zsh_LIMIT_PRESENT(RLIMIT_PTHREAD)
 zsh_LIMIT_PRESENT(RLIMIT_RSS)
Index: Doc/Zsh/builtins.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v
retrieving revision 1.139
diff -p -u -r1.139 builtins.yo
--- Doc/Zsh/builtins.yo	16 Aug 2012 14:00:11 -0000	1.139
+++ Doc/Zsh/builtins.yo	17 Aug 2012 09:36:54 -0000
@@ -1738,7 +1738,7 @@ enditem()
 findex(ulimit)
 cindex(resource limits)
 cindex(limits, resource)
-item(tt(ulimit) [ [ tt(-SHacdfilmnpqstvx) | tt(-N) var(resource) [ var(limit) ] ... ])(
+item(tt(ulimit) [ [ tt(-SHacdfilmnpqrstvx) | tt(-N) var(resource) [ var(limit) ] ... ])(
 Set or display resource limits of the shell and the processes started by
 the shell.  The value of var(limit) can be a number in the unit specified
 below or one of the values `tt(unlimited)', which removes the limit on the
@@ -1759,6 +1759,9 @@ When looping over multiple resources, th
 it detects a badly formed argument.  However, if it fails to set a limit
 for some other reason it will continue trying to set the remaining limits.
 
+Not all the following resources are supported on all systems.  Running
+tt(ulimit -a) will show which are supported.
+
 startsitem()
 sitem(tt(-a))(Lists all of the current resource limits.)
 sitem(tt(-c))(512-byte blocks on the size of core dumps.)
@@ -1771,7 +1774,8 @@ sitem(tt(-n))(open file descriptors.)
 sitem(tt(-q))(Bytes in POSIX message queues.)
 sitem(tt(-s))(K-bytes on the size of the stack.)
 sitem(tt(-t))(CPU seconds to be used.)
-sitem(tt(-u))(processes available to the user.)
+sitem(tt(-r))(The number of simultaneous threads available to the user.)
+sitem(tt(-u))(The number of processes available to the user.)
 sitem(tt(-v))(K-bytes on the size of virtual memory.  On some systems this
 refers to the limit called `address space'.)
 sitem(tt(-x))(The number of locks on files.)
Index: Src/Builtins/rlimits.awk
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Builtins/rlimits.awk,v
retrieving revision 1.9
diff -p -u -r1.9 rlimits.awk
--- Src/Builtins/rlimits.awk	19 Jun 2011 00:10:34 -0000	1.9
+++ Src/Builtins/rlimits.awk	17 Aug 2012 09:36:54 -0000
@@ -42,6 +42,7 @@ BEGIN {limidx = 0}
 	    if (limnam == "MEMLOCK") { msg[limnum] = "Mmemorylocked" }
 	    if (limnam == "NOFILE")  { msg[limnum] = "Ndescriptors" }
 	    if (limnam == "NPROC")   { msg[limnum] = "Nmaxproc" }
+	    if (limnam == "NTHR")    { msg[limnum] = "Nmaxthr" }
 	    if (limnam == "OFILE")   { msg[limnum] = "Ndescriptors" }
 	    if (limnam == "PTHREAD") { msg[limnum] = "Nmaxpthreads" }
 	    if (limnam == "RSS")     { msg[limnum] = "Mresident" }
Index: Src/Builtins/rlimits.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Builtins/rlimits.c,v
retrieving revision 1.25
diff -p -u -r1.25 rlimits.c
--- Src/Builtins/rlimits.c	31 Oct 2011 09:48:59 -0000	1.25
+++ Src/Builtins/rlimits.c	17 Aug 2012 09:36:54 -0000
@@ -314,6 +314,12 @@ printulimit(char *nam, int lim, int hard
 	    printf("-u: processes                  ");
 	break;
 # endif /* HAVE_RLIMIT_NPROC */
+# ifdef HAVE_RLIMIT_NTHR
+    case RLIMIT_NTHR:
+	if (head)
+	    printf("-r: threads                    ");
+	break;
+#endif /* HAVE_RLIMIT_NTHR */
 # if defined(HAVE_RLIMIT_VMEM) && (!defined(HAVE_RLIMIT_RSS) || !defined(RLIMIT_VMEM_IS_RSS))
     case RLIMIT_VMEM:
 	if (head)
@@ -791,6 +797,11 @@ bin_ulimit(char *name, char **argv, UNUS
 		    res = RLIMIT_NOFILE;
 		    break;
 # endif /* HAVE_RLIMIT_NOFILE */
+# ifdef HAVE_RLIMIT_NTHR
+		case 'r':
+		    res = RLIMIT_NTHR;
+		    break;
+# endif /* HAVE_RLIMIT_NTHR */
 # ifdef HAVE_RLIMIT_NPROC
 		case 'u':
 		    res = RLIMIT_NPROC;

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[relevance 4%]

* PATCH: (provisional) underscores in constants in numeric evaluation
@ 2012-08-30 14:11  3% Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2012-08-30 14:11 UTC (permalink / raw)
  To: Zsh Hackers' List

Another of those occasions when "wouldn't it be helpful if..." toppled
over the edge into frustration.

Some scripting languages allow dummy "_"s in numeric constants so you
can count the decimal places.  This is very convenient if you're doing
arithmetic with large integers.

It seems to me (watch this assumption closely) that if we restrict this
to handling constants in arithmetic evaluation, where we already know we
require a numeric constant and we already know the syntax needs to be
that of an arithmetic expression, all substitutions having been done
by this point, we can get away with doing this without a new option.  It
would not be safe to modify zstrtol() to do this more widely.

A quick poll of Perl and Ruby suggests they both allow underscores in
decimal constants.  That's the messiest (and least efficient) part of
this patch --- but it should be safe.  I don't fancy replacing
strtod(); floating point numbers need careful handling.

I won't be committing this any time particularly soon.

Index: Src/math.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/math.c,v
retrieving revision 1.41
diff -p -u -r1.41 math.c
--- Src/math.c	19 Jun 2011 16:26:11 -0000	1.41
+++ Src/math.c	30 Aug 2012 13:55:36 -0000
@@ -452,7 +452,7 @@ lexconstant(void)
 	nptr++;
 	if (*nptr == 'x' || *nptr == 'X') {
 	    /* Let zstrtol parse number with base */
-	    yyval.u.l = zstrtol(ptr, &ptr, 0);
+	    yyval.u.l = zstrtol_underscore(ptr, &ptr, 0, 1);
 	    /* Should we set lastbase here? */
 	    lastbase = 16;
 	    return NUM;
@@ -466,13 +466,13 @@ lexconstant(void)
 	     * it can't be a base indication (always decimal)
 	     * or a floating point number.
 	     */
-	    for (ptr2 = nptr; idigit(*ptr2); ptr2++)
+	    for (ptr2 = nptr; idigit(*ptr2) || *ptr2 == '_'; ptr2++)
 		;
 
 	    if (ptr2 > nptr && *ptr2 != '.' && *ptr2 != 'e' &&
 		*ptr2 != 'E' && *ptr2 != '#')
 	    {
-		yyval.u.l = zstrtol(ptr, &ptr, 0);
+		yyval.u.l = zstrtol_underscore(ptr, &ptr, 0, 1);
 		lastbase = 8;
 		return NUM;
 	    }
@@ -481,17 +481,43 @@ lexconstant(void)
     }
     else
     {
-	while (idigit(*nptr))
+	while (idigit(*nptr) || *nptr == '_')
 	    nptr++;
     }
 
     if (*nptr == '.' || *nptr == 'e' || *nptr == 'E') {
+	char *ptr2;
 	/* it's a float */
 	yyval.type = MN_FLOAT;
 #ifdef USE_LOCALE
 	prev_locale = dupstring(setlocale(LC_NUMERIC, NULL));
 	setlocale(LC_NUMERIC, "POSIX");
 #endif
+	if (*nptr == '.') {
+	    nptr++;
+	    while (idigit(*nptr) || *nptr == '_')
+		nptr++;
+	}
+	if (*nptr == 'e' || *nptr == 'E') {
+	    nptr++;
+	    if (*nptr == '+' || *nptr == '-')
+		nptr++;
+	    while (idigit(*nptr) || *nptr == '_')
+		nptr++;
+	}
+	for (ptr2 = ptr; ptr2 < nptr; ptr2++) {
+	    if (*ptr2 == '_') {
+		int len = nptr - ptr;
+		ptr = strdup(ptr);
+		for (ptr2 = ptr; len; len--) {
+		    if (*ptr2 == '_')
+			chuck(ptr2);
+		    else
+			ptr2++;
+		}
+		break;
+	    }
+	}
 	yyval.u.d = strtod(ptr, &nptr);
 #ifdef USE_LOCALE
 	if (prev_locale) setlocale(LC_NUMERIC, prev_locale);
@@ -503,11 +529,12 @@ lexconstant(void)
 	ptr = nptr;
     } else {
 	/* it's an integer */
-	yyval.u.l = zstrtol(ptr, &ptr, 10);
+	yyval.u.l = zstrtol_underscore(ptr, &ptr, 10, 1);
 
 	if (*ptr == '#') {
 	    ptr++;
-	    yyval.u.l = zstrtol(ptr, &ptr, lastbase = yyval.u.l);
+	    lastbase = yyval.u.l;
+	    yyval.u.l = zstrtol_underscore(ptr, &ptr, lastbase, 1);
 	}
     }
     return NUM;
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.270
diff -p -u -r1.270 utils.c
--- Src/utils.c	27 Jun 2012 07:10:29 -0000	1.270
+++ Src/utils.c	30 Aug 2012 13:55:36 -0000
@@ -2030,13 +2030,20 @@ skipparens(char inpar, char outpar, char
    return level;
 }
 
+/**/
+mod_export zlong
+zstrtol(const char *s, char **t, int base)
+{
+    return zstrtol_underscore(s, t, base, 0);
+}
+
 /* Convert string to zlong (see zsh.h).  This function (without the z) *
  * is contained in the ANSI standard C library, but a lot of them seem *
  * to be broken.                                                       */
 
 /**/
 mod_export zlong
-zstrtol(const char *s, char **t, int base)
+zstrtol_underscore(const char *s, char **t, int base, int underscore)
 {
     const char *inp, *trunc = NULL;
     zulong calc = 0, newcalc = 0;
@@ -2062,22 +2069,24 @@ zstrtol(const char *s, char **t, int bas
     if (base < 2 || base > 36) {
 	zerr("invalid base (must be 2 to 36 inclusive): %d", base);
 	return (zlong)0;
-    } else if (base <= 10)
-	for (; *s >= '0' && *s < ('0' + base); s++) {
-	    if (trunc)
+    } else if (base <= 10) {
+	for (; (*s >= '0' && *s < ('0' + base)) ||
+		 (underscore && *s == '_'); s++) {
+	    if (trunc || *s == '_')
 		continue;
 	    newcalc = calc * base + *s - '0';
 	    if (newcalc < calc)
 	    {
-	      trunc = s;
-	      continue;
+		trunc = s;
+		continue;
 	    }
 	    calc = newcalc;
 	}
-    else
+    } else {
 	for (; idigit(*s) || (*s >= 'a' && *s < ('a' + base - 10))
-	     || (*s >= 'A' && *s < ('A' + base - 10)); s++) {
-	    if (trunc)
+	     || (*s >= 'A' && *s < ('A' + base - 10))
+	     || (underscore && *s == '_'); s++) {
+	    if (trunc || *s == '_')
 		continue;
 	    newcalc = calc*base + (idigit(*s) ? (*s - '0') : (*s & 0x1f) + 9);
 	    if (newcalc < calc)
@@ -2087,6 +2096,7 @@ zstrtol(const char *s, char **t, int bas
 	    }
 	    calc = newcalc;
 	}
+    }
 
     /*
      * Special case: check for a number that was just too long for

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[relevance 3%]

* Bug with long multiline strings?
@ 2012-10-24 15:21  2% Frank Terbeck
  0 siblings, 0 replies; 200+ results
From: Frank Terbeck @ 2012-10-24 15:21 UTC (permalink / raw)
  To: zsh-workers

Hi workers!

I've tried to reproduce

  <https://bugs.launchpad.net/ubuntu/+source/zsh/+bug/1070820>


Turns out, I can:

[snip]
i-(6000)-~% echo "asdf
dquote> asdf
dquote> asdf
dquote> asdf
dquote> asdf
dquote> asfd
dquote> asdf
dquote> asdf
dquote> asdf
dquote> asdf
dquote> asdf
dquote> asdf
dquote> asdf
 mem.c:604: BUG: hrealloc() called for non-heap memory.
[1]    2554 segmentation fault (core dumped)  zsh
[snap]

Backtrace:

[snip]
Reading symbols from /usr/local/bin/zsh...done.
[New LWP 2554]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `zsh'.
Program terminated with signal 11, Segmentation fault.
#0  0x0000000000460225 in hrealloc (p=0x7f1e52779050 "\232asdf\nasdf\nasdf\nasdf\nasdf\nasfd\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasd%_> ", old=64, new=128) at mem.c:605
605	    DPUTS(h->sp && arena(h) + h->sp->used > p,
(gdb) #0  0x0000000000460225 in hrealloc (p=0x7f1e52779050 "\232asdf\nasdf\nasdf\nasdf\nasdf\nasfd\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasd%_> ", old=64, new=128) at mem.c:605
        h = 0x0
        ph = 0x7f1e52772000
#1  0x0000000000456291 in add (c=100) at lex.c:575
        newbsiz = 128
#2  0x00000000004583ea in dquote_parse (endchar=34 '"', sub=0) at lex.c:1576
        pct = 0
        brct = 0
        bct = 0
        intick = 0
        err = 0
        c = 100
        math = 0
        zlemath = 0
#3  0x0000000000457b2a in gettokstr (c=34, sub=0) at lex.c:1371
        act = 15
        e = 34
        inbl = 0
        bct = 0
        pct = 0
        brct = 0
        fdpar = 0
        intpos = 1
        in_brace_param = 0
        peek = 34
        inquote = -1189248448
        unmatched = 0
        ocmdsp = 0
#4  0x0000000000457061 in gettok () at lex.c:993
        c = 34
        d = -1189248128
        peekfd = -1
        peek = 32767
#5  0x0000000000455d73 in zshlex () at lex.c:395
No locals.
#6  0x0000000000479a87 in par_simple (complex=0x7fffb91d8448, nr=0) at parse.c:1678
        redir_var = 0
        oecused = 3
        isnull = 1
        r = 3
        argc = 1
        p = 3
        isfunc = 0
        sr = 0
        c = 0
        nrediradd = 0
        assignments = 0
#7  0x0000000000477857 in par_cmd (complex=0x7fffb91d8448) at parse.c:879
        sr = 0
        r = 3
        nr = 0
#8  0x00000000004772f3 in par_pline (complex=0x7fffb91d8448) at parse.c:728
        p = 2
        line = 1
#9  0x00000000004772ac in par_sublist2 (complex=0x7fffb91d8448) at parse.c:709
        f = 0
#10 0x000000000047713d in par_sublist (complex=0x7fffb91d8470) at parse.c:664
        f = 4545929
        p = 1
        c = 1
#11 0x0000000000476b58 in par_event () at parse.c:477
        r = 0
        p = 0
        c = 0
#12 0x0000000000476ad2 in parse_event () at parse.c:454
No locals.
#13 0x0000000000448f34 in loop (toplevel=1, justonce=0) at init.c:132
        prog = 0x7fffb91d84e0
        err = 0
        non_empty = 0
#14 0x000000000044c6c5 in zsh_main (argc=1, argv=0x7fffb91d8648) at init.c:1567
        t = 0x7fffb91d8650
        runscript = 0x0
        t0 = 158
#15 0x000000000041024c in main (argc=1, argv=0x7fffb91d8648) at ./main.c:93
No locals.
[snap]

Information about this system:

% echo $ZSH_VERSION-$ZSH_PATCHLEVEL
5.0.0-dev-0-1.5699

% uname -srm
Linux 3.2.0-3-amd64 x86_64

% /lib32/libc.so.6
GNU C Library (Debian EGLIBC 2.13-35) stable release version 2.13, by
Roland McGrath et al.
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.4.7.
Compiled on a Linux 3.2.21 system on 2012-07-22.
Available extensions:
        crypt add-on version 2.1 by Michael Glad and others
        GNU Libidn by Simon Josefsson
        Native POSIX Threads Library by Ulrich Drepper et al
        BIND-8.2.3-T5B
libc ABIs: UNIQUE IFUNC
For bug reporting instructions, please see:
<http://www.debian.org/Bugs/>.



Regards, Frank


^ permalink raw reply	[relevance 2%]

* Re: Function code breaking out of if then ...fi
  @ 2012-11-05 14:29  3%   ` Peter Stephenson
    0 siblings, 1 reply; 200+ results
From: Peter Stephenson @ 2012-11-05 14:29 UTC (permalink / raw)
  To: zsh-workers

n Fri, 02 Nov 2012 14:39:11 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:

> On Nov 2, 10:09am, Michal Maruska wrote:
> }
> } I wonder if the following behaviour is a bug, or
> } simply my wrong expectation:
> } 
> } This script, assuming the globbing fails, and I'm not using
> NULL_GLOB, } does not bother finishing the commands in the
> "then ....fi" block, } instead continues after "fi".
> 
> What slightly surprises me is that a glob failure isn't considered an
> error for purposes of ERR_EXIT (the -e option in your #! line).  I
> would have expected the whole script to quit at that point, but I
> guess glob errors are not treated as command failures because the
> command never executes in the first place.
> 
> However, what *is* happening is that a glob failure in a complex
> command acts in the manner of a "break" statement.

It's not really like a break, it's like (well, is) a global error flag
--- but the error status gets reset at the top level command loop, which
we reach in a script after the end of a set of complex commands --- but
only right at the end, when we're reading a new (possibly complex,
arbitrarily nested) command from the script.

I think actually what's going on could be considered a bug which is an
oversight for the case of scripts.  If the code was running a function,
the failure would cause it to skip right to the end of the function,
indeed any arbitrarily nested hierarchy of functions.  If we took the
rough equivalence between functions and scripts seriously, any hard
error (zerr() or zerrnam()) would cause a script to exit in the same
way.  Interactively, the error flag would still get reset but
non-interactively it wouldn't.

I don't see anything in the documentation to suggest that the top-level
command loop should be special non-interactively in the way it currently
is.  Indeed, when documenting try- and always-blocks, I wrote:

  An `error' in this context is a condition such as a syntax error
  which causes the shell to abort execution of the  current  func‐
  tion,  script,  or  list.
         ^^^^^^

which is clearly not true.  If there's a more fundamental description
of what happens on an error, I don't know where it is.

Indeed, it looks to me that without this the shell is violating the
"shall exit" terms of POSIX, section 2.8.1 of the shell command
language.  To use the example they give, this script

echo "${x!y}"
echo Got here

shouldn't print anything apart from the error message, but does.

pws


^ permalink raw reply	[relevance 3%]

* Re: Function code breaking out of if then ...fi
  @ 2012-11-05 16:08  9%       ` Peter Stephenson
  2012-11-09 22:52 12%       ` Peter Stephenson
  1 sibling, 0 replies; 200+ results
From: Peter Stephenson @ 2012-11-05 16:08 UTC (permalink / raw)
  To: zsh-workers

Another inconsistency with error handling...

% fn() { setopt mumbly; print Got here; }
% fn
fn:setopt: no such option: mumbly
Got here
% fn() { set -o mumbly; print Got here; }
% fn
fn:set: no such option: mumbly

This is because set is a POSIX special builtin but setopt isn't.  It
should be documented, however.

Index: Doc/Zsh/builtins.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v
retrieving revision 1.145
diff -p -u -r1.145 builtins.yo
--- Doc/Zsh/builtins.yo	11 Oct 2012 20:14:03 -0000	1.145
+++ Doc/Zsh/builtins.yo	5 Nov 2012 16:06:10 -0000
@@ -1361,6 +1361,11 @@ or without the tt(no) prefix remains the
 If the tt(-m) flag is given the arguments are taken as patterns
 (which should be quoted to protect them from filename expansion), and all
 options with names matching these patterns are set.
+
+Note that a bad option name does not cause execution of shell code
+to be aborted; this is different from `tt(set -o)'.  This is because
+tt(set) is regarded as a special builtin by the POSIX standard,
+but tt(setopt) is not.
 )
 findex(shift)
 cindex(parameters, positional)

pws


^ permalink raw reply	[relevance 9%]

* bug in parameter expansion
@ 2012-11-07 19:13  3% Scott Moser
  2012-11-07 20:45  2% ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Scott Moser @ 2012-11-07 19:13 UTC (permalink / raw)
  To: zsh-workers

This issue was initially reported against shell code delivered in
cloud-init at [1], but it seems to me to be a bug in zsh's posix shell
behavior.

$ for shell in /bin/dash /bin/bash /bin/ksh /bin/zsh; do \
  echo "=== $shell ==="; $shell -c 'echo "${1%%=*}"' \
  -- A=B; done
=== /bin/dash ===
A
=== /bin/bash ===
A
=== /bin/ksh ===
A
=== /bin/zsh ===
zsh:1: * not found

It also has the issue when matching prefix (#):
$ zsh -c 'echo ${1#=?}' -- =AB
zsh:1: ? not found
$ bash -c 'echo ${1#=?}' -- =AB
B

It is seemingly easily worked around by escaping the '=' like:
  $ zsh -c 'echo "${1%%\=*}"' -- A=B
  A
or:
  zsh -c 'equal="="; echo "${1%%${equal}*}"' -- A=B
  A

Scott
--
[1] https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1073077


^ permalink raw reply	[relevance 3%]

* Re: bug in parameter expansion
  2012-11-07 19:13  3% bug in parameter expansion Scott Moser
@ 2012-11-07 20:45  2% ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2012-11-07 20:45 UTC (permalink / raw)
  To: zsh-workers

On Wed, 7 Nov 2012 14:13:36 -0500 (EST)
Scott Moser <smoser@ubuntu.com> wrote:
> This issue was initially reported against shell code delivered in
> cloud-init at [1], but it seems to me to be a bug in zsh's posix shell
> behavior.

As it happens, that's not quite true, because zsh doesn't have POSIX
behaviour by default, and it will work as you expect if you invoke it as
sh or "setopt noequals".

It's still pretty funny, even in the native mode, though.  That's a very
strange place for =-expansion to happen.

It's happening because we look at the string "=*" and we tokenise that to
make patterns (such as the "*") active if it was in quotes.  We tokenise
the "=" the same as if it were a command line argument.  I can't think
of any occasion we'd want to do that if we know it's *not* a command
line argument: there's already a flag for this, so the fix is simple.
Maybe someone can think of a pathological case where we should do the
=-expansion (or =(...) expansion) even in a substituted string, but
I can't think of one.  This doesn't trigger any test failures.

Index: Src/lex.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/lex.c,v
retrieving revision 1.73
diff -p -u -r1.73 lex.c
--- Src/lex.c	5 Oct 2012 21:35:06 -0000	1.73
+++ Src/lex.c	7 Nov 2012 20:37:05 -0000
@@ -1265,51 +1265,53 @@ gettokstr(int c, int sub)
 		break;
 	    goto brk;
 	case LX2_EQUALS:
-	    if (intpos) {
-		e = hgetc();
-		if (e != '(') {
-		    hungetc(e);
-		    lexstop = 0;
-		    c = Equals;
-		} else {
-		    add(Equals);
-		    if (skipcomm()) {
-			peek = LEXERR;
-			goto brk;
-		    }
-		    c = Outpar;
-		}
-	    } else if (!sub && peek != ENVSTRING &&
-		       incmdpos && !bct && !brct) {
-		char *t = tokstr;
-		if (idigit(*t))
-		    while (++t < bptr && idigit(*t));
-		else {
-		    int sav = *bptr;
-		    *bptr = '\0';
-		    t = itype_end(t, IIDENT, 0);
-		    if (t < bptr) {
-			skipparens(Inbrack, Outbrack, &t);
+	    if (!sub) {
+		if (intpos) {
+		    e = hgetc();
+		    if (e != '(') {
+			hungetc(e);
+			lexstop = 0;
+			c = Equals;
 		    } else {
-			*bptr = sav;
+			add(Equals);
+			if (skipcomm()) {
+			    peek = LEXERR;
+			    goto brk;
+			}
+			c = Outpar;
 		    }
-		}
-		if (*t == '+')
-                    t++;
-		if (t == bptr) {
-		    e = hgetc();
-		    if (e == '(' && incmdpos) {
+		} else if (peek != ENVSTRING &&
+			   incmdpos && !bct && !brct) {
+		    char *t = tokstr;
+		    if (idigit(*t))
+			while (++t < bptr && idigit(*t));
+		    else {
+			int sav = *bptr;
 			*bptr = '\0';
-			return ENVARRAY;
+			t = itype_end(t, IIDENT, 0);
+			if (t < bptr) {
+			    skipparens(Inbrack, Outbrack, &t);
+			} else {
+			    *bptr = sav;
+			}
 		    }
-		    hungetc(e);
-		    lexstop = 0;
-		    peek = ENVSTRING;
-		    intpos = 2;
+		    if (*t == '+')
+			t++;
+		    if (t == bptr) {
+			e = hgetc();
+			if (e == '(' && incmdpos) {
+			    *bptr = '\0';
+			    return ENVARRAY;
+			}
+			hungetc(e);
+			lexstop = 0;
+			peek = ENVSTRING;
+			intpos = 2;
+		    } else
+			c = Equals;
 		} else
 		    c = Equals;
-	    } else
-		c = Equals;
+	    }
 	    break;
 	case LX2_BKSLASH:
 	    c = hgetc();

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


^ permalink raw reply	[relevance 2%]

* Re: Function code breaking out of if then ...fi
    2012-11-05 16:08  9%       ` Peter Stephenson
@ 2012-11-09 22:52 12%       ` Peter Stephenson
  1 sibling, 0 replies; 200+ results
From: Peter Stephenson @ 2012-11-09 22:52 UTC (permalink / raw)
  To: zsh-workers

On the behaviour that when the shell encounters a "fatal" error in a
script it resumes at the next "top level" command:  here's a proposal.
This makes that behaviour optional, for compatibility, but turns it off
by default.  I don't think the old, undocumented, behaviour is intuitive
enough for us to go on leaving it as the default.  The shell essentially
skips a chunk of code and resumes later on at a point where there's not
the slightest reason to suppose it's appropriate to do so; you might be
relying on the structure that was previously executing to set things up
for the next chunk of code.

I'm not really even sure we need the option, but it seems possible that
people who happened on the behaviour have become reliant on it.

I've taken the opportunity to document the behaviour on fatal errors.
The list is exhausting rather than exhaustive.  I haven't bothered
listing errors associated with interactive shells where you'd be
returned to the command prompt.

That test at the end was a bit weird:  I don't think it was testing
POSIX_BUILTINS at all since errors with read-only variables are always
hard errors as a grep for the error message will immediately show.
It does provide a useful test for CONTINUE_ON_ERROR.

Index: Doc/Zsh/grammar.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/grammar.yo,v
retrieving revision 1.23
diff -p -u -r1.23 grammar.yo
--- Doc/Zsh/grammar.yo	1 Feb 2012 12:53:49 -0000	1.23
+++ Doc/Zsh/grammar.yo	9 Nov 2012 22:43:30 -0000
@@ -438,7 +438,7 @@ where var(term) is at least one newline 
 A short form of tt(select).
 )
 enditem()
-texinode(Reserved Words)(Comments)(Alternate Forms For Complex Commands)(Shell Grammar)
+texinode(Reserved Words)(Errors)(Alternate Forms For Complex Commands)(Shell Grammar)
 sect(Reserved Words)
 cindex(reserved words)
 findex(disable, use of)
@@ -451,7 +451,56 @@ select coproc nocorrect foreach end ! [[
 
 Additionally, `tt(})' is recognized in any position if neither the
 tt(IGNORE_BRACES) option nor the tt(IGNORE_CLOSE_BRACES) option is set.
-texinode(Comments)(Aliasing)(Reserved Words)(Shell Grammar)
+texinode(Errors)(Comments)(Reserved Words)(Shell Grammar)
+sect(Errors)
+cindex(errors, handling of)
+Certain errors are treated as fatal by the shell: in an interactive
+shell, they cause control to return to the command line, and in a
+non-interactive shell they cause the shell to be aborted.  In older
+versions of zsh, a non-interactive shell running a script would not
+abort completely, but would resume execution at the next command to be
+read from the script, skipping the remainder of any functions or
+shell constructs such as loops or conditions; this somewhat illogical
+behaviour can be recovered by setting the option tt(CONTINUE_ON_ERROR).
+
+Fatal errors found in non-interactive shells include:
+startlist()
+list(Failure to parse shell options passed when invoking the shell)
+list(Failure to change options with the tt(set) builtin)
+list(Parse errors of all sorts, including failures to parse
+mathematical expressions)
+list(Failures to set or modify variable behaviour with tt(typeset),
+tt(local), tt(declare), tt(export), tt(integer), tt(float))
+list(Execution of incorrectly positioned loop control structures
+(tt(continue), tt(break)))
+list(Attempts to use regular expression with no regular expression
+module available)
+list(Disallowed operations when the tt(RESTRICTED) options is set)
+list(Failure to create a pipe needed for a pipeline)
+list(Failure to create a multio)
+list(Failure to autoload a module needed for a declared shell feature)
+list(Errors creating command or process substitutions)
+list(Syntax errors in glob qualifiers)
+list(File generation errors where not caught by the option tt(BAD_PATTERN))
+list(All bad patterns used for matching within case statements)
+list(File generation failures where not caused by tt(NO_MATCH) or
+list(All file generation errors where the pattern was used to create a
+multio)
+list(Memory errors where detected by the shell)
+list(Invalid subscripts to shell variables)
+list(Attempts to assign read-only variables)
+list(Logical errors with variables such as assignment to the wrong type)
+list(Use of invalid variable names)
+list(Errors in variable substitution syntax)
+list(Failure to convert characters in tt($')...tt(') expressions)
+similar options)
+endlist()
+
+If the tt(POSIX_BUILTINS) option is set, more errors associated with
+shell builtin commands are treated as fatal, as specified by the POSIX
+standard.
+
+texinode(Comments)(Aliasing)(Errors)(Shell Grammar)
 sect(Comments)
 cindex(comments)
 pindex(INTERACTIVE_COMMENTS, use of)
Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.107
diff -p -u -r1.107 options.yo
--- Doc/Zsh/options.yo	1 Mar 2012 03:34:15 -0000	1.107
+++ Doc/Zsh/options.yo	9 Nov 2012 22:43:31 -0000
@@ -1733,6 +1733,22 @@ Make the tt(echo) builtin compatible wit
 This disables backslashed escape sequences in echo strings unless the
 tt(-e) option is specified.
 )
+pindex(CONTINUE_ON_ERROR)
+pindex(NO_CONTINUE_ON_ERROR)
+pindex(CONTINUEONERROR)
+pindex(NOCONTINUEONERROR)
+cindex(error, option to continue script on)
+item(tt(CONTINUE_ON_ERROR))(
+If a fatal error is encountered (see 
+ifnzman(noderef(Errors))\
+ifzman(the section ERRORS in zmanref(zshmisc))), and the code is running
+in a script, the shell will resume execution at the next statement
+in the script at the top level, in other words outside all functions
+or shell constructs such as loops and conditions.  This mimics the
+behaviour of interactive shells, where the shell returns to the
+line editor to read a new command; it was the normal behaviour in versions
+of zsh before 5.0.1.
+)
 pindex(CSH_JUNKIE_HISTORY)
 pindex(NO_CSH_JUNKIE_HISTORY)
 pindex(CSHJUNKIEHISTORY)
Index: Src/hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hist.c,v
retrieving revision 1.118
diff -p -u -r1.118 hist.c
--- Src/hist.c	21 Apr 2012 18:42:56 -0000	1.118
+++ Src/hist.c	9 Nov 2012 22:43:31 -0000
@@ -573,7 +573,7 @@ histsubchar(int c)
 		} else {
 		    herrflush();
 		    unqueue_signals();
-		    zerr("Ambiguous history reference");
+		    zerr("ambiguous history reference");
 		    return -1;
 		}
 
Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.127
diff -p -u -r1.127 init.c
--- Src/init.c	11 Oct 2012 20:14:03 -0000	1.127
+++ Src/init.c	9 Nov 2012 22:43:31 -0000
@@ -1608,15 +1608,20 @@ zsh_main(UNUSED(int argc), char **argv)
 	 * We only do this at top level, because if we are
 	 * executing stuff we may refer to them by job pointer.
 	 */
+	int errexit = 0;
 	maybeshrinkjobtab();
 
 	do {
 	    /* Reset return from top level which gets us back here */
 	    retflag = 0;
 	    loop(1,0);
+	    if (errflag && !interact && !isset(CONTINUEONERROR)) {
+		errexit = 1;
+		break;
+	    }
 	} while (tok != ENDINPUT && (tok != LEXERR || isset(SHINSTDIN)));
-	if (tok == LEXERR) {
-	    /* Make sure a parse error exits with non-zero status */
+	if (tok == LEXERR || errexit) {
+	    /* Make sure a fatal error exits with non-zero status */
 	    if (!lastval)
 		lastval = 1;
 	    stopmsg = 1;
Index: Src/options.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/options.c,v
retrieving revision 1.65
diff -p -u -r1.65 options.c
--- Src/options.c	11 Oct 2012 20:14:03 -0000	1.65
+++ Src/options.c	9 Nov 2012 22:43:31 -0000
@@ -113,6 +113,7 @@ static struct optname optns[] = {
 {{NULL, "combiningchars",     0},			 COMBININGCHARS},
 {{NULL, "completealiases",    0},			 COMPLETEALIASES},
 {{NULL, "completeinword",     0},			 COMPLETEINWORD},
+{{NULL, "continueonerror",    0},                        CONTINUEONERROR},
 {{NULL, "correct",	      0},			 CORRECT},
 {{NULL, "correctall",	      0},			 CORRECTALL},
 {{NULL, "cshjunkiehistory",   OPT_EMULATE|OPT_CSH},	 CSHJUNKIEHISTORY},
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.186
diff -p -u -r1.186 zsh.h
--- Src/zsh.h	11 Oct 2012 20:14:03 -0000	1.186
+++ Src/zsh.h	9 Nov 2012 22:43:31 -0000
@@ -1971,6 +1971,7 @@ enum {
     COMPLETEINWORD,
     CORRECT,
     CORRECTALL,
+    CONTINUEONERROR,
     CPRECEDENCES,
     CSHJUNKIEHISTORY,
     CSHJUNKIELOOPS,
Index: Test/A04redirect.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A04redirect.ztst,v
retrieving revision 1.24
diff -p -u -r1.24 A04redirect.ztst
--- Test/A04redirect.ztst	3 Oct 2012 18:11:15 -0000	1.24
+++ Test/A04redirect.ztst	9 Nov 2012 22:43:31 -0000
@@ -419,26 +419,26 @@
 >output
 ?zsh:.:2: no such file or directory: /nonexistent/nonexistent
 
-  $ZTST_testdir/../Src/zsh -f <<<'
+  $ZTST_testdir/../Src/zsh -f -o CONTINUE_ON_ERROR <<<'
   readonly foo
   foo=bar set output
   echo output'
-0:failed assignment on posix special, NO_POSIX_BUILTINS
+0:failed assignment on posix special, CONTINUE_ON_ERROR
 >output
 ?zsh: read-only variable: foo
 
-  $ZTST_testdir/../Src/zsh -f -o POSIX_BUILTINS <<<'
+  $ZTST_testdir/../Src/zsh -f <<<'
   readonly foo
   foo=bar set output
   echo output'
-1:failed assignment on posix special, POSIX_BUILTINS
+1:failed assignment on posix special, NO_CONTINUE_ON_ERROR
 ?zsh: read-only variable: foo
 
-  $ZTST_testdir/../Src/zsh -f -o POSIX_BUILTINS <<<'
+  $ZTST_testdir/../Src/zsh -f -o CONTINUE_ON_ERROR <<<'
   readonly foo
   foo=bar echo output
   echo output'
-0:failed assignment on non-posix-special, POSIX_BUILTINS
+0:failed assignment on non-posix-special, CONTINUE_ON_ERROR
 >output
 ?zsh: read-only variable: foo
 

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


^ permalink raw reply	[relevance 12%]

* PATCH: updated find completion
@ 2012-11-16 22:27 18% Oliver Kiddle
  0 siblings, 0 replies; 200+ results
From: Oliver Kiddle @ 2012-11-16 22:27 UTC (permalink / raw)
  To: Zsh workers

This just adds further new options from GNU findutils. There's plenty
more that could be improved.

Oliver

Index: Completion/Unix/Command/_find
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_find,v
retrieving revision 1.3
diff -u -r1.3 _find
--- Completion/Unix/Command/_find	30 Nov 2007 22:59:01 -0000	1.3
+++ Completion/Unix/Command/_find	16 Nov 2012 22:15:11 -0000
@@ -1,18 +1,23 @@
 #compdef find
 
 _arguments \
+  '(- *)-help' '(-)--help' \
+  '(- *)-version' '(-)--version' \
+  '(-L -P)-H[only follow symlinks when resolving command-line arguments]' \
+  '(-H -P)-L[follow symlinks]' \
+  '(-H -L)-P[never follow symlinks]' \
+  '-D[print diagnostics]:deb option:(help tree search stat rates opt exec)' \
+  '-O+[enable query optimisation]:level:(1 2 3)' \
   '*-daystart' \
-  '*-depth' \
+  '*-d' '*-depth' \
   '*-follow' \
-  '*-help' \
-  '*-ignore_readdir_race' \
-  '*-maxdepth:maximum search depth:' \
-  '*-mindepth:minimum search depth:' \
+  '(-noignore_readdir_race)-ignore_readdir_race' \
+  '*-maxdepth:maximum search depth' \
+  '*-mindepth:minimum search depth' \
   '*-mount' \
-  '*-noignore_readdir_race' \
+  '(-ignore_readdir_race)-noignore_readdir_race' \
   '*-noleaf' \
-  '*-regextype:regexp syntax:(emacs posix-awk posix-basic posix-egrep posix-extended)' \
-  '*-version' \
+  '-regextype:regexp syntax:(emacs posix-awk posix-basic posix-egrep posix-extended)' \
   '*-warn' \
   '*-nowarn' \
   '*-xdev' \
@@ -27,6 +32,7 @@
   '*-newer:file to compare (modification time):_files' \
   '*-used:access after inode change (days):' \
   '*-empty' \
+  '*-executable' \
   '*-false' \
   '*-fstype:file system type:_file_systems' \
   '*-gid:numeric group ID:' \
@@ -48,6 +54,8 @@
   '*-nouser' \
   '*-nogroup' \
   '*-perm:file permission bits:' \
+  '*-readable' \
+  '*-writable' \
   '*-size:file size:' \
   '*-samefile:same inode as:_files' \
   '*-true' \
@@ -68,4 +76,7 @@
   '*-prune' \
   '*-quit' \
   '*-ls' \
+  '*-and' '*-a' \
+  '*-or' '*-o' \
+  '*-not' \
   '*:directory:_files -/'


^ permalink raw reply	[relevance 18%]

* Re: SIGPIPE echoing to fifo exits zsh
  @ 2013-01-16  2:53  2%   ` Bart Schaefer
  2013-01-16  9:44  0%     ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Bart Schaefer @ 2013-01-16  2:53 UTC (permalink / raw)
  To: zsh-workers

On Jan 15,  4:43pm, Christian Neukirchen wrote:
}
} juno% repeat 1000 echo a >/tmp/fifo
} 
} Program received signal SIGPIPE, Broken pipe.
}
} Using /bin/echo (coreutils 8.20), the code works flawlessy (all lines
} get through the FIFO).

On Jan 16,  7:16am, Han Pingtian wrote:
} Subject: Re: SIGPIPE echoing to fifo exits zsh
}
} Looks like the crash occurs at this line in bin_print():
} 
}     4084         /* Testing EBADF special-cases >&- redirections */
}     4085         if ((fout != stdout) ? (fclose(fout) != 0) :
}     4086             (fflush(fout) != 0 && errno != EBADF)) {


Hrm.  If this were a script instead of an interactive command at the
prompt, the correct behavior would in fact be to exit on SIGPIPE.  I
don't know offhand if that's also (per POSIX spec for example) correct
in this instance.

You can prevent the shell from exiting by simply blocking the SIGPIPE
signal:

    trap '' PIPE

As for why the builtin echo gets a SIGPIPE and /bin/echo does not ...
there's a race condition involved.  With the trap above in place, if
you try

    a=0
    repeat 100 echo $((++a)) > /tmp/fifo

you'll probably see something like this on the reading end:

1
5
14
24
34
43
51
60
70
80
89
97
100

What's happening is that the the repeat loop writes a bunch of data to
the pipe (several executions of "echo") before "head -1" wakes up and
reads it.  Then "head" exits, closing the pipe, which SIGPIPE's one of
the echo commands.  A new "head" then re-opens the pipe so another few
passes of the loop go by before there's another exit+SIGPIPE event.

With /bin/echo it takes about the same amount of time for each of the
two loops to spawn their external processes, so the race is much less
likely to happen.

If you put a "sleep 1" or really almost any delay into the repeat loop
-- or use a single command like "cat" that doesn't repeatedly open/close
the read end of the pipe -- you'll see all the lines get through even
with the builtin echo.

You can see this even more glaringly by using

    while :; do head -1 ; done < /tmp/fifo

as the reading end; with that, each run of "head" will consume multiple
lines of the output from the writing end, discard all but the first line
each time, and produce output similar to

1
53
83

without ever triggering the SIGPIPE on the write side.

In short, when using FIFOs, synchronizing the amount of data written/read
by each side is the programmer's job; commands like "head" are not meant
to work that way.


^ permalink raw reply	[relevance 2%]

* Re: SIGPIPE echoing to fifo exits zsh
  2013-01-16  2:53  2%   ` Bart Schaefer
@ 2013-01-16  9:44  0%     ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2013-01-16  9:44 UTC (permalink / raw)
  To: zsh-workers

On Tue, 15 Jan 2013 18:53:41 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> Hrm.  If this were a script instead of an interactive command at the
> prompt, the correct behavior would in fact be to exit on SIGPIPE.  I
> don't know offhand if that's also (per POSIX spec for example) correct
> in this instance.

I tried a few shells and got a roughly 50-50 split.  As far as I could
make out, in fact, bash behaved differently depending whether or not
invoked as "sh", but I haven't looked further.

pws


^ permalink raw reply	[relevance 0%]

* *$var*/* and recursive globbing
@ 2013-01-26 22:25  3% Stephane Chazelas
  0 siblings, 0 replies; 200+ results
From: Stephane Chazelas @ 2013-01-26 22:25 UTC (permalink / raw)
  To: Zsh hackers list

Hiya,

With zsh (but also ksh -G and bash -O globstar),

*"$var"*/* where $var is empty, expands like **/* while it
sounds to me like not the right thing to do. It can be worked
around by doing (*"$var"*)/*, but that requires extended_glob.

I would say that's a case where there's a fair chance to break a
perfectly correct POSIX script (considering that **/ is not
disabled in sh emulation).

I would be of the opinion that **/ (and ***/) should recurse only when
entered as is (or at least the two stars entered as is).

What do you think?
-- 
Stephane


^ permalink raw reply	[relevance 3%]

* PATCH: minor completion function updates
@ 2013-02-21  9:55  2% Oliver Kiddle
  0 siblings, 0 replies; 200+ results
From: Oliver Kiddle @ 2013-02-21  9:55 UTC (permalink / raw)
  To: Zsh workers

This adds some options on newer versions of GNU sed, wget, xmllint, fc
and fixes the spelling in _cut.

Oliver

Index: Completion/Unix/Command/_cut
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_cut,v
retrieving revision 1.7
diff -u -r1.7 _cut
--- Completion/Unix/Command/_cut	6 Feb 2008 01:30:29 -0000	1.7
+++ Completion/Unix/Command/_cut	21 Feb 2013 09:48:45 -0000
@@ -37,22 +37,22 @@
   _arguments \
         '(--bytes -b)'{--bytes=,-b+}'['$_cut_args[bytes]']:list' \
         '(--characters -c)'{--characters=,-c+}'['$_cut_args[characters]']:list' \
-        '(--delimiter -d)'{--delimiter=,-d+}'['$_cut_args[delimiter]']:delimeter' \
+        '(--delimiter -d)'{--delimiter=,-d+}'['$_cut_args[delimiter]']:delimiter' \
         '(--fields -f)'{--fields=,-f+}'['$_cut_args[fields]']:list' \
         '-n['$_cut_args[n]']' \
         '--complement['$_cut_args[complement]']' \
         '(--only-delimited -s)'{--only-delimited,-s}'['$_cut_args[only-delimited]']' \
-        '--output-delimiter=['$_cut_args[output-delimiter]']:delimeter' \
-        '--help['$_cut_args[help]']' \
-        '--version['$_cut_args[version]']' \
+        '--output-delimiter=['$_cut_args[output-delimiter]']:delimiter' \
+        '(- *)--help['$_cut_args[help]']' \
+        '(- *)--version['$_cut_args[version]']' \
         '*:file:_files'
 else
   _arguments \
     '-b[list specifies byte positions]:list:' \
     '-c[list specifies character positions]:list:' \
-    '-d[use alternate delimeter]:delimeter:' \
+    '-d[use alternate delimiter]:delimiter' \
     '-f[list specifies fields]:list:' \
     '-n[do not split multi-byte characters]' \
-    '-s[suppress lines with no delimeters]' \
+    '-s[suppress lines with no delimiters]' \
     '*:file:_files'
 fi
Index: Completion/Unix/Command/_sed
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_sed,v
retrieving revision 1.3
diff -u -r1.3 _sed
--- Completion/Unix/Command/_sed	16 Jan 2008 22:27:43 -0000	1.3
+++ Completion/Unix/Command/_sed	21 Feb 2013 09:48:45 -0000
@@ -12,8 +12,10 @@
 
 if _pick_variant gnu=GNU unix --version; then
   args+=(
+    '--follow-symlinks[follow symlinks when processing in place]'
     '(-i --in-place)'{-i-,--in-place=-}'[edit files in place]::suffix for backup'
     '(-l --line-length)'{-l,--line-length=-}'[specify line-wrap length for the l command]'
+    '(-r)--posix[disable GNU extensions]'
     '(-r --regexp-extended)'{-r,--regexp-extended}'[use extended regular expressions]'
     '(-s --separate)'{-s,--separate}'[consider files separately instead of as a combined stream]'
     '(-u --unbuffered)'{-u,--unbuffered}'[disable data buffering]'
Index: Completion/Unix/Command/_wget
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_wget,v
retrieving revision 1.15
diff -u -r1.15 _wget
--- Completion/Unix/Command/_wget	10 Jun 2012 03:25:40 -0000	1.15
+++ Completion/Unix/Command/_wget	21 Feb 2013 09:48:45 -0000
@@ -17,13 +17,14 @@
   '(--input-file -i)'{--input-file=,-i+}'[specify input file]:file containing URLs:_files' \
   '(--force-html -F)'{--force-html,-F}'[treat input file as html]' \
   '(--base -B)'{--base=,-B+}'[prepend URL to relative links]:base URL:_urls' \
+  '--config=[specify config file]:config file:_files' \
   '(--tries -t)'{--tries=,-t+}'[set number of retries]:number of retries' \
   '--retry-connrefused[retry even if connection is refused]' \
   '(--output-document -O)'{--output-document=,-O+}'[specify file to write documents to]:output file:_files' \
   '(--continue -c)'{--continue,-c}'[continue getting an existing file]'  \
-  '--content-disposition[honor the Content-Disposition header when choosing local file names]'  \
   '--progress=[set progress gauge type]:gauge type:->gauge' \
   '(--timestamping -N)'{--timestamping,-N}'[retrieve only files newer than existing]' \
+  "--no-use-server-timestamps[don't set the local file's timestamp by the one on the server]" \
   '(--server-response -S)'{--server-response,-S}'[print server response]' \
   "--spider[don't download anything]" \
   '(--timeout -T)'{--timeout=,-T+}'[set all timeout values]:timeout (seconds)' \
@@ -40,11 +41,16 @@
   '--limit-rate=[specify limit to download rate]:download rate limit' \
   '--no-dns-cache[disable caching DNS lookups]' \
   '--restrict-file-names=[restrict chars in file names to ones OS allows]:OS:->restrict' \
+  '--ignore-case[ignore case when matching files/directories]' \
   '(-4 --inet4-only -6 --inet6-only)'{-4,--inet4-only}'[connect only to IPv4 addresses]' \
   '(-4 --inet4-only -6 --inet6-only)'{-6,--inet6-only}'[connect only to IPv6 addresses]' \
   '--prefer-family[connect first to addresses of specified family]:address family:(IPv6 IPv4 none)' \
   '(--http-user --ftp-user)--user[set both ftp and http user]:user' \
   '(--http-password --ftp-password)--password[set both ftp and http password]:password' \
+  '--no-iri[turn off IRI support]' \
+  '--local-encoding=[specify local encoding for IRIs]:encoding' \
+  '--remote-encoding=[specify default remote encoding]:encoding' \
+  '--unlink[remove file before clobber]' \
   '(--force-directories -x)'{--force-directories,-x}'[force creation of directories]' \
   '--protocol-directories[use protocol name in directories]' \
   '(--directory-prefix -P)'{--directory-prefix=,-P+}'[specify prefix to save files to]:prefix:_files -/' \
@@ -52,7 +58,8 @@
   '(--user)--http-user=:user' \
   '(--password)--http-password=:password' \
   '--no-cache[disallow server-cached data]' \
-  '(--html-extension -E)'{--html-extension,-E}'[save all HTML documents with a .html extension]' \
+  '--default-page=[specify default page name, normally index.html]' \
+  '(--adjust-extension -E)'{--adjust-extension,-E}'[save all HTML/CSS documents with proper extensions]' \
   "--ignore-length[ignore \`Content-Length' header field]" \
   '*--header=:string' \
   '--proxy-user=:user' \
@@ -61,12 +68,14 @@
   '--save-headers[save http headers]' \
   '(--user-agent -U)'{--user-agent=,-U+}'[specify user agent to identify as]:user-agent' \
   '--no-http-keep-alive[disable HTTP keep-alive]' \
-  '--no-cookies=[turn cookies off]' \
+  '--no-cookies[turn cookies off]' \
   '--load-cookies=[specify file to load cookies from]:cookie file:_files' \
   '--save-cookies=[specify file to save cookies to]:cookie file:_files' \
   '--keep-session-cookies[load and save session cookies]' \
   '--post-data=[use the POST method with specified data]:data to send' \
   '--post-file=[use the POST method; sending contents of a file]:file:_files' \
+  '--content-disposition[honor the Content-Disposition header when choosing local file names]'  \
+  "--auth-no-challenge[send basic HTTP authentication without first waiting for server's challenge]" \
   '--secure-protocol=[choose secure protocol]:protocol:(SSLv2 SSLv3 TLSv1)' \
   "--no-check-certificate=[don't check the server certificate]" \
   '--certificate=[specify client certificate]:client certificate file:_files' \
@@ -89,7 +98,7 @@
   '--delete-after' \
   '(--convert-links -k)'{--convert-links,-k}'[convert links to be relative]' \
   '(--backup-converted -K)'{--backup-converted,-K}'[backup files before conversion]' \
-  '(--mirror -m -r -N -l)'{--mirror,-m}'[mirror (-r -N -l inf -nr)]' \
+  '(--mirror -m -r -N -l)'{--mirror,-m}'[mirror (-r -N -l inf --no-remove-listing)]' \
   '(--page-requisites -p)'{--page-requisites,-p}'[get all images needed to display page]' \
   '--strict-comments[turn on strict (SGML) handling of HTML comments]' \
   '(--accept -A)'{--accept=,-A+}'[specify accepted extensions]:extensions' \
@@ -102,9 +111,10 @@
   '(--span-hosts -H)'{--span-hosts,-H}'[span hosts]' \
   '(--relative -L)'{--relative,-L}'[follow relative links only]' \
   '(--include-directories -I)'{--include-directories=,-I+}'[include directories]:allowed directories' \
+  '--trust-server-names' \
   '(--exclude-directories -X)'{--exclude-directories=,-X+}'[exclude directories]:excluded directories' \
+  '(-np --no-parent)'{-np,--no-parent}"[don't ascend to parent directory]" \
   '--no-host-lookup' \
-  '--no-parent' \
   '--no-verbose' \
   '--no-clobber' \
   '--no-directories' \
Index: Completion/Unix/Command/_xmlsoft
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_xmlsoft,v
retrieving revision 1.11
diff -u -r1.11 _xmlsoft
--- Completion/Unix/Command/_xmlsoft	6 Jun 2012 13:22:16 -0000	1.11
+++ Completion/Unix/Command/_xmlsoft	21 Feb 2013 09:48:45 -0000
@@ -66,13 +66,14 @@
       '--recover[output what was parsable on broken XML documents]' \
       '--huge[remove any internal arbitrary parser limits]' \
       '--noent[substitute entity references by their value]' \
+      '--noenc[ignore any encoding specified inside the document]' \
       "(--output -o)--noout[don't output the result tree]" \
       '--path[provide a set of paths for resources]:paths:_files -/' \
       '--load-trace[print trace of all external entites loaded]' \
       '--nonet[refuse to fetch DTDs or entities over network]' \
+      '--nocompact[do not generate compact text nodes]' \
       '--htmlout[output results as HTML]' \
       '--nowrap[do not put HTML doc wrapper]' \
-      '--nocompact[do not generate compact text nodes]' \
       '--valid[validate the document in addition to std well-formed check]' \
       '(--dtdvalid --relaxng --schema)--postvalid[do a posteriori validation, i.e after parsing]' \
       '(--postvalid --relaxng --schema --dtdvalidfpi)--dtdvalid[do a posteriori validation against a given DTD]:DTD:_webbrowser' \
@@ -84,27 +85,28 @@
       '--compress[turn on gzip compression of output]' \
       '--html[use the HTML parser]' \
       '--xmlout[use the XML serializer when using --html]' \
+      '--nodefdtd[do not default HTML doctype]' \
       '--push[use the push mode of the parser]' \
       '--memory[parse from memory]' \
-      '--maxmem[imits memory allocation]:bytes' \
+      '--maxmem[limit memory allocation]:bytes' \
       '--nowarning[do not emit warnings from parser/validator]' \
       '--noblanks[drop (ignorable?) blanks spaces]' \
       '--nocdata[replace cdata section with text nodes]' \
       '--format[reformat/reindent the input]' \
       '--encode[output in the given encoding]:encoding:(${encoding[@]})' \
       '--dropdtd[remove the DOCTYPE of the input docs]' \
+      "--pretty[pretty-print in a particular style]:style:((0\:don't\ pretty\ print 1\:reformat 2\:add\ whitespace))" \
       '--c14n[save in W3C canonical format]' \
       '--c14n11[save in W3C canonical format v1.1 (with comments)]' \
       '--exc-c14n[save in W3C exclusive canonical format]' \
       '--nsclean[remove redundant namespace declarations]' \
-      '--testIO[test user I/O support]' \
       '(--nocatalogs)--catalogs[use SGML catalogs]' \
       '(--catalogs)--nocatalogs[deactivate all catalogs]' \
       '--auto[generate a small doc on the fly]' \
       '(--noxincludenode)--xinclude[do XInclude processing]' \
       '(--xinclude)--noxincludenode[do XInclude processing but do not generate XInclude nodes]' \
-      '--loaddtd[fetch external DTD]' \
       '--nofixup-base-uris[do not fixup xml:base uris]' \
+      '--loaddtd[fetch external DTD]' \
       '--dtdattr[loaddtd + populate the tree with inherited attributes]' \
       '--stream[use the streaming interface to process very large files]' \
       '--walker[create a reader and walk though the resulting doc]' \
@@ -116,7 +118,7 @@
       '--sax1[use the old SAX1 interfaces for processing]' \
       '--sax[do not build a tree but work just at the SAX level]' \
       '--oldxml10[use XML-1.0 parsing rules before the 5th edition]' \
-      '--xpath[evaluate the XPath expression, inply --noout]:XPath expression:' \
+      '(--noout)--xpath[evaluate the XPath expression, implies --noout]:XPath expression' \
       '*:XML file:_webbrowser' && return
   ;;
   *XML_CATALOG_FILES*)
@@ -125,7 +127,7 @@
       _urls
       return
     fi
-    
+
     compset -S ':*'
     _alternative \
       'files:catalog file:_files' \
@@ -134,5 +136,3 @@
 esac
 
 return 1
-
-
Index: Completion/Zsh/Command/_fc
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Command/_fc,v
retrieving revision 1.2
diff -u -r1.2 _fc
--- Completion/Zsh/Command/_fc	11 Apr 2001 21:47:18 -0000	1.2
+++ Completion/Zsh/Command/_fc	21 Feb 2013 09:48:45 -0000
@@ -3,17 +3,21 @@
 local fc_common fc_hist fc_r
 
 fc_common=(
-  '(-A -R -W -I)-r[reverse order of the commands]'
-  '(-A -R -W -I -e)-n[suppress line numbers]'
-  '(-A -R -W -I)*::commands:_command_names -e' )
+  '(-A -R -W -I -p -P)-r[reverse order of the commands]'
+  '(-A -R -W -I -e -p -P)-n[suppress line numbers]'
+  '(-A -R -W -I -p -P)*::commands:_command_names -e' )
 
 fc_hist=(
-  '(-A -R -W -I)-m[treat first argument as a pattern]'
-  '(-A -R -W -I -e -f -E -i)-d[print time-stamps]'
-  '(-A -R -W -I -e -d -E -i)-f[mm/dd/yyyy format time-stamps]'
-  '(-A -R -W -I -e -d -f -i)-E[dd.mm.yyyy format time-stamps]'
-  '(-A -R -W -I -e -d -f -E)-i[yyyy-mm-dd format time-stamps]'
-  '(-A -R -W -I -e)-D[print elapsed times]' )
+  '(-A -R -W -I -p -p)-m[treat first argument as a pattern]'
+  '(-A -R -W -I -e -f -E -i -t -p -P)-d[print time-stamps]'
+  '(-A -R -W -I -e -d -E -i -t -p -P)-f[mm/dd/yyyy format time-stamps]'
+  '(-A -R -W -I -e -d -f -i -t -p -P)-E[dd.mm.yyyy format time-stamps]'
+  '(-A -R -W -I -e -d -f -E -t -p -P)-i[yyyy-mm-dd format time-stamps]'
+  '(-A -R -W -I -e -d -f -E -i -p -P)-t[print time-stamps in specified format]:date format'
+  '(-A -R -W -I -e -p -P)-D[print elapsed times]'
+  '(- *)-p[push current history to stack]:history file:_files:history size: :saved history size'
+  '(- *)-P[pop history from stack]'
+)
 
 fc_r='(-A -R -W -I -e)-l[list resulting commands on stdout]'
 
@@ -26,11 +30,11 @@
   ;;
   *)
   _arguments -s -S \
-    '(-A -R -W -I -l -n -d -f -E -i -D)-e[specify editor to invoke]:editor to invoke:_command_names -e' \
-    '(-l -m -e -r -n -d -f -E -i -D -A -W *)-R[read history from file]:history file:_files' \
-    '(-l -m -e -r -n -d -f -E -i -D -R -W *)-A[append history to file]:history file:_files' \
-    '(-l -m -e -r -n -d -f -E -i -D -R -A *)-W[write history to file]:history file:_files' \
-    '(-l -m -e -r -n -d -f -E -i -D -A -W *)-I[read/write new events only]:history file:_files' \
+    '(-A -R -W -I -l -n -d -f -E -i -D -p -P)-e[specify editor to invoke]:editor to invoke:_command_names -e' \
+    '(-l -m -e -r -n -d -f -E -i -D -A -W -p -P *)-R[read history from file]:history file:_files' \
+    '(-l -m -e -r -n -d -f -E -i -D -R -W -p -P *)-A[append history to file]:history file:_files' \
+    '(-l -m -e -r -n -d -f -E -i -D -R -A -p -P *)-W[write history to file]:history file:_files' \
+    '(-l -m -e -r -n -d -f -E -i -D -A -W -p -P *)-I[read/write new events only]:history file:_files' \
     "$fc_common[@]" "$fc_hist[@]" "$fc_r" && return 0
   ;;
 esac


^ permalink raw reply	[relevance 2%]

* Re: One-command mail import with X-Seq: and ChangeLog
  @ 2013-04-07 21:08  2%           ` Frank Terbeck
  2013-04-11 15:10  3%           ` Frank Terbeck
  1 sibling, 0 replies; 200+ results
From: Frank Terbeck @ 2013-04-07 21:08 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

Bart Schaefer wrote:
> On Apr 5,  6:57pm, Frank Terbeck wrote:
[...]
> The one thing I'm finding missing from both places is a discussion of
> how to perform a simple one-file (well, two, counting ChangeLog) push
> directly from a clone of the master.  Can I --amend a commit without
> having a branch, or must I wait even to commit until I've edited the
> ChangeLog?  Or is creating a branch THE way, and I should ignore all
> the discussion of branching for "a feature" and just create a branch
> that's always there and use it repeatedly whenver I edit?

For most things people usually do, additional branches are _absolutely_
optional. People usually use them, because they are cheap to create and
easy to handle. But there's no requirement to use them at all.

You can do this if you like:

  - HACK HACK HACK
  - commit
  - format-patch/send-email
  - Get the X-Seq: number from the mail as it returns
  - Add a ChangeLog entry, however you like
  - "git add ChangeLog"
  - "git commit --amend" and put the X-Seq: Number in front for the
    commit message's first line
  - "git push"

This will work just fine. It might even be the way to go for trivial
changes, that you would commit as "unposted: ..." because you don't have
to do much of anything, except for adding a ChangeLog entry.

Here is one scenario, that might arise, when doing development directly
on master:

  - You got your changes on master
  - Someone else has their changes pushed in the meantime,
  - Your copy of master is outdated, and to regain linear history, you'd
    have to do "git pull --rebase"
  - If you already have added an entry to ChangeLog, you will definitely
    get a merge conflict while rebasing.

The easy way around this would be to "git pull --rebase" before adding
ChangeLog entries. If you don't do your development on master, you can
always just "git pull" while master is checked out locally and it will
trivially work because there are no changes on there. You can just
"zsh-am" your changes on top of it, if you like and then push.


You also asked, if "commit --amend" is possible on master. And the
answer is yes. "master" is in no way special to git, other than being
the default name it uses when creating a repository. There is one catch:
Do not amend commits you already pushed. Amending commits changes the
hash sum for the commit and people who already have the old version will
run into trouble if you change published history from under their feet.


As for the idea of a hacking branch: Yes, you can do that, too:

  - While having master checked out, do: git checkout -b bart/hack
  - That will create a new branch "bart/hack" and check it out.
  - You can now do all the things I lined out in README.org
  - Instead of removing the branch once you're finished you can also do
    this:
  - git reset --hard master

That will make "bart/hack" the same as the current master branch, ready
for you next development cycle.

> }   - Mark mails containing commits in MUA
> }   - Make MUA save those Mails into mbox file
> }   - Call: zsh-am the-mbox-file
>
> I think the first thing I'm going to do unless you beat me to it is to
> make zsh-am read patch emails from standard input ... it's just way too
> easy in e.g. Alpine to hit "|" rather than save the message.  I know
> a number of people send patches in several parts and want to commit
> them all at once, but far and away the most common thing is to want to
> operate on just one message.

Makes sense. I'm not sure how soon I can get onto it.

> (Aside: zsh-am is a bash script?  Horrors! :-)

Well, if your /bin/sh is bash, then you might call it that. It only uses
POSIX features, though, and will happily work with debian's `dash' shell
or some ksh flavour on other operating systems, as well. :-)

Regards, Frank


^ permalink raw reply	[relevance 2%]

* Re: One-command mail import with X-Seq: and ChangeLog
    2013-04-07 21:08  2%           ` One-command mail import with X-Seq: and ChangeLog Frank Terbeck
@ 2013-04-11 15:10  3%           ` Frank Terbeck
  1 sibling, 0 replies; 200+ results
From: Frank Terbeck @ 2013-04-11 15:10 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

Bart Schaefer wrote:
[...]
> I think the first thing I'm going to do unless you beat me to it is to
> make zsh-am read patch emails from standard input [...]

The latest code from zsh-am's git repository¹ now supports doing that.
The mode is entered in two cases:

   1.) There is _no_ non-option argument on the command line
   2.) There is exactly _one_ non-option argument and that
       argument is exactly one single dash: "-"

Also, that mode requires mktemp(1) to be available².


Regards, Frank

¹ https://github.com/ft/zsh-am
² mktemp(1) is not POSIX, so it's not strictly portable, but widely
  available across many operating systems; if your system does not have
  it, that's though luck. ;)


^ permalink raw reply	[relevance 3%]

* [PATCH] _cp: add support for Mac OS X
@ 2013-04-29 13:50  5% Jun T
  0 siblings, 0 replies; 200+ results
From: Jun T @ 2013-04-29 13:50 UTC (permalink / raw)
  To: zsh-workers; +Cc: Jun T

if not GNU nor darwin, assume POSIX
---
 Completion/Unix/Command/_cp |   92 ++++++++++++++++++++++++++++---------------
 1 file changed, 60 insertions(+), 32 deletions(-)

diff --git a/Completion/Unix/Command/_cp b/Completion/Unix/Command/_cp
index 958214a..5013f85 100644
--- a/Completion/Unix/Command/_cp
+++ b/Completion/Unix/Command/_cp
@@ -1,34 +1,62 @@
 #compdef cp
 
-_arguments -s \
-  '(-a --archive)'{-a,--archive}'[same as -dpR]' \
-  '(-b --backup)-b[backup]' \
-  '(-b --backup)--backup=[backup]:method:(none off numbered t existing nil simple never)' \
-  '--copy-contents[copy contents of special files when recursive]' \
-  '-d[same as --no-dereference --preserve=links]' \
-  '(-f --force)'{-f,--force}'[remove and retry for destinations that cannot be opened]' \
-  '(-i --interactive)'{-i,--interactive}'[prompt before overwrite]' \
-  '-H[follow command-line symbolic links]' \
-  '(-l --link)'{-l,--link}'[link files instead of copying]' \
-  '(-L --dereference)'{-L,--dereference}'[always follow symbolic links]' \
-  '(-n --no-clobber)'{-n,--no-clobber}'[do not overwrite an existing file]' \
-  '(-P --no-dereference)'{-P,--no-dereference}'[never follow symbolic links]' \
-  '-p[same as --preserve=mode,ownership,timestamps]' \
-  '--preserve=[preserve specified attributes]:attributes to preserve:_values -s , mode timestamps ownership links context xattr all' \
-  '--no-preserve=[don'\''t preserve specified attributes]:attributes not to preserve:_values -s , mode timestamps ownership links context xattr all' \
-  '--parents[append source path to target directory]' \
-  '(-R -r --recursive)'{-R,-r,--recursive}'[copy directories recursively]' \
-  '--reflink=[control clone/CoW copies]:when to perform a lightweight copy:(always auto)' \
-  '--remove-destination[remove each existing destination file before attempting to open it]' \
-  '--sparse=[control creation of sparse files]:when to create sparse files:(auto always never)' \
-  '--strip-trailing-slashes[remove any trailing slashes from each source argument]' \
-  '(-s --symbolic-link)'{-s,--symbolic-link}'[make symbolic links instead of copies of non-directories]' \
-  '(-S --suffix)'{-S,--suffix=}'[override the usual backup suffix]:backup suffix:' \
-  '(-t --target-directory)'{-t,--target-directory=}'[copy all source arguments into target directory]:target directory:_files -/' \
-  '(-T --no-target-directory)'{-T,--no-target-directory}'[treat DEST as a normal file]' \
-  '(-u --update)'{-u,--update}'[copy only when source is newer than destination or destination is missing]' \
-  '(-v --verbose)'{-v,--verbose}'[explain what is being done]' \
-  '(-x --one-file-system)'{-x,--one-file-system}'[stay on this file system]' \
-  '--help' \
-  '--version' \
-  '*:file or directory:_files'
+if _pick_variant gnu=GNU unix --version; then
+  _arguments -s -S \
+    '(-a --archive)'{-a,--archive}'[same as -dR --preserve=all]' \
+    '(-b --backup)-b[backup]' \
+    '(-b --backup)--backup=[backup]:method:(none off numbered t existing nil simple never)' \
+    '--copy-contents[copy contents of special files when recursive]' \
+    '-d[same as --no-dereference --preserve=links]' \
+    '(-f --force)'{-f,--force}'[remove and retry for destinations that cannot be opened]' \
+    '(-i --interactive)'{-i,--interactive}'[prompt before overwrite]' \
+    '-H[follow command-line symbolic links]' \
+    '(-l --link)'{-l,--link}'[link files instead of copying]' \
+    '(-L --dereference)'{-L,--dereference}'[always follow symbolic links]' \
+    '(-n --no-clobber)'{-n,--no-clobber}'[do not overwrite an existing file]' \
+    '(-P --no-dereference)'{-P,--no-dereference}'[never follow symbolic links]' \
+    '-p[same as --preserve=mode,ownership,timestamps]' \
+    '--preserve=[preserve specified attributes]:attributes to preserve:_values -s , mode timestamps ownership links context xattr all' \
+    '--no-preserve=[don'\''t preserve specified attributes]:attributes not to preserve:_values -s , mode timestamps ownership links context xattr all' \
+    '--parents[append source path to target directory]' \
+    '(-R -r --recursive)'{-R,-r,--recursive}'[copy directories recursively]' \
+    '--reflink=[control clone/CoW copies]:when to perform a lightweight copy:(always auto)' \
+    '--remove-destination[remove each existing destination file before attempting to open it]' \
+    '--sparse=[control creation of sparse files]:when to create sparse files:(auto always never)' \
+    '--strip-trailing-slashes[remove any trailing slashes from each source argument]' \
+    '(-s --symbolic-link)'{-s,--symbolic-link}'[make symbolic links instead of copies of non-directories]' \
+    '(-S --suffix)'{-S,--suffix=}'[override the usual backup suffix]:backup suffix:' \
+    '(-t --target-directory)'{-t,--target-directory=}'[copy all source arguments into target directory]:target directory:_files -/' \
+    '(-T --no-target-directory)'{-T,--no-target-directory}'[treat DEST as a normal file]' \
+    '(-u --update)'{-u,--update}'[copy only when source is newer than destination or destination is missing]' \
+    '(-v --verbose)'{-v,--verbose}'[explain what is being done]' \
+    '(-x --one-file-system)'{-x,--one-file-system}'[stay on this file system]' \
+    '--help' \
+    '--version' \
+    '*:file or directory:_files'
+
+elif [[ "$OSTYPE" == darwin* ]]; then
+  _arguments -s -S \
+    '-R[copy directories recursively]' \
+    '(-L -P)-H[with -R, follow symlinks on the command line]' \
+    '(-H -P)-L[with -R, follow all symlinks]' \
+    '(-H -L)-P[with -R, do not follow symlinks (default)]' \
+    '(-i -n)-f[force overwriting existing file]' \
+    '(-f -n)-i[confirm before overwriting existing file]' \
+    '(-f -i)-n[do not overwrite existing file]' \
+    '-a[same as -pRP]' \
+    '-p[preserve timestamps, mode, owner, flags, ACLs, and Extended Attributes]' \
+    '-v[show file names as they are copied]' \
+    '-X[do not copy Extended Attributes or resource forks]' \
+    '(-)*:file or directory:_files'
+
+else    # assume POSIX
+  _arguments -s -S \
+    '-R[copy directories recursively]' \
+    '(-L -P)-H[with -R, follow symlinks on the command line]' \
+    '(-H -P)-L[with -R, follow all symlinks]' \
+    '(-H -L)-P[do not follow symlinks]' \
+    '(-i)-f[force overwriting existing file]' \
+    '(-f)-i[confirm before overwriting existing file]' \
+    '-p[preserve timestamps, mode, and owner]' \
+    '(-)*:file or directory:_files'
+fi
-- 
1.7.9.6 (Apple Git-31.1)


^ permalink raw reply	[relevance 5%]

* Re: cygwin64 can not build zsh 5.0.2
       [not found]     <CAOjwHPbVW8BQ2J==oYnDFXMTcMSVsP-uj7Qu42Y288SRHJG76g@mail.gmail.com>
@ 2013-05-14 11:30  0% ` Peter Stephenson
  2013-05-14 13:14  0%   ` XueJia Zhe
  0 siblings, 1 reply; 200+ results
From: Peter Stephenson @ 2013-05-14 11:30 UTC (permalink / raw)
  To: XueJia Zhe, Zsh Hackers' List

Mail like the following (quoted in full) should go to
zsh-workers@zsh.org. mailing list.

I'm not sure who on zsh-workers is currently using zsh on cygwin64, but
I haven't seen any mention of it on the mailing list yet.

pws

On Tue, 14 May 2013 19:06:59 +0800
XueJia Zhe <vvwalle@gmail.com> wrote:
> Hi all,
> 
> I have download zsh 5.0.2 then:
> *./configure*
> *make*
> but i get an error about '.data'.
> I't linker error, i think it's bug of cygwin64 gcc runtime lib.
> I'm sure I have install all dependence libs need to build zsh.
> 
> you can re-produce this issue as next steps:
> 1, install cygwin64 and x86_64 gcc tool chain.
> 2, install all zsh dependence libs, such as ncurse.
> 3, download zsh 5.0.2, then uncompress them in zsh dir.
> 4, cd into zsh dir, then run ./configure, it's generate makefile fine.
> 5, run make in zsh dir. The error will show in console.
> 
> here is the *gcc -v* output:
> Using built-in specs.
> COLLECT_GCC=gcc
> COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/4.8.0/lto-wrapper.exe
> Target: x86_64-pc-cygwin
> Configured with: /usr/src/ports/gcc/gcc-4.8.0-2/src/gcc-4.8.0/configure
> --srcdir=/usr/src/ports/gcc/gcc-4.8.0-2/src/gcc-4.8.0 --prefix=/usr
> --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin
> --libexecdir=/usr/lib --datadir=/usr/share --localstatedir=/var
> --sysconfdir=/etc --datarootdir=/usr/share --docdir=/usr/share/doc/gcc -C
> --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin
> --without-libiconv-prefix --without-libintl-prefix --enable-shared
> --enable-shared-libgcc --enable-static
> --enable-version-specific-runtime-libs --enable-bootstrap
> --disable-__cxa_atexit --with-dwarf2 --with-tune=generic
> --enable-languages=c,c++,fortran,lto,objc,obj-c++ --enable-graphite
> --enable-threads=posix --enable-libatomic --enable-libgomp --disable-libitm
> --enable-libquadmath --enable-libquadmath-support --enable-libssp
> --enable-libgcj-sublibs --disable-java-awt --disable-symvers
> --with-ecj-jar=/usr/share/java/ecj.jar --with-gnu-ld --with-gnu-as
> --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix
> --without-libintl-prefix --with-system-zlib
> Thread model: posix
> gcc version 4.8.0 (GCC)
> 
> Also, could cygwin64 team to build and supply an official zsh?
> I don't know how to get help, so just send you email ask for help, you are
> kind​, thanks very much :-)
> 
> thanks again :-)
> 
> 



-- 
Peter Stephenson <p.stephenson@samsung.com>       Principal Software
Engineer Tel: +44 (0)1223 434724              Samsung Cambridge
Solution Centre St John's House, St John's Innovation Park,
Cowley Road, Cambridge, CB4 0DS, UK


^ permalink raw reply	[relevance 0%]

* Re: cygwin64 can not build zsh 5.0.2
  2013-05-14 11:30  0% ` cygwin64 can not build zsh 5.0.2 Peter Stephenson
@ 2013-05-14 13:14  0%   ` XueJia Zhe
  0 siblings, 0 replies; 200+ results
From: XueJia Zhe @ 2013-05-14 13:14 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh Hackers' List

[-- Attachment #1: Type: text/plain, Size: 3097 bytes --]

I realy don't know how to do.
Where should I submit the issue? could you help me to submit that?

thanks for you so soon reply :-)


2013/5/14 Peter Stephenson <p.stephenson@samsung.com>

> Mail like the following (quoted in full) should go to
> zsh-workers@zsh.org. mailing list.
>
> I'm not sure who on zsh-workers is currently using zsh on cygwin64, but
> I haven't seen any mention of it on the mailing list yet.
>
> pws
>
> On Tue, 14 May 2013 19:06:59 +0800
> XueJia Zhe <vvwalle@gmail.com> wrote:
> > Hi all,
> >
> > I have download zsh 5.0.2 then:
> > *./configure*
> > *make*
> > but i get an error about '.data'.
> > I't linker error, i think it's bug of cygwin64 gcc runtime lib.
> > I'm sure I have install all dependence libs need to build zsh.
> >
> > you can re-produce this issue as next steps:
> > 1, install cygwin64 and x86_64 gcc tool chain.
> > 2, install all zsh dependence libs, such as ncurse.
> > 3, download zsh 5.0.2, then uncompress them in zsh dir.
> > 4, cd into zsh dir, then run ./configure, it's generate makefile fine.
> > 5, run make in zsh dir. The error will show in console.
> >
> > here is the *gcc -v* output:
> > Using built-in specs.
> > COLLECT_GCC=gcc
> > COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/4.8.0/lto-wrapper.exe
> > Target: x86_64-pc-cygwin
> > Configured with: /usr/src/ports/gcc/gcc-4.8.0-2/src/gcc-4.8.0/configure
> > --srcdir=/usr/src/ports/gcc/gcc-4.8.0-2/src/gcc-4.8.0 --prefix=/usr
> > --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin
> > --libexecdir=/usr/lib --datadir=/usr/share --localstatedir=/var
> > --sysconfdir=/etc --datarootdir=/usr/share --docdir=/usr/share/doc/gcc -C
> > --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin
> --target=x86_64-pc-cygwin
> > --without-libiconv-prefix --without-libintl-prefix --enable-shared
> > --enable-shared-libgcc --enable-static
> > --enable-version-specific-runtime-libs --enable-bootstrap
> > --disable-__cxa_atexit --with-dwarf2 --with-tune=generic
> > --enable-languages=c,c++,fortran,lto,objc,obj-c++ --enable-graphite
> > --enable-threads=posix --enable-libatomic --enable-libgomp
> --disable-libitm
> > --enable-libquadmath --enable-libquadmath-support --enable-libssp
> > --enable-libgcj-sublibs --disable-java-awt --disable-symvers
> > --with-ecj-jar=/usr/share/java/ecj.jar --with-gnu-ld --with-gnu-as
> > --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix
> > --without-libintl-prefix --with-system-zlib
> > Thread model: posix
> > gcc version 4.8.0 (GCC)
> >
> > Also, could cygwin64 team to build and supply an official zsh?
> > I don't know how to get help, so just send you email ask for help, you
> are
> > kind​, thanks very much :-)
> >
> > thanks again :-)
> >
> >
>
>
>
> --
> Peter Stephenson <p.stephenson@samsung.com>       Principal Software
> Engineer Tel: +44 (0)1223 434724              Samsung Cambridge
> Solution Centre St John's House, St John's Innovation Park,
> Cowley Road, Cambridge, CB4 0DS, UK
>



-- 
*With Regards,*
*Zhe XueJia*

^ permalink raw reply	[relevance 0%]

* [PATCH 06/16] _git: completion updates to match latest git v1.8.3 part 2
    2013-07-28 16:22  3% ` [PATCH 05/16] _git: completion updates to match latest git v1.8.3 Øystein Walle
@ 2013-07-28 16:22  1% ` Øystein Walle
  1 sibling, 0 replies; 200+ results
From: Øystein Walle @ 2013-07-28 16:22 UTC (permalink / raw)
  To: zsh-workers; +Cc: m0viefreak.cm, Øystein Walle

---
 Completion/Unix/Command/_git | 112 ++++++++++++++++++++++++++++++++++---------
 1 file changed, 89 insertions(+), 23 deletions(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 3080872..dc33a73 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -64,8 +64,9 @@ _git-add () {
     '(-i --interactive : -)'{-i,--interactive}'[add contents interactively to index]' \
     '(-p --patch)'{-p,--patch}'[like -i but go directly into patch mode for specified files]' \
     '(-e --edit)'{-e,--edit}'[open diff against index in editor]' \
-    '(-u --update -A --all)'{-u,--update}'[update only files git already knows about]' \
-    '(-A --all -u --update)'{-A,--all}'[act as both add . and add -u]' \
+    '(-A --all --no-ignore-removal -u --update --no-all --ignore-removal)'{-A,--all,--no-ignore-removal}'[add, modify, and remove index entries to match the working tree]' \
+    '(-A --all --no-ignore-removal -u --update --no-all --ignore-removal)'{--no-all,--ignore-removal}'[like "--all" but ignore removals]' \
+    '(-A --all --no-ignore-removal -u --update --no-all --ignore-removal)'{-u,--update}'[update the index just where it already has an entry matching <pathspec>]' \
     '(-N --intent-to-add)'{-N,--intent-to-add}'[record only that path will be added later]' \
     '--refresh[do not add files, but refresh their stat() info in index]' \
     '--ignore-errors[continue adding if an error occurs]' \
@@ -104,6 +105,7 @@ _git-am () {
   _arguments -S \
     '(-s --signoff)'{-s,--signoff}'[add Signed-off-by: line to the commit message]' \
     '(-k --keep)'{-k,--keep}'[pass -k to git mailinfo]' \
+    '--keep-non-patch[pass -b to git mailinfo]' \
     '(          --no-keep-cr)--keep-cr[pass --keep-cr to git mailsplit]' \
     '(--keep-cr             )--no-keep-cr[do not pass --keep-cr to git mailsplit]' \
     '(-c --scissors --no-scissors)'{-c,--scissors}'[strip everything before a scissors line]' \
@@ -315,10 +317,12 @@ _git-branch () {
   _arguments -w -S -s \
     "($c $m $d $e --no-color :)--color=-[turn on branch coloring]:: :__git_color_whens" \
     "($c $m $d $e : --color)--no-color[turn off branch coloring]" \
+    "($c $m $d $e --no-column)"'--column=[display tag listing in columns]:column.branch option:((always\:"always show in columns" never\:"never show in columns" auto\:"show in columns if the output is to the terminal" column\:"fill columns before rows (default)" row\:"fill rows before columns" plain\:"show in one column" dense\:"make unequal size columns to utilize more space" nodense\:"make equal size columns"))' \
+    "($c $m $d $e --column)"'--no-column[do not display in columns]' \
     "($c $m $d $e )*--list[list only branches matching glob]:pattern" \
     "($c $m    $e  -a)-r[list or delete only remote-tracking branches]" \
     "($c $m $d $e: -r)-a[list both remote-tracking branches and local branches]" \
-    "($c $m $d $e : -v --verbose)"{-v,--verbose}'[show SHA1 and commit subject line for each head]' \
+    "($c $m $d $e : -v -vv --verbose)"{-v,-vv--verbose}'[show SHA1 and commit subject line for each head]' \
     "($c $m $d $e :)--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length" \
     "($c $m $d $e :)--no-abbrev[do not abbreviate sha1s]" \
     "($l $m $d $e)-l[create the branch's reflog]" \
@@ -419,6 +423,7 @@ _git-checkout () {
     '(--patch)--no-track[override the branch.autosetupmerge configuration variable]' \
     $new_branch_reflog_opt \
     '(-b -B -t --track --patch)--orphan[create a new orphan branch based at given commit]: :__git_branch_names' \
+    '--ignore-skip-worktree-bits[ignores patterns and adds back any files in <paths>]' \
     '(-q --quiet -f --force -m --merge --conflict --patch)'{-m,--merge}'[3way merge current branch, working tree and new branch]' \
     '(-q --quiet -f --force -m --merge --patch)--conflict[same as --merge, using given merge style]:style:(merge diff3)' \
     '(-)'{-p,--patch}'[interactively select hunks in diff between given tree-ish and working tree]' \
@@ -473,6 +478,7 @@ _git-cherry-pick () {
     '(--abort --continue --quit)--continue[continue the operation]' \
     '(--abort --continue --quit)--quit[forget about the operation in progress]' \
     '--allow-empty-message[allow replaying a commit with an empty message]' \
+    '--keep-redundant-commits[keep cherry-picked commits that will become empty]' \
     '(-e --edit --ff)'{-e,--edit}'[edit commit before committing the revert]' \
     '(--ff)-x[append information about what commit was cherry-picked]' \
     '(-m --mainline)'{-m,--mainline}'[specify mainline when cherry-picking a merge commit]:parent number' \
@@ -589,6 +595,18 @@ _git-clone () {
   return ret
 }
 
+(( $+functions[_git-column] )) ||
+_git-column () {
+  _arguments -w -S -s \
+    '--command=[look up layout mode using config vars column.<name> and column.ui]' \
+    '--mode=[specify layout mode. See configuration variable column.ui for option syntax]' \
+    '--raw-mode=[same as --mode but take mode encoded as a number]' \
+    '--width=[specify the terminal width]' \
+    '--indent=[string to be printed at the beginning of each line]' \
+    '--nl[string to be printed at the end of each line, including newline character]' \
+    '--padding[the number of spaces between columns. One space by default]'
+}
+
 (( $+functions[_git-commit] )) ||
 _git-commit () {
   local amend_opt='--amend[amend the tip of the current branch]'
@@ -622,6 +640,7 @@ _git-commit () {
                                                                             default\:"act as '\''strip'\'' if the message is to be edited and as '\''whitespace'\'' otherwise"))' \
     '(-e --edit --no-edit)'{-e,--edit}'[edit the commit message before committing]' \
     '(-e --edit --no-edit)--no-edit[do not edit the commit message before committing]' \
+    '--no-post-rewrite[bypass the post-rewrite hook]' \
     '(-a --all --interactive -o --only -i --include)'{-i,--include}'[update the given files and commit the whole index]' \
     '(-a --all --interactive -o --only -i --include)'{-o,--only}'[commit only the given files]' \
     '(-u --untracked-files)'{-u-,--untracked-files=}'[show files in untracked directories]::mode:((no\:"show no untracked files"
@@ -864,7 +883,8 @@ _git-grep () {
   _arguments -C -A '-*' \
     '(-O --open-files-in-pager --no-index)--cached[search blobs registered in index file instead of working tree]' \
     '(--cached)--no-index[search files in current directory, not just treacked files]' \
-    '--exclude-standard[exclude files standard ignore mechanisms]' \
+    '(--exclude-standard)--no-exclude-standard[also search in ignored files]' \
+    '(--no-exclude-standard)--exclude-standard[exclude files standard ignore mechanisms]' \
     '--untracked[search in untracked files]' \
     '(-a --text)'{-a,--text}'[process binary files as if they were text]' \
     '(-i --ignore-case)'{-i,--ignore-case}'[ignore case when matching]' \
@@ -879,7 +899,7 @@ _git-grep () {
     '(-E --extended-regexp -G --basic-regexp -P --perl-regexp -F --fixed-strings)'{-G,--basic-regexp}'[use POSIX basic regexes]' \
     '(-E --extended-regexp -G --basic-regexp -P --perl-regexp -F --fixed-strings)'{-P,--perl-regexp}'[use perl-compatible regexes]' \
     '(-E --extended-regexp -G --basic-regexp -P --perl-regexp -F --fixed-strings)'{-F,--fixed-strings}'[do not interpret pattern as a regex]' \
-    '-n[prefix the line number to matching lines]' \
+    '(-n --line-number)'{-n,--line-number}'[prefix the line number to matching lines]' \
     '(-l --files-with-matches -L --files-without-match --name-only)'{-l,--files-with-matches,--name-only}'[show only names of matching files]' \
     '(-l --files-with-matches -L --files-without-match)'{-L,--files-without-match}'[show only names of non-matching files]' \
     '(--cached -O --open-files-in-pager)'{-O,--open-files-in-pager}'=-[open matching files in pager]::_path_commands' \
@@ -889,9 +909,9 @@ _git-grep () {
     '(--color           )---no-color[do not color matches]' \
     '--break[prefix the line number to matching lines]' \
     '--heading[show the filename above the matches]' \
-    '-A[show trailing context]: :__git_guard_number lines' \
-    '-B[show leading context]: :__git_guard_number lines' \
-    '-C[show context]: :__git_guard_number lines' \
+    '(-A --after-context)'{-A,--after-context=}'[show <num> trailing lines, and separate groups of matches]: :__git_guard_number lines' \
+    '(-B --before-context)'{-B,--before-context=}'[show <num> leading lines, and separate groups of matches]: :__git_guard_number lines' \
+    '(-A --after-context -B --before-context -C --context)'{-C,--context=}'[show <num> leading and trailing lines, and separate groups of matches]: :__git_guard_number lines' \
     '(-p --show-function)'{-p,--show-function}'[show preceding line containing function name of match]' \
     '(-W --function-context)'{-W,--function-context}'[show whole function where a match was found]' \
     '(1)*-f[read patterns from given file]:pattern file:_files' \
@@ -1206,6 +1226,7 @@ _git-push () {
     '--porcelain[produce machine-readable output]' \
     '--delete[delete all listed refs from the remote repository]' \
     '--tags[all tags under refs/tags are pushed]' \
+    '--follow-tags[also push missing annotated tags reachable from the pushed refs]' \
     '(--receive-pack --exec)'{--receive-pack=-,--exec=-}'[path to git-receive-pack on remote]:remote git-receive-pack:_files' \
     '(-f --force)'{-f,--force}'[allow refs that are not ancestors to be updated]' \
     '(:)--repo=[default repository to use]:repository:__git_any_repositories' \
@@ -1234,6 +1255,7 @@ _git-rebase () {
   _arguments -A '-*' \
     '(- :)--continue[continue after resolving merge conflict]' \
     '(- :)--abort[abort current rebase]' \
+    '--keep-empty[keep empty commits in the result]' \
     '(- :)--skip[skip the current patch]' \
     '(-m --merge)'{-m,--merge}'[use merging strategies to rebase]' \
     '*'{-s,--strategy=}'[use given merge strategy]:merge strategy:__git_merge_strategies' \
@@ -1523,7 +1545,10 @@ _git-status () {
                                                                                      normal\:"show untracked files and directories" \
                                                                                      all\:"also show untracked files in untracked directories (default)"))' \
     '--ignore-submodules[ignore changes to submodules]:: :__git_ignore_submodules_whens' \
+    '--ignored[show ignored files as well]' \
     '(--porcelain)-z[use NUL termination on output]' \
+    '(--no-column)--column=-[display in columns]::column.status option:((always\:"always show in columns" never\:"never show in columns" auto\:"show in columns if the output is to the terminal" column\:"fill columns before rows (default)" row\:"fill rows before columns" plain\:"show in one column" dense\:"make unequal size columns to utilize more space" nodense\:"make equal size columns"))' \
+    '(--column)--no-column[do not display in columns]' \
     '*: :__git_ignore_line_inside_arguments _files'
 }
 
@@ -1655,9 +1680,9 @@ _git-tag () {
 
   _arguments -A '-*' \
     - creation \
-      '(   -s -u)-a[create an unsigned, annotated tag]' \
-      '(-a    -u)-s[create an signed and annotated tag]' \
-      '(-a -s   )-u[create a tag, annotated and signed with the given key]: :__git_gpg_secret_keys' \
+      '(   -s -u --local-user)-a[create an unsigned, annotated tag]' \
+      '(-a    -u --local-user)-s[create an signed and annotated tag]' \
+      '(-a -s)'{-u,--local-user}'[create a tag, annotated and signed with the given key]: :__git_gpg_secret_keys' \
       '-f[replace existing tag]' \
       '--cleanup=[cleanup message]:mode:((verbatim\:"no cleanup" whitespace\:"remove leading and trailing whitespace" strip\:"remove leading and trailing whitespace and comments"))' \
       $message_opts \
@@ -1669,6 +1694,8 @@ _git-tag () {
     - listing \
       '-n+[limit line output of annotation]: :__git_guard_number "limit"' \
       '-l[list tags matching pattern]' \
+      '(--no-column)--column=-[display tag listing in columns]::column.tag option:((always\:"always show in columns" never\:"never show in columns" auto\:"show in columns if the output is to the terminal" column\:"fill columns before rows (default)" row\:"fill rows before columns" plain\:"show in one column" dense\:"make unequal size columns to utilize more space" nodense\:"make equal size columns"))' \
+      '(--column)--no-column[do not display in columns]' \
       '--contains=[only list tags which contain the specified commit]: :__git_commits' \
       '--points-at=[only list tags of the given object]: :__git_commits' \
       '::pattern' \
@@ -1742,7 +1769,9 @@ _git-config () {
       '(2)--get-regexp[like "--get-all", but interpret "name" as a regular expression]' \
       '(2 3 --bool --int --bool-or-int --path -z --null)--get-colorbool[check if color should be used]: :->gettable-colorbool-option' \
       '(2 3 --bool --int --bool-or-int --path -z --null)--get-color[find color setting]: :->gettable-color-option' \
-      '(-e --edit --bool --int --bool-or-int --path -z --null)'{-e,--edit}'[open config file for editing]' && ret=0
+      '(-e --edit --bool --int --bool-or-int --path -z --null)'{-e,--edit}'[open config file for editing]' \
+      '(--no-includes)'--includes'[respect "include.*" directives in config files when looking up values]' \
+      '(--includes)'--no-includes'[do not respect "include.*" directives]' && ret=0
 
   # TODO: Most all _path_commands should be able to take arguments and so on.
   # How do we deal with that and how do we quote the whole argument to git
@@ -2679,7 +2708,9 @@ _git-fast-export () {
     '-C-[detect copies as well as renames with given scope]: :__git_guard_number size' \
     '--export-marks=[dump internal marks table when complete]: :_files' \
     '--import-marks=[load marks before processing input]: :_files' \
+    '--import-marks-if-exists=[silently skip if files does not exist]: :_files' \
     '--fake-missing-tagger=[fake a tagger when tags lack them]' \
+    '--use-done-feature[start with a "feature done" stanza, and terminate with a "done" command]' \
     '--no-data[do not output blocb objects, instead referring to them via their SHA-1 hash]' \
     '--full-tree[output full tree for each commit]' \
     '*: :__git_commit_ranges'
@@ -2688,9 +2719,11 @@ _git-fast-export () {
 (( $+functions[_git-fast-import] )) ||
 _git-fast-import () {
   _arguments -S -A '-*' \
+    '--cat-blob-fd=-[write responses to cat-blob and ls queries to <fd> instead of stdout]:file descriptor' \
     '--date-format=-[type of dates used in input]:format:((raw\:"native Git format"
                                                            rfc2822\:"standard email format from RFC 2822"
                                                            now\:"use current time and timezone"' \
+    '--done[terminate with error if there is no "done" command at the end of the stream]' \
     '--force[force updating modified existing branches]' \
     '--max-pack-size=-[maximum size of each packfile]: :__git_guard_bytes' \
     '--big-file-threshold=-[maximum size of blob to create deltas for]: :__git_guard_bytes' \
@@ -2732,6 +2765,7 @@ _git-mergetool () {
   # TODO: Only complete files with merge conflicts.
   _arguments -S -A '-*' \
     '(-t --tool)'{-t,--tool=}'[merge resolution program to use]: :__git_mergetools' \
+    '--tool-help[print a list of merge tools that may be used with "--tool"]' \
     '(-y --no-prompt --prompt)'{-y,--no-prompt}'[do not prompt before invocation of merge resolution program]' \
     '(-y --no-prompt)--prompt[prompt before invocation of merge resolution program]' \
     '*:conflicted file:_files'
@@ -3036,7 +3070,8 @@ _git-cherry () {
 (( $+functions[_git-count-objects] )) ||
 _git-count-objects () {
   _arguments \
-    '(-v --verbose)'{-v,--verbose}'[also report number of in-pack objects and objects that can be removed]'
+    '(-v --verbose)'{-v,--verbose}'[also report number of in-pack objects and objects that can be removed]' \
+    {-H,--human-readable}'[Print sizes in human readable format]'
 }
 
 (( $+functions[_git-difftool] )) ||
@@ -3048,6 +3083,9 @@ _git-difftool () {
     '(-y --no-prompt)--prompt[prompt before invocation of diff tool]' \
     '(-t --tool -x --extcmd)'{-t,--tool=-}'[merge resolution program to use]: :__git_difftools' \
     '(-t --tool -x --extcmd)'{-x,--extcmd=-}'[custom diff command to use]: :_path_commands' \
+    '--tool-help[print a list of diff tools that may be used with --tool]' \
+    '(--symlinks)--no-symlinks[make copies of instead of symlinks to the working tree]' \
+    '(---no-symlinks)--symlinks[make symlinks to instead of copies of the working tree]' \
     '(-g --gui)'{-g,--gui}'[use diff.guitool instead of diff.tool]'
 }
 
@@ -3077,10 +3115,11 @@ _git-get-tar-commit-id () {
 (( $+functions[_git-help] )) ||
 _git-help () {
   _arguments -w -S -s \
-    '(         -i --info -m --man -w --web)'{-a,--all}'[show all available commands]' \
-    '(-a --all           -m --man -w --web)'{-i,--info}'[show all available commands]' \
-    '(-a --all -i --info          -w --web)'{-m,--man}'[show all available commands]' \
-    '(-a --all -i --info -m --man         )'{-w,--web}'[show all available commands]' \
+    '(         -g --guides -i --info -m --man -w --web)'{-a,--all}'[show all available commands]' \
+    '(-a --all -g --guides           -m --man -w --web)'{-i,--info}'[show all available commands]' \
+    '(-a --all -g --guides -i --info          -w --web)'{-m,--man}'[show all available commands]' \
+    '(-a --all -g --guides -i --info -m --man         )'{-w,--web}'[show all available commands]' \
+    '(-g --guides)'{-g,--guides}'[prints a list of useful guides on the standard output]' \
     ': :_git_commands'
 }
 
@@ -3200,6 +3239,7 @@ _git-rev-parse () {
       '(           --symbolic-full-name)--symbolic[output in a format as true to input as possible]' \
       '(--symbolic                     )--symbolic-full-name[same as --symbolic, but omit non-ref inputs]' \
       '--abbrev-ref=-[a non-ambiguous short name of object]::mode:(strict loose)' \
+      '--disambiguate=-[show every object whose name begins with the given prefix]:prefix' \
       '--all[show all refs found in refs/]' \
       '--branches=-[show branch refs found in refs/heads/]::shell glob pattern' \
       '--tags=-[show tag refs found in refs/tags/]::shell glob pattern' \
@@ -3215,6 +3255,7 @@ _git-rev-parse () {
       '(--revs-only --no-revs --flags --no-flags --verify)--short=-[show only shorter unique name]:: :__git_guard_number length' \
       '(--since --after)'{--since=-,--after=-}'[show --max-age= parameter corresponding given date string]:datestring' \
       '(--until --before)'{--until=-,--before=-}'[show --min-age= parameter corresponding given date string]:datestring' \
+      '--resolve-git-dir[check if <path> is a valid repository or gitfile and print location]:git dir:_files -/' \
       '*: :__git_objects' && ret=0
   fi
 
@@ -3394,13 +3435,16 @@ _git-send-email () {
     '--subject=[specify the initial subject of the email thread]:subject' \
     '--to=[specify the primary recipient of the emails]: :_email_addresses' \
     '--8bit-encoding=[encoding to use for non-ASCII messages]: :__git_encodings' \
+    '--compose-encoding=[encoding to use for compose messages]: :__git_encodings' \
     '--envelope-sender[specify the envelope sender used to send the emails]: :_email_addresses' \
     '--smtp-encryption=[specify encryption method to use]: :__git_sendemail_smtpencryption_values' \
     '--smtp-domain=[specify FQDN used in HELO/EHLO]: :_domains' \
     '--smtp-pass=[specify password to use for SMTP-AUTH]::password' \
     '--smtp-server=[specify SMTP server to connect to]:smtp server:_hosts' \
     '--smtp-server-port=[specify port to connect to SMTP server on]:smtp port:_ports' \
+    '--smtp-server-option=[specify the outgoing SMTP server option to use]:SMPT server option' \
     '--smtp-user=[specify user to use for SMTP-AUTH]:smtp user:_users' \
+    '--smtp-debug=[enable or disable debug output]:smtp debug:((0\:"disable" 1\:"enable"))' \
     '--cc-cmd=[specify command to generate Cc\: header with]:Cc\: command:_path_commands' \
     '--to-cmd=[specify command to generate To\: header with]:To\: command:_path_commands' \
     '(                 --no-chain-reply-to)--chain-reply-to[send each email as a reply to previous one]' \
@@ -3919,6 +3963,7 @@ _git-read-tree () {
     $exclude_per_directory_opt \
     '--index-output=[write index in the named file instead of $GIT_INDEX_FILE]: :_files' \
     '--no-sparse-checkout[display sparse checkout support]' \
+    '--empty[instead of reading tree object(s) into the index, just empty it]' \
     '1:first tree-ish to be read/merged:__git_tree_ishs' \
     '2::second tree-ish to be read/merged:__git_tree_ishs' \
     '3::third tree-ish to be read/merged:__git_tree_ishs'
@@ -4333,6 +4378,8 @@ _git-daemon () {
     '--disable=-[disable site-wide service]: :__git_daemon_service' \
     '--allow-override[allow overriding site-wide service]: :__git_daemon_service' \
     '--forbid-override[forbid overriding site-wide service]: :__git_daemon_service' \
+    '(--no-informative-errors)--informative-errors[report more verbose errors to the client]' \
+    '(--informative-errors)--no-informative-errors[report all errors as "access denied" to the client]' \
     '*:repository:_directories'
 }
 
@@ -4537,7 +4584,10 @@ _git-check-attr () {
 _git-check-ref-format () {
   _arguments \
     '-h[display usage information]' \
-    '--print[display canonicalized name of hypothetical reference of given name]' \
+    '(--no-allow-onelevel)--allow-onelevel[accept one-level refnames]' \
+    '(--allow-onelevel)--no-allow-onelevel[do not accept one-level refnames]' \
+    '--refspec-pattern[interpret <refname> as a reference name pattern for a refspec]' \
+    '--normalize[Normalize refname by removing leading slashes]' \
     '--branch[expand previous branch syntax]' \
     ': :__git_references'
 }
@@ -4592,7 +4642,8 @@ _git-patch-id () {
 (( $+functions[_git-stripspace] )) ||
 _git-stripspace () {
   _arguments \
-    '(-s --strip-comments)'{-s,--strip-comments}'[also strip lines starting with #]'
+    '(-s --strip-comments)'{-s,--strip-comments}'[also strip lines starting with #]' \
+    '(-c --comment-lines)'{-c,--comment-lines}'[prepend comment character and blank to each line]'
 }
 
 # INTERNAL GIT COMPLETION FUNCTIONS
@@ -5750,10 +5801,11 @@ __git_setup_diff_options () {
     # TODO: --break-rewrites is undocumented.
     '(-B --break-rewrites)'{-B-,--break-rewrites=-}'[break complete rewrite changes into pairs of given size]:: :__git_guard_number size'
     # TODO: --detect-renames is undocumented.
-    '(-M --detect-renames)'{-M-,--detect-renames=-}'[detect renames with given scope]:: :__git_guard_number size'
+    '(-M --find-renames)'{-M-,--find-renames=-}'[Detect renames with given scope]:: :__git_guard_number size'
     # TODO: --detect-copies is undocumented.
     '(-C --detect-copies)'{-C-,--detect-copies=-}'[detect copies as well as renames with given scope]:: :__git_guard_number size'
     '--find-copies-harder[try harder to find copies]'
+    '(-D --irreversible-delete)'{-D,--irreversible-delete}'[omit the preimage for deletes]'
     '-l-[limit number of rename/copy targets to run]: :__git_guard_number'
     '--diff-filter=-[select certain kinds of files for diff]: :_guard "[ACDMRTUXB*]#" kinds'
     '-S-[look for differences that contain the given string]:string'
@@ -5816,7 +5868,8 @@ __git_setup_revision_options () {
                                                                                     email\:"use email headers like From and Subject"
                                                                                     raw\:"the raw commits"
                                                                                     format\:"specify own format"))'
-    '--abbrev-commit[show only partial prefixes of commit object names]'
+    '(--abbrev-commit --no-abbrev-commit)--abbrev-commit[show only partial prefixes of commit object names]'
+    '(--abbrev-commit --no-abbrev-commit)--no-abbrev-commit[show the full 40-byte hexadecimal commit object name]'
     '--oneline[shorthand for --pretty=oneline --abbrev-commit]'
     '--encoding=-[output log messages in given encoding]:: :__git_encodings'
     '(--no-notes --notes)--no-notes[do not show notes that annotate commit]'
@@ -5845,6 +5898,10 @@ __git_setup_revision_options () {
     '--remove-empty[stop when given path disappears from tree]'
     '--merges[display only merge commits]'
     '--no-merges[do not display commits with more than one parent]'
+    '(--min-parents --no-min-parents)--min-parents=-[show only commits having at least <n> commits]: :__git_guard_number "minimum number of parents"'
+    '(--min-parents --no-min-parents)--no-min-parents[reset limit]'
+    '(--max-parents --no-max-parents)--max-parents=-[show only commits having at most <n> commits]: :__git_guard_number "maximum number of parents"'
+    '(--max-parents --no-max-parents)--no-max-parents[reset limit]'
     '--first-parent[follow only first parent from merge commits]'
     '*--not[reverses meaning of ^ prefix for revisions that follow]'
     '--all[show all commits from refs]'
@@ -5914,6 +5971,8 @@ __git_setup_merge_options () {
     '--ff-only[refuse to merge unless HEAD is up to date or merge can be resolved as a fast-forward]'
     '*'{-s,--strategy=}'[use given merge strategy]:merge strategy:__git_merge_strategies'
     '*'{-X,--strategy-option=}'[pass merge-strategy-specific option to merge strategy]'
+    '(--verify-signatures)--no-verify-signatures[verify the commits being merged or abort]'
+    '(--no-verify-signatures)--verify-signatures[do not verify the commits being merged]'
     '(-q --quiet -v --verbose)'{-q,--quiet}'[suppress all output]'
     '(-q --quiet -v --verbose)'{-v,--verbose}'[output additional information]')
 }
@@ -5933,10 +5992,13 @@ __git_setup_fetch_options () {
     '(--no-tags -t --tags)'{-t,--tags}'[fetch remote tags]'
     '(-u --update-head-ok)'{-u,--update-head-ok}'[allow updates of current branch head]'
     '--upload-pack=[specify path to git-upload-pack on remote side]:remote path'
-    '(--no-recurse-submodules --recurse-submodules)--recurse-submodules=[specify when to fetch commits of submodules]:recursive fetching mode:((no\:"disable recursion"
+    '(--no-recurse-submodules --recurse-submodules)--recurse-submodules=-[specify when to fetch commits of submodules]::recursive fetching mode:((no\:"disable recursion"
                                                                                                                                                 yes\:"always recurse"
                                                                                                                                                 on-demand\:"only when submodule reference in superproject is updated"))'
     '(--no-recurse-submodules --recurse-submodules)--no-recurse-submodules[disable recursive fetching of submodules]'
+    '(--no-recurse-submodules)--recurse-submodules-default=-[provide internal temporary non-negative value for "--recurse-submodules"]::recursive fetching mode:((yes\:"always recurse"
+                                                                                                                                                                 on-demand\:"only when submodule reference in superproject is updated"))'
+    '--submodule-prefix=-[prepend <path> to paths printed in informative messages]:submodule prefix path:_files -/'
     '(-q --quiet -v --verbose --progress)'{-q,--quiet}'[suppress all output]'
     '(-q --quiet -v --verbose)'{-v,--verbose}'[output additional information]'
     '(-q --quiet)--progress[output progress information]')
@@ -6271,13 +6333,17 @@ _git() {
       '(- :)--help[display help message]' \
       '-c[pass configuration parameter to command]:parameter' \
       '--exec-path=-[path containing core git-programs]:: :_directories' \
-      '--html-path[display path to HTML documentation and exit]' \
+      '(: -)--man-path[print the manpath for the man pages for this version of Git and exit]' \
+      '(: -)--info-path[print the path where the info files are installed and exit]' \
+      '(: -)--html-path[display path to HTML documentation and exit]' \
       '(-p --paginate)'{-p,--paginate}'[pipe output into $PAGER]' \
       '--no-pager[do not pipe git output into a pager]' \
       '--git-dir=-[path to repository]: :_directories' \
       '--work-tree=-[path to working tree]: :_directories' \
+      '--namespace=-[set the Git namespace]: :_directories' \
       '--bare[use $PWD as repository]' \
       '--no-replace-objects[do not use replacement refs to replace git objects]' \
+      '--literal-pathspecs[treat pathspecs literally, rather than as glob patterns]' \
       '(-): :->command' \
       '(-)*:: :->option-or-argument' && return
 
-- 
1.8.2.2


^ permalink raw reply	[relevance 1%]

* [PATCH 05/16] _git: completion updates to match latest git v1.8.3
  @ 2013-07-28 16:22  3% ` Øystein Walle
  2013-07-28 16:22  1% ` [PATCH 06/16] _git: completion updates to match latest git v1.8.3 part 2 Øystein Walle
  1 sibling, 0 replies; 200+ results
From: Øystein Walle @ 2013-07-28 16:22 UTC (permalink / raw)
  To: zsh-workers; +Cc: m0viefreak.cm

From: m0viefreak <m0viefreak.cm@googlemail.com>

---
 Completion/Unix/Command/_git | 258 ++++++++++++++++++++++++++++++++-----------
 1 file changed, 196 insertions(+), 62 deletions(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 6370c99..3080872 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -277,12 +277,13 @@ _git-bisect () {
 
 (( $+functions[_git-branch] )) ||
 _git-branch () {
-  declare l c m d
+  declare l c m d e
 
-  l='--color --no-color -r -a -v --verbose --abbrev --no-abbrev'
-  c='-l -f --force -t --track --no-track --set-upstream --contains --merged --no-merged'
-  m='-m -M'
-  d='-d -D'
+  l='--color --no-color -r -a -v --verbose --abbrev --no-abbrev --list'
+  c='-l -f --force -t --track --no-track -u --set-upstream --set-upstream-to --unset-upstream --contains --merged --no-merged'
+  m='-m --move -M'
+  d='-d --delete -D'
+  e='--edit-description'
 
   declare -a dependent_creation_args
   if (( words[(I)-r] == 0 )); then
@@ -312,27 +313,31 @@ _git-branch () {
   fi
 
   _arguments -w -S -s \
-    "($c $m $d --no-color :)--color=-[turn on branch coloring]:: :__git_color_whens" \
-    "($c $m $d : --color)--no-color[turn off branch coloring]" \
-    "($c $m      -a)-r[list or delete only remote-tracking branches]" \
-    "($c $m $d : -r)-a[list both remote-tracking branches and local branches]" \
-    "($c $m $d : -v --verbose)"{-v,--verbose}'[show SHA1 and commit subject line for each head]' \
-    "($c $m $d :)--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length" \
-    "($c $m $d :)--no-abbrev[do not abbreviate sha1s]" \
-    "($l $m $d)-l[create the branch's reflog]" \
-    "($l $m $d -f --force)"{-f,--force}"[force the creation of a new branch]" \
-    "($l $m $d -t --track)"{-t,--track}"[set up configuration so that pull merges from the start point]" \
-    "($l $m $d)--no-track[override the branch.autosetupmerge configuration variable]" \
-    "($l $m $d)--set-upstream[set up configuration so that pull merges]" \
-    "($l $m $d)--contains=[only list branches which contain the specified commit]: :__git_committishs" \
-    "($l $m $d)--merged=[only list branches which are fully contained by HEAD]: :__git_committishs" \
-    "($l $m $d)--no-merged=[do not list branches which are fully contained by HEAD]: :__git_committishs" \
+    "($c $m $d $e --no-color :)--color=-[turn on branch coloring]:: :__git_color_whens" \
+    "($c $m $d $e : --color)--no-color[turn off branch coloring]" \
+    "($c $m $d $e )*--list[list only branches matching glob]:pattern" \
+    "($c $m    $e  -a)-r[list or delete only remote-tracking branches]" \
+    "($c $m $d $e: -r)-a[list both remote-tracking branches and local branches]" \
+    "($c $m $d $e : -v --verbose)"{-v,--verbose}'[show SHA1 and commit subject line for each head]' \
+    "($c $m $d $e :)--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length" \
+    "($c $m $d $e :)--no-abbrev[do not abbreviate sha1s]" \
+    "($l $m $d $e)-l[create the branch's reflog]" \
+    "($l $m $d $e -f --force)"{-f,--force}"[force the creation of a new branch]" \
+    "($l $m $d $e -t --track)"{-t,--track}"[set up configuration so that pull merges from the start point]" \
+    "($l $m $d $e)--no-track[override the branch.autosetupmerge configuration variable]" \
+    "($l $m $d $e -u --set-upstream --set-upstream-to --unset-upstream)"{-u,--set-upstream-to=}"[set up configuration so that pull merges]:remote-branches:__git_remote_branch_names" \
+    "($l $m $d $e -u --set-upstream --set-upstream-to --unset-upstream)--unset-upstream[remove upstream configuration]" \
+    "($l $m $d $e)--contains=[only list branches which contain the specified commit]: :__git_committishs" \
+    "($l $m $d $e)--merged=[only list branches which are fully contained by HEAD]: :__git_committishs" \
+    "($l $m $d $e)--no-merged=[do not list branches which are fully contained by HEAD]: :__git_committishs" \
+    "($c $l $m $d)--edit-description[edit branch description]" \
     $dependent_creation_args \
-    "($l $c $d -M)-m[rename a branch and the corresponding reflog]" \
-    "($l $c $d -m)-M[rename a branch even if the new branch-name already exists]" \
+    "($l $c $d $m $e)"{-m,--move}"[rename a branch and the corresponding reflog]" \
+    "($l $c $d $m $e)-M[rename a branch even if the new branch-name already exists]" \
     $dependent_modification_args \
-    "($l $c $m -D)-d[delete a fully merged branch]" \
-    "($l $c $m -d)-D[delete a branch]" \
+    "($l $c $m $d $e)"{-d,--delete}"[delete a fully merged branch]" \
+    "($l $c $m $d $e)-D[delete a branch]" \
+    {-q,--quiet}"[be more quiet]" \
     $dependent_deletion_args
 }
 
@@ -464,11 +469,17 @@ _git-checkout () {
 (( $+functions[_git-cherry-pick] )) ||
 _git-cherry-pick () {
   _arguments \
+    '(--abort --continue --quit)--abort[cancel the operation]' \
+    '(--abort --continue --quit)--continue[continue the operation]' \
+    '(--abort --continue --quit)--quit[forget about the operation in progress]' \
+    '--allow-empty-message[allow replaying a commit with an empty message]' \
     '(-e --edit --ff)'{-e,--edit}'[edit commit before committing the revert]' \
     '(--ff)-x[append information about what commit was cherry-picked]' \
     '(-m --mainline)'{-m,--mainline}'[specify mainline when cherry-picking a merge commit]:parent number' \
     '(-n --no-commit --ff)'{-n,--no-commit}'[do not make the actually commit]' \
     '(-s --signoff --ff)'{-s,--signoff}'[add Signed-off-by line at the end of the commit message]' \
+    '*'{-s,--strategy=}'[use given merge strategy]:merge strategy:__git_merge_strategies' \
+    '*'{-X,--strategy-option=}'[pass merge-strategy-specific option to merge strategy]' \
     '(-e --edit -x -n --no-commit -s --signoff)--ff[fast forward, if possible]' \
     ': :__git_revisions'
 }
@@ -543,7 +554,8 @@ _git-clone () {
   # TODO: Argument to -b should complete branch names in the repository being
   # cloned.
   _arguments -w -C -S -s \
-    '(-l --local)'{-l,--local}'[clone locally, hardlink refs and objects if possible]' \
+    '(-l --local --no-local)'{-l,--local}'[clone locally, hardlink refs and objects if possible]' \
+    '(-l --local --no-local)--no-local[override --local, as if file:/// URL was given]' \
     '--no-hardlinks[copy files instead of hardlinking when doing a local clone]' \
     '(-s --shared)'{-s,--shared}'[share the objects with the source repository (warning: see man page)]' \
     '--reference[reference repository]:repository:_directories' \
@@ -557,7 +569,9 @@ _git-clone () {
     '(-b --branch)'{-b,--branch}'[point HEAD to the given branch]: :__git_guard_branch-name' \
     '(-u --upload-pack)'{-u,--upload-pack=}'[specify path to git-upload-pack on remote side]:remote path' \
     '--template=[directory to use as a template for the object database]: :_directories' \
+    '*'{-c,--config}'[<key>=<value> set a configuration variable in the newly created repository]' \
     '--depth[create a shallow clone, given number of revisions deep]: :__git_guard_number depth' \
+    '--single-branch[clone only history leading up to the main branch or the one specified by -b]' \
     '--recursive[initialize all contained submodules]' \
     ': :->repository' \
     ': :_directories' && ret=0
@@ -595,17 +609,19 @@ _git-commit () {
     '(        --porcelain --dry-run)--short[output dry run in short format]' \
     '(--short             --dry-run)--porcelain[output dry run in porcelain-ready format]' \
     '(--short --porcelain --dry-run -z --null)'{-z,--null}'[separate dry run entry output with NUL]' \
+    '--patch[use the interactive patch selection interface to chose which changes to commit]' \
     '(--reset-author)--author[override the author name used in the commit]:author name' \
     '--date=[override the author date used in the commit]:date' \
     '(-s --signoff)'{-s,--signoff}'[add Signed-off-by line at the end of the commit message]' \
     '(-n --no-verify)'{-n,--no-verify}'[do not look for suspicious lines the commit introduces]' \
     '--allow-empty[allow recording an empty commit]' \
     '--allow-empty-message[allow recording a commit with an empty message]' \
-    '--cleanup=[specify how the commit message should be cleaned up]:mode:((verbatim\:"don'\''t change the commit message at all"
+    '--cleanup=[specify how the commit message should be cleaned up]:mode:((verbatim\:"do not change the commit message at all"
                                                                             whitespace\:"remove leading and trailing whitespace lines"
                                                                             strip\:"remove both whitespace and commentary lines"
                                                                             default\:"act as '\''strip'\'' if the message is to be edited and as '\''whitespace'\'' otherwise"))' \
-    '(-e --edit)'{-e,--edit}'[edit the commit message before committing]' \
+    '(-e --edit --no-edit)'{-e,--edit}'[edit the commit message before committing]' \
+    '(-e --edit --no-edit)--no-edit[do not edit the commit message before committing]' \
     '(-a --all --interactive -o --only -i --include)'{-i,--include}'[update the given files and commit the whole index]' \
     '(-a --all --interactive -o --only -i --include)'{-o,--only}'[commit only the given files]' \
     '(-u --untracked-files)'{-u-,--untracked-files=}'[show files in untracked directories]::mode:((no\:"show no untracked files"
@@ -616,7 +632,10 @@ _git-commit () {
     '--dry-run[only show list of paths that are to be commited or not, and any untracked]' \
     '(         --no-status)--status[include the output of git status in the commit message template]' \
     '(--status            )--no-status[do not include the output of git status in the commit message template]' \
+    '(-S --gpg-sign)'{-S-,--gpg-sign=}'[GPG-sign the commit]::key id' \
     '(-a --all --interactive -o --only -i --include *)--interactive[interactively update paths in the index file]' \
+    '--fixup=[construct a commit message for use with rebase --autosquash to automatically fixup]: :__git_commits' \
+    '--squash=[construct a commit message for use with rebase --autosquash to automatically squash]: :__git_commits' \
     '*: :__git_ignore_line_inside_arguments __git_changed_files' \
     - '(message)' \
       {-C,--reuse-message=}'[use existing commit object with same log message]: :__git_commits' \
@@ -788,14 +807,17 @@ _git-format-patch () {
     '(--thread            )--no-thread[do not thread messages]' \
     '--in-reply-to=[make the first mail a reply to the given message]:message id' \
     '--ignore-if-in-upstream[do not include a patch that matches a commit in the given range]' \
+    '(-v --reroll-count)'{-v,--reroll-count=}'[mark the series as the <n>-th iteration of the topic]: :__git_guard_number iteration' \
     '(-k --keep-subject)--subject-prefix=[use the given prefix instead of \[PATCH\]]:prefix' \
     '*--to=[add To: header to email headers]: :_email_addresses' \
     '*--cc=[add Cc: header to email headers]: :_email_addresses' \
     '*--add-header=[add an arbitrary header to email headers]:header' \
     '--cover-letter[generate a cover letter template]' \
+    '--notes=[append notes for the commit after the three-dash line]:: :__git_notes_refs' \
     '(            --no-signature)--signature=[add a signature]:signature' \
     '(--signature               )--no-signature[do not add a signature]' \
     '--suffix=[use the given suffix for filenames]:filename suffix' \
+    '--quiet[suppress the output of the names of generated files]' \
     '--no-binary[do not output contents of changes in binary files, only note that they differ]' \
     '--root[treat the revision argument as a range]' \
     ': :->commit-or-commit-range' && ret=0
@@ -842,6 +864,8 @@ _git-grep () {
   _arguments -C -A '-*' \
     '(-O --open-files-in-pager --no-index)--cached[search blobs registered in index file instead of working tree]' \
     '(--cached)--no-index[search files in current directory, not just treacked files]' \
+    '--exclude-standard[exclude files standard ignore mechanisms]' \
+    '--untracked[search in untracked files]' \
     '(-a --text)'{-a,--text}'[process binary files as if they were text]' \
     '(-i --ignore-case)'{-i,--ignore-case}'[ignore case when matching]' \
     '-I[do not match pattern in binary files]' \
@@ -851,9 +875,10 @@ _git-grep () {
     '(   -H)-h[supress output of filenames]' \
     '(-h   )-H[show filenames]' \
     '--full-name[output paths relative to the project top directory]' \
-    '(-E --extended-regexp -G --basic-regexp)'{-E,--extended-regexp}'[use POSIX extended regexes]' \
-    '(-E --extended-regexp -G --basic-regexp)'{-G,--basic-regexp}'[use POSIX basic regexes]' \
-    '(-F --fixed-strings)'{-F,--fixed-strings}'[do not interpret pattern as a regex]' \
+    '(-E --extended-regexp -G --basic-regexp -P --perl-regexp -F --fixed-strings)'{-E,--extended-regexp}'[use POSIX extended regexes]' \
+    '(-E --extended-regexp -G --basic-regexp -P --perl-regexp -F --fixed-strings)'{-G,--basic-regexp}'[use POSIX basic regexes]' \
+    '(-E --extended-regexp -G --basic-regexp -P --perl-regexp -F --fixed-strings)'{-P,--perl-regexp}'[use perl-compatible regexes]' \
+    '(-E --extended-regexp -G --basic-regexp -P --perl-regexp -F --fixed-strings)'{-F,--fixed-strings}'[do not interpret pattern as a regex]' \
     '-n[prefix the line number to matching lines]' \
     '(-l --files-with-matches -L --files-without-match --name-only)'{-l,--files-with-matches,--name-only}'[show only names of matching files]' \
     '(-l --files-with-matches -L --files-without-match)'{-L,--files-without-match}'[show only names of non-matching files]' \
@@ -862,10 +887,13 @@ _git-grep () {
     '(-c --count)'{-c,--count}'[show number of matching lines in files]' \
     '(        --no-color)--color=-[color matches]:: :__git_color_whens' \
     '(--color           )---no-color[do not color matches]' \
+    '--break[prefix the line number to matching lines]' \
+    '--heading[show the filename above the matches]' \
     '-A[show trailing context]: :__git_guard_number lines' \
     '-B[show leading context]: :__git_guard_number lines' \
     '-C[show context]: :__git_guard_number lines' \
     '(-p --show-function)'{-p,--show-function}'[show preceding line containing function name of match]' \
+    '(-W --function-context)'{-W,--function-context}'[show whole function where a match was found]' \
     '(1)*-f[read patterns from given file]:pattern file:_files' \
     '(1)*-e[use the given pattern for matching]:pattern' \
     $pattern_operators \
@@ -979,6 +1007,7 @@ _git-init () {
     '--bare[create a bare repository]' \
     '--template=[directory to use as a template for the object database]: :_directories' \
     '--shared=[share repository amongst several users]:: :__git_repository_permissions' \
+    '--separate-git-dir=[create git dir elsewhere and link it using the gitdir mechanism]:: :_directories' \
     ':: :_directories'
 }
 
@@ -1039,6 +1068,7 @@ _git-merge () {
     '-m[set the commit message to be used for the merge commit]:merge message' \
     '(                    --no-rerere-autoupdate)--rerere-autoupdate[allow the rerere mechanism to update the index]' \
     '(--rerere-autoupdate                       )--no-rerere-autoupdate[do not allow the rerere mechanism to update the index]' \
+    '--abort[restore the original branch and abort the merge operation]' \
     '*: :__git_commits'
 }
 
@@ -1085,6 +1115,7 @@ _git-notes () {
         copy:'copy notes from one object to another'
         append:'append notes to a given object'
         edit:'edit notes for a given object'
+        merge:'merge the given notes ref into the current ref'
         show:'show notes for a given object'
         remove:'remove notes for a given object'
         prune:'remove all notes for non-existing/unreachable objects')
@@ -1119,6 +1150,15 @@ _git-notes () {
             ': :__git_commits' \
             ': :__git_commits' && ret=0
           ;;
+        (merge)
+          _arguments -w -S -s \
+            '(-s --strategy)--abort[abort an in-progress notes merge]' \
+            '(-s --strategy)--commit[finalize an in-progress notes merge]' \
+            {-q,--quiet}'[be quiet]' \
+            {-v,--verbose}'[be more verbose]' \
+            '(--abort --commit)'{-s,--strategy=}'[resolve conflicts using the given strategy]' \
+            ': :__git_notes_refs' && ret=0
+          ;;
         (append)
           _arguments -w -S -s \
             '*'{-m,--message=}'[use given note message]:message' \
@@ -1160,6 +1200,7 @@ _git-push () {
   # later on to match the remote end.
   _arguments -w -S -s \
     '--all[push all refs under refs/heads/]' \
+    '--prune[remove remote branches that do not have a local counterpart]' \
     '--mirror[push all refs under refs/heads/ and refs/tags/ and delete non-existing refs]' \
     '(-n --dry-run)'{-n,--dry-run}'[do everything except actually send the updates]' \
     '--porcelain[produce machine-readable output]' \
@@ -1168,12 +1209,14 @@ _git-push () {
     '(--receive-pack --exec)'{--receive-pack=-,--exec=-}'[path to git-receive-pack on remote]:remote git-receive-pack:_files' \
     '(-f --force)'{-f,--force}'[allow refs that are not ancestors to be updated]' \
     '(:)--repo=[default repository to use]:repository:__git_any_repositories' \
-    '(-u --set-upstream)'{-u,--set-upstream}'[add upstream reference for each branch that is up to date or pushed]' \
+    '(-u --set-upstream-to)'{-u,--set-upstream-to}'[add upstream reference for each branch that is up to date or pushed]' \
     '(       --no-thin)--thin[try to minimize number of objects to be sent]' \
     '(--thin          )--no-thin[do not try to minimize number of objects to be sent]' \
     '(-q --quiet -v --verbose --progress)'{-q,--quiet}'[suppress all output]' \
     '(-q --quiet -v --verbose)'{-v,--verbose}'[output additional information]' \
     '(-q --quiet)--progress[output progress information]' \
+    '--recurse-submodules=[submodule handling]:submodule handling:((check\:"refuse pushing of supermodule if submodule commit cannot be found on the remote"
+                                                                    on-demand\:"push all changed submodules"))' \
     ':: :__git_any_repositories' \
     '*: :__git_ref_specs'
 }
@@ -1182,7 +1225,7 @@ _git-push () {
 _git-rebase () {
   local -a autosquash_opts
 
-  if (( words[(I)--interactive] )); then
+  if (( words[(I)-i|--interactive] )); then
     autosquash_opts=(
       '(             --no-autosquash)--autosquash[check for auto-squash boundaries]'
       '(--autosquash                )--no-autosquash[do not check for auto-squash boundaries]')
@@ -1204,7 +1247,9 @@ _git-rebase () {
     '(-i --interactive)--whitespace=-[detect a new or modified line that has whitespace errors]: :__git_apply_whitespace_strategies' \
     '(-i --interactive)--committer-date-is-author-date[use author date as committer date]' \
     '(-i --interactive --ignore-whitespace --whitespace --committer-date-is-author-date)'{-i,--interactive}'[make a list of commits to be rebased and open in $EDITOR]' \
+    '--edit-todo[edit interactive instruction sheet in an editor]' \
     '(-p --preserve-merges --interactive)'{-p,--preserve-merges}'[try to recreate merges instead of ignoring them]' \
+    {-x,--exec}'[with -i\: append "exec <cmd>" after each line]:command' \
     '(1)--root[rebase all reachable commits]' \
     $autosquash_opts \
     '--no-ff[cherry-pick all rebased commits with --interactive, otherwise synonymous to --force-rebase]' \
@@ -1246,6 +1291,9 @@ _git-reset () {
 (( $+functions[_git-revert] )) ||
 _git-revert () {
   _arguments -w -S -s \
+    '(--abort --continue --quit)--abort[cancel the operation]' \
+    '(--abort --continue --quit)--continue[continue the operation]' \
+    '(--abort --continue --quit)--quit[forget about the operation in progress]' \
     '(-e --edit --no-edit)'{-e,--edit}'[edit the commit before committing the revert]' \
     '(-m --mainline)'{-m+,--mainline=}'[pick which parent is mainline]:parent number' \
     '(-e --edit)--no-edit[do not edit the commit message]' \
@@ -1407,6 +1455,7 @@ _git-stash () {
             '(             --no-keep-index)--keep-index[all changes already added to the index are left intact]' \
             '(--keep-index                )--no-keep-index[all changes already added to the index are undone]' \
             '(-q --quiet)'{-q,--quiet}'[suppress all output]' \
+            '(-u --include-untracked)'{-u,--include-untracked}'[include untracked files]' \
             '::message' && ret=0
           ;;
         (list)
@@ -1496,6 +1545,7 @@ _git-submodule () {
         add:'add given repository as a submodule'
         status:'show the status of a submodule'
         init:'initialize a submodule'
+        deinit:'unregister a submodule'
         update:'update a submodule'
         summary:'show commit summary between given commit and working tree/index'
         foreach:'evaluate shell command in each checked-out submodule'
@@ -1514,6 +1564,7 @@ _git-submodule () {
             '(-q --quiet)'{-q,--quiet}'[suppress all output]' \
             '(-b --branch)'{-b,--branch}'[branch of repository to add as submodule]' \
             '(-f --force)'{-f,--force}'[allow adding an otherwise ignored submodule path]' \
+            '--name[use given name instead of defaulting to its path]:name' \
             '--reference=[remote repository to clone]: :__git_any_repositories' \
             ': :__git_any_repositories' \
             ':: :_directories' && ret=0
@@ -1530,6 +1581,11 @@ _git-submodule () {
             '(-q --quiet)'{-q,--quiet}'[suppress all output]' \
             '*: :__git_ignore_line_inside_arguments __git_submodules' && ret=0
           ;;
+        (deinit)
+          _arguments -S \
+            '(-f --force)'{-f,--force}'[remove submodule worktree even if local modifications are present]' \
+            '*: :__git_ignore_line_inside_arguments __git_submodules' && ret=0
+          ;;
         (update)
           # TODO: --init not properly documented.
           _arguments -S \
@@ -1539,6 +1595,7 @@ _git-submodule () {
             '--rebase[rebase current branch onto commit recorded in superproject]' \
             '--reference=[remote repository to clone]: :__git_any_repositories' \
             '--recursive[traverse submodules recursively]' \
+            '--force[discard local changes by checking out the current up-to-date version]' \
             '--init[initialize uninitialized submodules]' \
             '*: :__git_ignore_line_inside_arguments __git_submodules' && ret=0
           ;;
@@ -1572,6 +1629,7 @@ _git-submodule () {
           ;;
         (sync)
           _arguments -S \
+            '--recursive[traverse submodules recursively]' \
             '(-q --quiet)'{-q,--quiet}'[suppress all output]' \
             '*: :__git_ignore_line_inside_arguments __git_submodules' && ret=0
           ;;
@@ -1601,6 +1659,7 @@ _git-tag () {
       '(-a    -u)-s[create an signed and annotated tag]' \
       '(-a -s   )-u[create a tag, annotated and signed with the given key]: :__git_gpg_secret_keys' \
       '-f[replace existing tag]' \
+      '--cleanup=[cleanup message]:mode:((verbatim\:"no cleanup" whitespace\:"remove leading and trailing whitespace" strip\:"remove leading and trailing whitespace and comments"))' \
       $message_opts \
       ': :__git_tags' \
       ':: :__git_commits' \
@@ -1611,6 +1670,7 @@ _git-tag () {
       '-n+[limit line output of annotation]: :__git_guard_number "limit"' \
       '-l[list tags matching pattern]' \
       '--contains=[only list tags which contain the specified commit]: :__git_commits' \
+      '--points-at=[only list tags of the given object]: :__git_commits' \
       '::pattern' \
     - verification \
       '-v[verifies gpg signutare of tags]' \
@@ -1791,15 +1851,19 @@ _git-config () {
     color.status.untracked:'color of files not currently being tracked::->color'
     color.status.nobranch:'color of no-branch warning::->color'
     color.ui:'color output of capable git commands::->color-bool'
+    commit.cleanup:'default --cleanup option::->commit.cleanup:default'
     commit.status:'include status information in commit message template::->bool:true'
     commit.template:'template file for commit messages:template:_files'
+    diff.algorithm:'default diff algorithm::->diff.algorithm:default'
     diff.autorefreshindex:'run git update-index --refresh before git diff::->bool:true'
+    diff.context:'default number of context lines::->int:3'
     diff.external:'command to generate diff with:diff command:_path_commands'
     diff.mnemonicprefix:'use mnemonic source and destination prefixes::->bool:false'
     diff.noprefix:'strip source and destination prefixes::->bool:false'
     diff.renameLimit:'number of files to consider when detecting copy/renames:rename limit:->int'
     diff.renames:'try to detect renames::->diff.renames:true'
     diff.ignoreSubmodules:'ignore submodules::->bool:false'
+    diff.submodule:'output format for submodule differences::->diff.submodule:short'
     diff.suppressBlankEmpty:'inbihit printing space before empty output lines::->bool:false'
     diff.tool:'diff tool to use::__git_difftools'
     'difftool.*.cmd:command to invoke for the diff tool::_path_commands'
@@ -1869,7 +1933,10 @@ _git-config () {
     guitool.revunmerged:'show only unmerged branches in revprompt::->bool:false'
     guitool.title:'title of prompt dialog:prompt title:->string'
     guitool.prompt:'prompt to display:prompt:->string'
+    grep.lineNumber:'enable -n option by default::->bool:false'
+    grep.patternType:'default matching pattern type::->grep.patternType:default'
     help.browser:'browser used to display help in web format::__git_browsers'
+    help.htmlpath:'location of HTML help::->help.htmlpath'
     help.format:'default help format used by git help::->help.format'
     help.autocorrect:'execute corrected mistyped commands::->bool:false'
     http.proxy:'HTTP proxy to use:proxy:_urls'
@@ -1947,8 +2014,9 @@ _git-config () {
     pack.indexVersion:'default pack index version:index version:->string'
     pack.packSizeLimit:'maximum size of packs:maximum size of packs:->bytes'
     pull.octopus:'default merge strategy to use when pulling multiple branches::__git_merge_strategies'
+    pull.rebase:'rebase branches on top of the fetched branch, instead of merging::->bool:false'
     pull.twohead:'default merge strategy to use when pulling a single branch::__git_merge_strategies'
-    push.default:'action git push should take if no refspec is given::->push.default'
+    push.default:'action git push should take if no refspec is given::->push.default:matching'
     rebase.stat:'show a diffstat of what changed upstream since last rebase::->bool:false'
     rebase.autosquash:'autosquash by default::->bool:false'
     receive.autogc:'run git gc --auto after receiving data::->bool:true'
@@ -1981,6 +2049,7 @@ _git-config () {
     sendemail.bcc:'value of Bcc\: header::_email_addresses'
     sendemail.cc:'value of Cc\: header::_email_addresses'
     sendemail.cccmd:'command to generate Cc\: header with:Cc\: command:_path_commands'
+    sendemail.toccmd:'command to generate To\: header with:To\: command:_path_commands'
     sendemail.chainreplyto:'send each email as a reply to the previous one::->bool:false'
     sendemail.confirm:'type of confirmation required before sending::->sendemail.confirm:auto'
     sendemail.envelopesender:'envelope sender to send emails as::_email_addresses'
@@ -2002,6 +2071,7 @@ _git-config () {
     'sendemail.*.bcc:value of Bcc\: header::_email_addresses'
     'sendemail.*.cc:value of Cc\: header::_email_addresses'
     'sendemail.*.cccmd:command to generate Cc\: header with:Cc\: command:_path_commands'
+    'sendemail.*.tocmd:command to generate To\: header with:To\: command:_path_commands'
     'sendemail.*.chainreplyto:send each email as a reply to the previous one::->bool:false'
     'sendemail.*.confirm:type of confirmation required before sending::->sendemail.confirm:auto'
     'sendemail.*.envelopesender:envelope sender to send emails as::_email_addresses'
@@ -2357,6 +2427,13 @@ _git-config () {
                 always:"always $parts[2]" \
                 {auto,true,yes,on}:$parts[2] && ret=0
               ;;
+            (commit.cleanup)
+              __git_config_values -- "$current" "$parts[5]" \
+                strip:'remove both whitespace and commentary lines' \
+                whitespace:'remove leading and trailing whitespace lines' \
+                verbatim:'no not change the commit message at all' \
+                default:'act as '\''strip'\'' if the message is to be edited and as '\''whitespace'\'' otherwise' && ret=0
+              ;;
             (compression)
               __git_compression_levels && ret=0
               ;;
@@ -2405,10 +2482,23 @@ _git-config () {
                 __git_guard_number 'number of days'
               fi
               ;;
+            (diff.algorithm)
+              __git_config_values -- "$current" "$parts[5]" \
+                default:'basic greedy diff algorithm' \
+                myers:'basic greedy diff algorithm' \
+                minimal:'spend extra time to make sure the smallest possible diff is produced' \
+                patience:'generate diffs with patience algorithm' \
+                histogram:'generate diffs with histogram algorithm' && ret=0
+              ;;
             (diff.renames)
               __git_config_booleans "$current" "$parts[5]" "$parts[2]" \
                 {copies,copy}:'try to detect both renames and copies' && ret=0
               ;;
+            (diff.submodule)
+              __git_config_values -- "$current" "$parts[5]" \
+                short:'show pairs of commit name' \
+                log:'list commits like git submodule does' && ret=0
+              ;;
             (encoding)
               __git_encodings && ret=0
               ;;
@@ -2438,12 +2528,25 @@ _git-config () {
                 SQLite:'use the SQLite database driver' \
                 Pg:'use the Pg database driver' && ret=0
               ;;
+            (grep.patternType)
+              __git_config_values -- "$current" "$parts[5]" \
+                basic:'use --basic-regexp' \
+                default:'use default' \
+                extended:'use --extended-regexp' \
+                fixed:'use --fixed-strings' \
+                perl:'use --perl-regexp' && ret=0
+              ;;
             (help.format)
               __git_config_values -- "$current" "$parts[5]" \
                 man:'use man' \
                 info:'use info' \
                 {web,html}:'use HTML' && ret=0
               ;;
+            (help.htmlpath)
+              _alternative \
+                'path::_files -/' \
+                'url::_urls' && ret=0
+              ;;
             (imap.authMethod)
               __git_config_values -- "$current" "$parts[5]" \
                 CRAM-MD5:'use CRAM-MD5' && ret=0
@@ -2464,9 +2567,9 @@ _git-config () {
               ;;
             (merge.verbosity)
               __git_config_values -t verbosity-levels -l 'verbosity level' -- "$current" "$parts[5]" \
-                0:'only final error message if conflicts were detected'
-                1:'conflicts'
-                2:'conflicts and file changes'
+                0:'only final error message if conflicts were detected' \
+                1:'conflicts' \
+                2:'conflicts and file changes' \
                 5:'debugging information' && ret=0
               ;;
             (notes.rewriteMode)
@@ -2482,7 +2585,8 @@ _git-config () {
               __git_config_values -- "$current" "$parts[5]" \
                 nothing:'do not push anything' \
                 matching:'push all matching branches' \
-                tracking:'push current branch to its upstream branch' \
+                upstream:'push current branch to its upstream branch' \
+                simple:'like upstream, but only if local and remote names are the same' \
                 current:'push current branch to branch of same name' && ret=0
               ;;
             (receive.denyCurrentBranch)
@@ -2885,11 +2989,13 @@ _git-blame () {
     '-S[use revs from revs-file]:revs-file:_files' \
     '--reverse[walk histor forward instead of backward]' \
     '(-p --porcelain)'{-p,--porcelain}'[show results designed for machine processing]' \
+    '--line-porcelain[show results designed for machine processing but show commit information for every line]' \
     '--incremental[show results incrementally for machine processing]' \
     '--contents[annotate against the given file if no rev is specified]: :_files' \
     '(-h --help)'{-h,--help}'[show help message]' \
     '-c[use same output format as git annotate]' \
     '--score-debug[output debugging information relating to -C and -M line movement]' \
+    '(-e --show-email)'{-e,--show-email}'[show the author email instead of the author name]' \
     '(-f --show-name)'{-f,--show-name}'[show the filename of the original commit]' \
     '(-n --show-number)'{-n,--show-number}'[show the line number in the original commit]' \
     '-s[suppress author name and timestamp]' \
@@ -2937,6 +3043,7 @@ _git-count-objects () {
 _git-difftool () {
   # TODO: Is this fine, or do we need to modify the context or similar?
   _git-diff \
+    '--dir-diff[diff a whole tree by prepare a temporary copy]' \
     '(-y --no-prompt --prompt)'{-y,--no-prompt}'[do not prompt before invocation of diff tool]' \
     '(-y --no-prompt)--prompt[prompt before invocation of diff tool]' \
     '(-t --tool -x --extcmd)'{-t,--tool=-}'[merge resolution program to use]: :__git_difftools' \
@@ -2949,6 +3056,8 @@ _git-fsck () {
   # TODO: -v is undocumented.
   _arguments -w -S -s \
     '--unreachable[show objects that are unreferenced in the object database]' \
+    '(--dangling --no-dangling)--dangling[print dangling objects (default)]' \
+    '(--dangling --no-dangling)--no-dangling[do not print dangling objects]' \
     '--root[show root nodes]' \
     '--tags[show tags]' \
     '--cache[consider objects recorded in the index as head nodes for reachability traces]' \
@@ -3032,7 +3141,8 @@ _git-rerere () {
         'clear[reset metadata used by rerere]' \
         'forget[resets metadata used by rerere for specific conflict]: :__git_cached_files' \
         'diff[output diffs for the current state of the resolution]' \
-        'status[like diff, but only output filesames]' \
+        'status[print paths with conflicts whose merge resolution rerere will record]' \
+        'remaining[print paths with conflicts that have not been autoresolved by rerere]' \
         'gc[prune old records of conflicted merges]' && ret=0
       ;;
   esac
@@ -3292,6 +3402,7 @@ _git-send-email () {
     '--smtp-server-port=[specify port to connect to SMTP server on]:smtp port:_ports' \
     '--smtp-user=[specify user to use for SMTP-AUTH]:smtp user:_users' \
     '--cc-cmd=[specify command to generate Cc\: header with]:Cc\: command:_path_commands' \
+    '--to-cmd=[specify command to generate To\: header with]:To\: command:_path_commands' \
     '(                 --no-chain-reply-to)--chain-reply-to[send each email as a reply to previous one]' \
     '(--chain-reply-to                    )--no-chain-reply-to[send all emails after first as replies to first one]' \
     '--identity=[specify configuration identity]: :__git_sendemail_identities' \
@@ -3585,8 +3696,6 @@ _git-apply () {
     '--unidiff-zero[disable unified-diff-context check]' \
     '--apply[apply patches that would otherwise not be applied]' \
     '--no-add[ignore additions made by the patch]' \
-    '*--exclude=[skip files matching specified pattern]:pattern' \
-    '*--include=[include files matching specified pattern]:pattern' \
     '--inaccurate-eof[work around missing-new-line-at-EOF bugs]' \
     '(-v --verbose)'{-v,--verbose}'[display progress on stderr]' \
     '--recount[do not trust line counts in hunk headers]' \
@@ -3776,9 +3885,10 @@ _git-prune-packed () {
 
 (( $+functions[_git-read-tree] )) ||
 _git-read-tree () {
-  local trivial_opt= aggressive_opt=
+  local trivial_opt= aggressive_opt= dryrun_opt=
 
   if (( words[(I)-m] )); then
+    dryrun_opt='--dry-run[report if a merge would fail without touching the index or the working tree]'
     trivial_opt='--trivial[restrict three-way merge to only happen if no file-level merging is required]'
     aggressive_opt='--aggressive[try harder to resolve merge conflicts]'
   fi
@@ -3802,6 +3912,7 @@ _git-read-tree () {
     '(-m         --prefix)--reset[perform a merge, not just a read, ignoring unmerged entries]' \
     '(-m --reset          2 3)--prefix=-[read the contents of specified tree-ish under specified directory]:prefix:_directories -r ""' \
     $ui_opts \
+    $dryrun_opt \
     '-v[display progress on standard error]' \
     $trivial_opt \
     $aggressive_opt \
@@ -3816,7 +3927,9 @@ _git-read-tree () {
 (( $+functions[_git-symbolic-ref] )) ||
 _git-symbolic-ref () {
   _arguments -w -S -s \
+    '(-d --delete)'{-d,--delete}'[delete symbolic ref]' \
     '(-q --quiet)'{-q,--quiet}'[do not issue error if specified name is not a symbolic ref]' \
+    '--short[shorten the ref name (eg. refs/heads/master -> master)]' \
     '-m[update reflog for specified name with specied reason]:reason for update' \
     ':symbolic reference:__git_heads' \
     ':: :__git_references'
@@ -4042,6 +4155,8 @@ _git-ls-remote () {
     '(-h --heads)'{-h,--heads}'[show only refs under refs/heads]' \
     '(-t --tags)'{-t,--tags}'[show only refs under refs/tags]' \
     '(-u --upload-pack)'{-u,--upload-pack=-}'[specify path to git-upload-pack on remote side]:remote path' \
+    '--exit-code[exit with status 2 when no matching refs are found in the remote repository]' \
+    '--get-url[expand the URL of the given repository taking into account any "url.<base>.insteadOf" config setting]' \
     ': :__git_any_repositories' \
     '*: :__git_references'
 }
@@ -4078,6 +4193,7 @@ _git-merge-base () {
   _arguments -w -S -s \
     '(-a --all)'{-a,--all}'[display all common ancestors]' \
     '--octopus[compute best common ancestors of all supplied commits]' \
+    '--is-ancestor[tell if A is ancestor of B (by exit status)]' \
     '(-)--independent[display minimal subset of supplied commits with same ancestors]' \
     ': :__git_commits' \
     '*: :__git_commits'
@@ -4194,6 +4310,7 @@ _git-daemon () {
   # TODO: --interpolated-path should complete %H, %CH, %IP, %P, and %D.
   _arguments -S \
     '--strict-paths[match paths exactly]' \
+    '--access-hook=-[allow an external tool to accept or decline service]:path:_directories' \
     '--base-path=-[remap all the path requests as relative to the given path]:path:_directories' \
     '--base-path-relaxed[allow lookup of base path witout prefix]' \
     '--interpolated-path=-[dynamically construct alternate paths]:path:_directories' \
@@ -4382,7 +4499,9 @@ _git-check-attr () {
   fi
 
   _arguments -C \
+    {-a,--all}'[list all attributes that are associated with the specified paths]' \
     '--stdin[read file names from stdin instead of from command line]' \
+    '--cached[consider .gitattributes in the index only, ignoring the working tree.]' \
     $z_opt \
     '(-)--[interpret preceding arguments as attributes and following arguments as path names]' \
     '*:: :->attribute-or-file' && ret=0
@@ -5300,15 +5419,6 @@ __git_remote_references () {
   __git_references
 }
 
-(( $+functions[__git_note_references] )) ||
-__git_local_references () {
-  local references expl
-
-  references=(${${(M)${${(f)"$(_call_program references git ls-remote ./. 2>/dev/null)"}#*$'\t'}:#refs/notes/*}#refs/notes/})
-  __git_command_successful $pipestatus || return 1
-
-  _wanted references expl reference compadd - $references
-}
 (( $+functions[__git_notes_refs] )) ||
 __git_notes_refs () {
   local expl
@@ -5604,7 +5714,14 @@ __git_setup_diff_options () {
     $diff_types{-U,--unified=}'[generate diff with given lines of context]: :__git_guard_number lines'
     $diff_types'--raw[generate default raw diff output]'
     $diff_types'--patch-with-raw[generate patch but also keep the default raw diff output]'
-    '--patience[generate diffs with patience algorithm]'
+    '(--minimal --patience --histogram --diff-algorithm)--minimal[spend extra time to make sure the smallest possible diff is producedm]'
+    '(--minimal --patience --histogram --diff-algorithm)--patience[generate diffs with patience algorithm]'
+    '(--minimal --patience --histogram --diff-algorithm)--histogram[generate diffs with histogram algorithm]'
+    '(--minimal --patience --histogram --diff-algorithm)--diff-algorithm=[choose a diff algorithm]:diff algorithm:((default\:"basic greedy diff algorithm"
+                                                                                                                    myers\:"basic greedy diff algorithm"
+                                                                                                                    minimal\:"spend extra time to make sure the smallest possible diff is produced"
+                                                                                                                    patience\:"generate diffs with patience algorithm"
+                                                                                                                    histogram\:"generate diffs with histogram algorithm"))'
     $diff_types'--stat=-[generate diffstat instead of patch]:: :__git_guard_diff-stat-width'
     $diff_types'--numstat[generate more machine-friendly diffstat]'
     $diff_types'--shortstat[generate summary diffstat]'
@@ -5616,7 +5733,7 @@ __git_setup_diff_options () {
     $diff_types'--name-only[show only names of changed files]'
     $diff_types'--name-status[show only names and status of changed files]'
     '--submodule=-[select output format for submodule differences]::format:((short\:"show pairs of commit names"
-                                                                            log\:"list commits like git submodule does (default)"))'
+                                                                            log\:"list commits like git submodule does"))'
     '(        --no-color --color-words)--color=-[show colored diff]:: :__git_color_whens'
     '(--color            --color-words)--no-color[turn off colored diff]'
     '--word-diff=-[show word diff]::mode:((color\:"highlight changed words using color"
@@ -5654,6 +5771,8 @@ __git_setup_diff_options () {
     '(--exit-code)--quiet[disable all output]'
     '(           --no-ext-diff)--ext-diff[allow external diff helper to be executed]'
     '(--ext-diff              )--no-ext-diff[disallow external diff helper to be executed]'
+    '(          --no-follow)--follow[follow renames]'
+    '(--follow             )--no-follow[do not follow renames]'
     '--ignore-submodules[ignore changes to submodules]:: :__git_ignore_submodules_whens'
     '(--no-prefix)--src-prefix=[use given prefix for source]:prefix'
     '(--no-prefix)--dst-prefix=[use given prefix for destination]:prefix'
@@ -5700,10 +5819,9 @@ __git_setup_revision_options () {
     '--abbrev-commit[show only partial prefixes of commit object names]'
     '--oneline[shorthand for --pretty=oneline --abbrev-commit]'
     '--encoding=-[output log messages in given encoding]:: :__git_encodings'
-    '(--no-notes --show-notes --standard-notes --no-standard-notes)--no-notes[do not show notes that annotate commit]'
-    '(--no-notes --show-notes --standard-notes --no-standard-notes)--show-notes[do not show notes that annotate commit]:: :__git_note_references'
-    '(--no-notes --show-notes --standard-notes --no-standard-notes)--no-standard-notes[enable populating notes ref list from core.notesRef and notes.displayRef]'
-    '(--no-notes --show-notes --standard-notes --no-standard-notes)--no-standard-notes[disable populating notes ref list from core.notesRef and notes.displayRef]'
+    '(--no-notes --notes)--no-notes[do not show notes that annotate commit]'
+    '(--no-notes        )*--notes=[show notes that annotate commit, with optional ref argument show this notes ref instead of the default notes ref(s)]:: :__git_notes_refs'
+    '--show-signature[validate GPG signature of commit]'
     '(                --date)--relative-date[show dates relative to current time]'
     '(--relative-date       )--date=-[format of date output]: :__git_date_formats'
     '--parents[display parents of commit]'
@@ -5735,8 +5853,8 @@ __git_setup_revision_options () {
     '--remotes=[-show all commits from refs/remotes]::pattern'
     '--glob=[show all commits from refs matching glob]:pattern'
     '--stdin[read commit objects from standard input]'
-    '--cherry-pick[omit any same-change commits]'
     '(-g --walk-reflogs --reverse)'{-g,--walk-reflogs}'[walk reflog entries from most recent to oldest]'
+    '--grep-reflog=[limit commits to ones whose reflog message matches the given pattern (with -g, --walk-reflogs)]:pattern'
     '--merge[after a failed merge, show refs that touch files having a conflict]'
     '--boundary[output uninteresting commits at boundary]'
     '--simplify-by-decoration[show only commits that are referenced by a ref]'
@@ -5752,21 +5870,26 @@ __git_setup_revision_options () {
     '(--objects               )--objects-edge[display object ids of objects referenced by listed and excluded commits]'
     '(          --do-walk)--no-walk[only display given revs, do not traverse their ancestors]'
     '(--no-walk          )--do-walk[only display given revs, traversing their ancestors]'
+    '(              --cherry-pick)--cherry-mark[like --cherry-pick but mark equivalent commits instead of omitting them]'
+    '(--cherry-pick              )--cherry-pick[omit any commit that introduces the same change as another commit on "the other side" of a symmetric range]'
+    '(            --right-only)--left-only[list only commits on the left side of a symmetric range]'
+    '(--left-only             )--right-only[list only commits on the right side of a symmetric range]'
+    '(--left-only --right-only --cherry-pick --cherry-mark)--cherry[synonym for --right-only --cherry-mark --no-merges]'
+    '(-c --cc            )--full-diff[show full commit diffs when using log -p, not only those affecting the given path]'
+    '--log-size[print log message size in bytes before the message]'
+    '--use-mailmap[use mailmap file to map author and committer names and email]'
 
     # TODO: --reflog is undocumented.
     '--reflog[show all commits from reflogs]'
     # TODO: --default is undocumented.
     '--default[use argument as default revision]:default revision:__git_revisions'
-    # TODO: --full-diff is undocumented.
-    '(-c --cc            )--full-diff[undocumented]'
     # TODO: --abrev is undocumented.
     '--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length'
     # TODO: --no-abbrev is undocumented.
     '--no-abbrev[undocumented]'
     # TODO: --early-output is undocumented.
     '--early-output=-[undocumented]::undocumented'
-    # TODO: --log-size is undocumented.
-    '--log-size[undocumented]')
+    )
 
   if (( words[(I)--objects(|-edge)] )); then
     revision_options+=('--unpacked[print object IDs not in packs]')
@@ -5778,6 +5901,8 @@ __git_setup_merge_options () {
   merge_options=(
     '(         --no-commit)--commit[perform the merge and commit the result]'
     '(--commit            )--no-commit[perform the merge but do not commit the result]'
+    '(         --no-edit)--edit[open an editor to change the commit message]'
+    '(--edit            )--no-edit[do not open an editor to change the commit message]'
     '(     --no-ff)--ff[do not generate a merge commit if the merge resolved as a fast-forward]'
     '(--ff        )--no-ff[generate a merge commit even if the merge resolved as a fast-forward]'
     '(      --no-log)--log[fill in one-line descriptions of the commits being merged in the log message]'
@@ -5799,6 +5924,7 @@ __git_setup_fetch_options () {
     '(: *)--all[fetch all remotes]'
     '(-a --append)'{-a,--append}'[append ref names and object names of fetched refs to "$GIT_DIR/FETCH_HEAD"]'
     '--depth=[deepen the history of a shallow repository by the given number of commits]: :__git_guard_number depth'
+    '--unshallow[convert a shallow clone to a complete one]'
     '--dry-run[show what would be done, without making any changes]'
     '(-f --force)'{-f,--force}'[allow refs that are not ancestors to be updated]'
     '(-k --keep)'{-k,--keep}'[keep downloaded pack]'
@@ -5807,6 +5933,10 @@ __git_setup_fetch_options () {
     '(--no-tags -t --tags)'{-t,--tags}'[fetch remote tags]'
     '(-u --update-head-ok)'{-u,--update-head-ok}'[allow updates of current branch head]'
     '--upload-pack=[specify path to git-upload-pack on remote side]:remote path'
+    '(--no-recurse-submodules --recurse-submodules)--recurse-submodules=[specify when to fetch commits of submodules]:recursive fetching mode:((no\:"disable recursion"
+                                                                                                                                                yes\:"always recurse"
+                                                                                                                                                on-demand\:"only when submodule reference in superproject is updated"))'
+    '(--no-recurse-submodules --recurse-submodules)--no-recurse-submodules[disable recursive fetching of submodules]'
     '(-q --quiet -v --verbose --progress)'{-q,--quiet}'[suppress all output]'
     '(-q --quiet -v --verbose)'{-v,--verbose}'[output additional information]'
     '(-q --quiet)--progress[output progress information]')
@@ -5820,7 +5950,10 @@ __git_setup_apply_options () {
     '-C-[ensure at least N lines of context match before and after each change]: :_guard  "[[\:digit\:]]#" "number of lines of context"'
     '--reject[apply hunks that apply and leave rejected hunks in .rej files]'
     '(--ignore-space-change --ignore-whitespace)'{--ignore-space-change,--ignore-whitespace}'[ignore changes in whitespace in context lines]'
-    '--directory=[root to prepend to all filenames]:root:_directories')
+    '--directory=[root to prepend to all filenames]:root:_directories'
+    '*--exclude=[skip files matching specified pattern]:pattern'
+    '*--include=[include files matching specified pattern]:pattern'
+    )
 }
 
 # Git Config Helpers
@@ -6077,6 +6210,7 @@ __git_sendemail_suppresscc_values () {
     bodycc:'avoid including anyone mentiond in Cc lines in patch body except for self' \
     sob:'avoid including anyone mentiond in Signed-off-by lines except for self' \
     cccmd:'avoid running --cc-cmd' \
+    tocmd:'avoid running --to-cmd' \
     body:'equivalent to sob + bodycc' \
     all:'avoid all auto Cc values'
 }
-- 
1.8.2.2


^ permalink raw reply	[relevance 3%]

* Re: sleep $floatval
  @ 2013-09-01  7:45  3% ` Bart Schaefer
  2013-09-01  8:16  3%   ` Phil Pennock
  0 siblings, 1 reply; 200+ results
From: Bart Schaefer @ 2013-09-01  7:45 UTC (permalink / raw)
  To: zsh-workers

On Aug 31,  4:47pm, Phil Pennock wrote:
>
> So the float shows as 3.000000000e-01 which becomes a string, before
> being passed to the built-in sleep, which then does not parse that
> format as 0.3, nor show an error, but instead sleeps for 3 seconds
> without an error.

If $SleepDuration can be < 1, don't you want

	usleep $((SleepDuration * 1.0e+6))

instead?
 
> What do folks think about sleep being a builtin, which can take
> arbitrary formats and avoid forking an extra process, just to delay?

I don't have any particular objection.

Incidentally, the manual actually recommends

	zselect -t $((SleepDurationInSeconds * 100))

> Looking for a rough idea of whether people think the current behaviour
> is problematic enough to make it worth adding another builtin.  And
> should it be sleep or zsleep, if so?

The current behavior isn't problematic enough to have caused POSIX, bash,
et al., to redefine sleep as a builtin, and it's not a problem I've ever
encountered myself, but ...

It could be added as one or more subcommands of zsystem (the only one
currently is "flock"), e.g. "zsystem sleep $n", which allows you to do
"if zsystem supports sleep; then ... fi".  Otherwise I'd say zsleep is
the best name for it, particularly if it magically converts floats into
fractional second sleeps.

If zsleep, then it could be a new module or be added to zsh/datetime.


^ permalink raw reply	[relevance 3%]

* Re: sleep $floatval
  2013-09-01  7:45  3% ` Bart Schaefer
@ 2013-09-01  8:16  3%   ` Phil Pennock
  0 siblings, 0 replies; 200+ results
From: Phil Pennock @ 2013-09-01  8:16 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

On 2013-09-01 at 00:45 -0700, Bart Schaefer wrote:
> If $SleepDuration can be < 1, don't you want
> 
> 	usleep $((SleepDuration * 1.0e+6))

I don't have a usleep(1) command.  I do have a BSD sleep(1) command
which takes fractional seconds, both on FreeBSD and MacOS, and the
Ubuntu systems I see have a sleep(1) which does the same, and appears to
be from GNU coreutils.

It appears that the GNU coreutils variant correctly parses
"3.000000000e-01" and sleeps for 0.3 seconds, instead of 3 seconds.

> The current behavior isn't problematic enough to have caused POSIX, bash,
> et al., to redefine sleep as a builtin, and it's not a problem I've ever
> encountered myself, but ...

I think POSIX still doesn't specify any support for non-integral
sleep(1) durations, right?

> If zsleep, then it could be a new module or be added to zsh/datetime.

Am reconsidering in light of this being purely a BSD sleep(1) bug.  Hrm.

Thanks,
-Phil


^ permalink raw reply	[relevance 3%]

* Builtin test and parsing of conditionals
@ 2013-09-04 16:15  3% Bart Schaefer
  2013-09-04 16:31  0% ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Bart Schaefer @ 2013-09-04 16:15 UTC (permalink / raw)
  To: zsh-workers

According to some discussion on the austin-group (POSIX) mailing list,
the following:

	test ! -a !
	test ! -o !
	test ! = !

should all be parsed as comparing the string "!" to the string "!", but
zsh gets this right only in the last case.

This is especially annoying because

	test ! -f !

should be interpreted as the negation of the unary file-exists operator.

This is probably complicated by the different meanings of -a and -o in
[[ ... ]] as opposed to "test" because the same parser is used.

Furthermore:

	test ! = -o a

should be parsed as the negation of the comparison between the strings "="
and "a", implying that zsh also gets this wrong:

	test ! = = =

which should return false (negation of (equal is the same string as equal)),
rather than give a parse error as zsh does.  (Zsh does get

	test = = =

right.)

Apparently the only way to do this correctly is to examine both argv[1] and
the number of arguments, and skip to argv[2] for recursive descent parsing
when argv[1] is "!" and there are four arguments.  (As already mentioned in
the zsh manual, what to do with more than four arguments in the absence of
explicit parens is unclear [unspecified?].)


^ permalink raw reply	[relevance 3%]

* Re: Builtin test and parsing of conditionals
  2013-09-04 16:15  3% Builtin test and parsing of conditionals Bart Schaefer
@ 2013-09-04 16:31  0% ` Peter Stephenson
  2013-09-04 17:39  3%   ` Bart Schaefer
  0 siblings, 1 reply; 200+ results
From: Peter Stephenson @ 2013-09-04 16:31 UTC (permalink / raw)
  To: zsh-workers

On Wed, 04 Sep 2013 09:15:03 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> According to some discussion on the austin-group (POSIX) mailing list,
> the following:
> 
> 	test ! -a !
> 	test ! -o !
> 	test ! = !
> 
> should all be parsed as comparing the string "!" to the string "!", but
> zsh gets this right only in the last case.

I don't understand that.  -a means "and" and -o means "or", unless
they're being interpreted as strings, but I don't see how that could be
if ! is supposed to be interpreted as a string.   So where does the
implicit comparison come from?  If -a were taken as high precedence you
might read it as

test -n ! -a n !
test -n ! -a n !

which is how

test foo -a bar
test foo -o bar

are interpreted, which you can see by

test foo -a '' # false
test foo -o '' # true

... same if you omit the ''.

(Outside our control, but I imagine people aren't daft enough to rely on
this sort of behaviour in new scripts...?)

pws


^ permalink raw reply	[relevance 0%]

* Re: Builtin test and parsing of conditionals
  2013-09-04 16:31  0% ` Peter Stephenson
@ 2013-09-04 17:39  3%   ` Bart Schaefer
  2013-09-04 19:09  0%     ` Peter Stephenson
  0 siblings, 1 reply; 200+ results
From: Bart Schaefer @ 2013-09-04 17:39 UTC (permalink / raw)
  To: zsh-workers

On Sep 4,  5:31pm, Peter Stephenson wrote:
} Subject: Re: Builtin test and parsing of conditionals
}
} On Wed, 04 Sep 2013 09:15:03 -0700
} Bart Schaefer <schaefer@brasslantern.com> wrote:
} > According to some discussion on the austin-group (POSIX) mailing list,
} > the following:
} > 
} > 	test ! -a !
} > 	test ! -o !
} > 	test ! = !
} > 
} > should all be parsed as comparing the string "!" to the string "!", but
} > zsh gets this right only in the last case.
} 
} I don't understand that.  -a means "and" and -o means "or", unless
} they're being interpreted as strings, but I don't see how that could be
} if ! is supposed to be interpreted as a string.

Sorry, perhaps I should have been clearer:  "! -a !" means to compare the
truth value "!" to the truth value of "!".  But "truth value" in "test"
is the same as "non-empty string" (true) and "empty string" (false) [not
0 or 1 as numeric values], so the -a operator is still comparing two
strings.

The point being that "!" should be parsed as a string, not as a negation
operator, in the three-argument case.

} So where does the
} implicit comparison come from?  If -a were taken as high precedence you
} might read it as
} 
} test -n ! -a n !
} test -n ! -a n !

Presuming you mean -a -n there, this is exactly how the austin-group
thread claims it should be interpreted, and is reportedly how ksh and
bash and GNU /usr/bin/test all interpret it.

} (Outside our control, but I imagine people aren't daft enough to rely on
} this sort of behaviour in new scripts...?)

I would hope so, but ...


^ permalink raw reply	[relevance 3%]

* Re: Builtin test and parsing of conditionals
  2013-09-04 17:39  3%   ` Bart Schaefer
@ 2013-09-04 19:09  0%     ` Peter Stephenson
    0 siblings, 1 reply; 200+ results
From: Peter Stephenson @ 2013-09-04 19:09 UTC (permalink / raw)
  To: zsh-workers

On Wed, 04 Sep 2013 10:39:40 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Sep 4,  5:31pm, Peter Stephenson wrote:
> } On Wed, 04 Sep 2013 09:15:03 -0700
> } Bart Schaefer <schaefer@brasslantern.com> wrote:
> } > According to some discussion on the austin-group (POSIX) mailing list,
> } > the following:
> } > 
> } > 	test ! -a !
> } > 	test ! -o !
> } > 	test ! = !
> } > 
> } > should all be parsed as comparing the string "!" to the string "!", but
> } > zsh gets this right only in the last case.
> 
> Sorry, perhaps I should have been clearer:  "! -a !" means to compare the
> truth value "!" to the truth value of "!".  But "truth value" in "test"
> is the same as "non-empty string" (true) and "empty string" (false) [not
> 0 or 1 as numeric values], so the -a operator is still comparing two
> strings.

OK, this looks straightforward enough.

diff --git a/Src/parse.c b/Src/parse.c
index 0c2a458..f0d0855 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -2088,9 +2088,17 @@ par_cond_2(void)
 	}
     }
     if (tok == BANG) {
-	condlex();
-	ecadd(WCB_COND(COND_NOT, 0));
-	return par_cond_2();
+	/*
+	 * In "test" compatibility mode, "! -a ..." and "! -o ..."
+	 * are treated as "[string] [and] ..." and "[string] [or] ...".
+	 */
+	if (!(condlex == testlex && *testargs && 
+	      (!strcmp(*testargs, "-a") || !strcmp(*testargs, "-o"))))
+	{
+	    condlex();
+	    ecadd(WCB_COND(COND_NOT, 0));
+	    return par_cond_2();
+	}
     }
     if (tok == INPAR) {
 	int r;
diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst
index 494261e..8562519 100644
--- a/Test/C02cond.ztst
+++ b/Test/C02cond.ztst
@@ -324,6 +324,27 @@ F:Failures in these cases do not indicate a problem in the shell.
 >	fi
 >}
 
+  weirdies=(
+    '! -a !'
+    '! -o !'
+    '! -a'
+    '! -o'
+    '! -a ! -a !'
+    '! = !'
+    '! !')
+  for w in $weirdies; do
+     eval test $w
+     print $?
+  done
+0:test compatability weirdness: treat ! as a string sometimes
+>0
+>0
+>1
+>0
+>0
+>0
+>1
+
 %clean
   # This works around a bug in rm -f in some versions of Cygwin
   chmod 644 unmodish

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


^ permalink raw reply	[relevance 0%]

* Re: Builtin test and parsing of conditionals
  @ 2013-09-06 19:20  5%         ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2013-09-06 19:20 UTC (permalink / raw)
  To: zsh-workers

On Thu, 05 Sep 2013 07:25:45 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> That's good, but it still doesn't fix the other case mentioned in my
> original email:
> 
> torch% /usr/bin/test ! = -a o ; print $?
> 1
> torch% test ! = -a o ; print $? 
> test: too many arguments
> 1
> 
> Do you want to try to handle that in parse.c, or am I correct that peeling
> off the "!" in builtin.c:bin_test [the way parens are peeled off] is the
> better way to go?

That seems sensible.

diff --git a/Src/builtin.c b/Src/builtin.c
index f8be4ac..c3f0169 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -5995,7 +5995,7 @@ bin_test(char *name, char **argv, UNUSED(Options ops), int func)
     char **s;
     Eprog prog;
     struct estate state;
-    int nargs;
+    int nargs, sense = 0, ret;
 
     /* if "test" was invoked as "[", it needs a matching "]" *
      * which is subsequently ignored                         */
@@ -6014,7 +6014,7 @@ bin_test(char *name, char **argv, UNUSED(Options ops), int func)
     /*
      * Implement some XSI extensions to POSIX here.
      * See
-     * http://www.opengroup.org/onlinepubs/009695399/utilities/test.html.
+     * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
      */
     nargs = arrlen(argv);
     if (nargs == 3 || nargs == 4)
@@ -6023,6 +6023,10 @@ bin_test(char *name, char **argv, UNUSED(Options ops), int func)
 	    argv[nargs-1] = NULL;
 	    argv++;
 	}
+	if (nargs == 4 && !strcmp("!", argv[0])) {
+	    sense = 1;
+	    argv++;
+	}
     }
 
     lexsave();
@@ -6057,8 +6061,11 @@ bin_test(char *name, char **argv, UNUSED(Options ops), int func)
     state.pc = prog->prog;
     state.strs = prog->strs;
 
+    ret = evalcond(&state, name);
+    if (ret < 2 && sense)
+	ret = ! ret;
 
-    return evalcond(&state, name);
+    return ret;
 }
 
 /* display a time, provided in units of 1/60s, as minutes and seconds */
diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst
index 8562519..94fca8b 100644
--- a/Test/C02cond.ztst
+++ b/Test/C02cond.ztst
@@ -331,7 +331,9 @@ F:Failures in these cases do not indicate a problem in the shell.
     '! -o'
     '! -a ! -a !'
     '! = !'
-    '! !')
+    '! !'
+    '= -a o'
+    '! = -a o')
   for w in $weirdies; do
      eval test $w
      print $?
@@ -344,6 +346,8 @@ F:Failures in these cases do not indicate a problem in the shell.
 >0
 >0
 >1
+>0
+>1
 
 %clean
   # This works around a bug in rm -f in some versions of Cygwin


^ permalink raw reply	[relevance 5%]

* [PATCH v2 06/14] _git: completion updates to match latest git v1.8.3 part 2
    2013-09-22 10:48  3% ` [PATCH v2 05/14] _git: completion updates to match latest git v1.8.3 Øystein Walle
@ 2013-09-22 10:48  1% ` Øystein Walle
  1 sibling, 0 replies; 200+ results
From: Øystein Walle @ 2013-09-22 10:48 UTC (permalink / raw)
  To: zsh-workers; +Cc: Øystein Walle

---
 Completion/Unix/Command/_git | 118 +++++++++++++++++++++++++++++++++----------
 1 file changed, 91 insertions(+), 27 deletions(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 867bd67..205ae67 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -64,8 +64,9 @@ _git-add () {
     '(-i --interactive : -)'{-i,--interactive}'[add contents interactively to index]' \
     '(-p --patch)'{-p,--patch}'[like -i but go directly into patch mode for specified files]' \
     '(-e --edit)'{-e,--edit}'[open diff against index in editor]' \
-    '(-u --update -A --all)'{-u,--update}'[update only files git already knows about]' \
-    '(-A --all -u --update)'{-A,--all}'[act as both add . and add -u]' \
+    '(-A --all --no-ignore-removal -u --update --no-all --ignore-removal)'{-A,--all,--no-ignore-removal}'[add, modify, and remove index entries to match the working tree]' \
+    '(-A --all --no-ignore-removal -u --update --no-all --ignore-removal)'{--no-all,--ignore-removal}'[like "--all" but ignore removals]' \
+    '(-A --all --no-ignore-removal -u --update --no-all --ignore-removal)'{-u,--update}'[update the index just where it already has an entry matching <pathspec>]' \
     '(-N --intent-to-add)'{-N,--intent-to-add}'[record only that path will be added later]' \
     '--refresh[do not add files, but refresh their stat() info in index]' \
     '--ignore-errors[continue adding if an error occurs]' \
@@ -104,6 +105,7 @@ _git-am () {
   _arguments -S \
     '(-s --signoff)'{-s,--signoff}'[add Signed-off-by: line to the commit message]' \
     '(-k --keep)'{-k,--keep}'[pass -k to git mailinfo]' \
+    '--keep-non-patch[pass -b to git mailinfo]' \
     '(          --no-keep-cr)--keep-cr[pass --keep-cr to git mailsplit]' \
     '(--keep-cr             )--no-keep-cr[do not pass --keep-cr to git mailsplit]' \
     '(-c --scissors --no-scissors)'{-c,--scissors}'[strip everything before a scissors line]' \
@@ -315,10 +317,12 @@ _git-branch () {
   _arguments -w -S -s \
     "($c $m $d $e --no-color :)--color=-[turn on branch coloring]:: :__git_color_whens" \
     "($c $m $d $e : --color)--no-color[turn off branch coloring]" \
+    "($c $m $d $e --no-column)"'--column=[display tag listing in columns]:column.branch option:((always\:"always show in columns" never\:"never show in columns" auto\:"show in columns if the output is to the terminal" column\:"fill columns before rows (default)" row\:"fill rows before columns" plain\:"show in one column" dense\:"make unequal size columns to utilize more space" nodense\:"make equal size columns"))' \
+    "($c $m $d $e --column)"'--no-column[do not display in columns]' \
     "($c $m $d $e )*--list[list only branches matching glob]:pattern" \
     "($c $m    $e  -a)-r[list or delete only remote-tracking branches]" \
     "($c $m $d $e: -r)-a[list both remote-tracking branches and local branches]" \
-    "($c $m $d $e : -v --verbose)"{-v,--verbose}'[show SHA1 and commit subject line for each head]' \
+    "($c $m $d $e : -v -vv --verbose)"{-v,-vv--verbose}'[show SHA1 and commit subject line for each head]' \
     "($c $m $d $e :)--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length" \
     "($c $m $d $e :)--no-abbrev[do not abbreviate sha1s]" \
     "($l $m $d $e)-l[create the branch's reflog]" \
@@ -419,6 +423,7 @@ _git-checkout () {
     '(--patch)--no-track[override the branch.autosetupmerge configuration variable]' \
     $new_branch_reflog_opt \
     '(-b -B -t --track --patch)--orphan[create a new orphan branch based at given commit]: :__git_branch_names' \
+    '--ignore-skip-worktree-bits[ignores patterns and adds back any files in <paths>]' \
     '(-q --quiet -f --force -m --merge --conflict --patch)'{-m,--merge}'[3way merge current branch, working tree and new branch]' \
     '(-q --quiet -f --force -m --merge --patch)--conflict[same as --merge, using given merge style]:style:(merge diff3)' \
     '(-)'{-p,--patch}'[interactively select hunks in diff between given tree-ish and working tree]' \
@@ -472,6 +477,8 @@ _git-cherry-pick () {
     '(- :)--quit[end revert or cherry-pick sequence]' \
     '(- :)--continue[resume revert or cherry-pick sequence]' \
     '(- :)--abort[cancel revert or cherry-pick sequence]' \
+    '--allow-empty-message[allow replaying a commit with an empty message]' \
+    '--keep-redundant-commits[keep cherry-picked commits that will become empty]' \
     '(-e --edit --ff)'{-e,--edit}'[edit commit before committing the revert]' \
     '(--ff)-x[append information about what commit was cherry-picked]' \
     '(-m --mainline)'{-m,--mainline}'[specify mainline when cherry-picking a merge commit]:parent number' \
@@ -588,6 +595,18 @@ _git-clone () {
   return ret
 }
 
+(( $+functions[_git-column] )) ||
+_git-column () {
+  _arguments -w -S -s \
+    '--command=[look up layout mode using config vars column.<name> and column.ui]' \
+    '--mode=[specify layout mode. See configuration variable column.ui for option syntax]' \
+    '--raw-mode=[same as --mode but take mode encoded as a number]' \
+    '--width=[specify the terminal width]' \
+    '--indent=[string to be printed at the beginning of each line]' \
+    '--nl[string to be printed at the end of each line, including newline character]' \
+    '--padding[the number of spaces between columns. One space by default]'
+}
+
 (( $+functions[_git-commit] )) ||
 _git-commit () {
   local amend_opt='--amend[amend the tip of the current branch]'
@@ -623,6 +642,7 @@ _git-commit () {
                                                                             default\:"act as '\''strip'\'' if the message is to be edited and as '\''whitespace'\'' otherwise"))' \
     '(-e --edit --no-edit)'{-e,--edit}'[edit the commit message before committing]' \
     '(-e --edit --no-edit)--no-edit[do not edit the commit message before committing]' \
+    '--no-post-rewrite[bypass the post-rewrite hook]' \
     '(-a --all --interactive -o --only -i --include)'{-i,--include}'[update the given files and commit the whole index]' \
     '(-a --all --interactive -o --only -i --include)'{-o,--only}'[commit only the given files]' \
     '(-u --untracked-files)'{-u-,--untracked-files=}'[show files in untracked directories]::mode:((no\:"show no untracked files"
@@ -863,7 +883,8 @@ _git-grep () {
   _arguments -C -A '-*' \
     '(-O --open-files-in-pager --no-index)--cached[search blobs registered in index file instead of working tree]' \
     '(--cached)--no-index[search files in current directory, not just treacked files]' \
-    '--exclude-standard[exclude files standard ignore mechanisms]' \
+    '(--exclude-standard)--no-exclude-standard[also search in ignored files]' \
+    '(--no-exclude-standard)--exclude-standard[exclude files standard ignore mechanisms]' \
     '--untracked[search in untracked files]' \
     '(-a --text)'{-a,--text}'[process binary files as if they were text]' \
     '(-i --ignore-case)'{-i,--ignore-case}'[ignore case when matching]' \
@@ -878,7 +899,7 @@ _git-grep () {
     '(-E --extended-regexp -G --basic-regexp -P --perl-regexp -F --fixed-strings)'{-G,--basic-regexp}'[use POSIX basic regexes]' \
     '(-E --extended-regexp -G --basic-regexp -P --perl-regexp -F --fixed-strings)'{-P,--perl-regexp}'[use perl-compatible regexes]' \
     '(-E --extended-regexp -G --basic-regexp -P --perl-regexp -F --fixed-strings)'{-F,--fixed-strings}'[do not interpret pattern as a regex]' \
-    '-n[prefix the line number to matching lines]' \
+    '(-n --line-number)'{-n,--line-number}'[prefix the line number to matching lines]' \
     '(-l --files-with-matches -L --files-without-match --name-only)'{-l,--files-with-matches,--name-only}'[show only names of matching files]' \
     '(-l --files-with-matches -L --files-without-match)'{-L,--files-without-match}'[show only names of non-matching files]' \
     '(--cached -O --open-files-in-pager)'{-O,--open-files-in-pager}'=-[open matching files in pager]::_path_commands' \
@@ -888,9 +909,9 @@ _git-grep () {
     '(--color           )---no-color[do not color matches]' \
     '--break[prefix the line number to matching lines]' \
     '--heading[show the filename above the matches]' \
-    '-A[show trailing context]: :__git_guard_number lines' \
-    '-B[show leading context]: :__git_guard_number lines' \
-    '-C[show context]: :__git_guard_number lines' \
+    '(-A --after-context)'{-A,--after-context=}'[show <num> trailing lines, and separate groups of matches]: :__git_guard_number lines' \
+    '(-B --before-context)'{-B,--before-context=}'[show <num> leading lines, and separate groups of matches]: :__git_guard_number lines' \
+    '(-A --after-context -B --before-context -C --context)'{-C,--context=}'[show <num> leading and trailing lines, and separate groups of matches]: :__git_guard_number lines' \
     '(-p --show-function)'{-p,--show-function}'[show preceding line containing function name of match]' \
     '(-W --function-context)'{-W,--function-context}'[show whole function where a match was found]' \
     '(1)*-f[read patterns from given file]:pattern file:_files' \
@@ -1205,6 +1226,7 @@ _git-push () {
     '--porcelain[produce machine-readable output]' \
     '--delete[delete all listed refs from the remote repository]' \
     '--tags[all tags under refs/tags are pushed]' \
+    '--follow-tags[also push missing annotated tags reachable from the pushed refs]' \
     '(--receive-pack --exec)'{--receive-pack=-,--exec=-}'[path to git-receive-pack on remote]:remote git-receive-pack:_files' \
     '(-f --force)'{-f,--force}'[allow refs that are not ancestors to be updated]' \
     '(:)--repo=[default repository to use]:repository:__git_any_repositories' \
@@ -1233,6 +1255,7 @@ _git-rebase () {
   _arguments -A '-*' \
     '(- :)--continue[continue after resolving merge conflict]' \
     '(- :)--abort[abort current rebase]' \
+    '--keep-empty[keep empty commits in the result]' \
     '(- :)--skip[skip the current patch]' \
     '(-m --merge)'{-m,--merge}'[use merging strategies to rebase]' \
     '*'{-s,--strategy=}'[use given merge strategy]:merge strategy:__git_merge_strategies' \
@@ -1521,7 +1544,10 @@ _git-status () {
                                                                                      normal\:"show untracked files and directories" \
                                                                                      all\:"also show untracked files in untracked directories (default)"))' \
     '--ignore-submodules[ignore changes to submodules]:: :__git_ignore_submodules_whens' \
+    '--ignored[show ignored files as well]' \
     '(--porcelain)-z[use NUL termination on output]' \
+    '(--no-column)--column=-[display in columns]::column.status option:((always\:"always show in columns" never\:"never show in columns" auto\:"show in columns if the output is to the terminal" column\:"fill columns before rows (default)" row\:"fill rows before columns" plain\:"show in one column" dense\:"make unequal size columns to utilize more space" nodense\:"make equal size columns"))' \
+    '(--column)--no-column[do not display in columns]' \
     '*: :__git_ignore_line_inside_arguments _files'
 }
 
@@ -1653,9 +1679,9 @@ _git-tag () {
 
   _arguments -A '-*' \
     - creation \
-      '(   -s -u)-a[create an unsigned, annotated tag]' \
-      '(-a    -u)-s[create an signed and annotated tag]' \
-      '(-a -s   )-u[create a tag, annotated and signed with the given key]: :__git_gpg_secret_keys' \
+      '(   -s -u --local-user)-a[create an unsigned, annotated tag]' \
+      '(-a    -u --local-user)-s[create an signed and annotated tag]' \
+      '(-a -s)'{-u,--local-user}'[create a tag, annotated and signed with the given key]: :__git_gpg_secret_keys' \
       '-f[replace existing tag]' \
       '--cleanup=[cleanup message]:mode:((verbatim\:"no cleanup" whitespace\:"remove leading and trailing whitespace" strip\:"remove leading and trailing whitespace and comments"))' \
       $message_opts \
@@ -1667,6 +1693,8 @@ _git-tag () {
     - listing \
       '-n+[limit line output of annotation]: :__git_guard_number "limit"' \
       '-l[list tags matching pattern]' \
+      '(--no-column)--column=-[display tag listing in columns]::column.tag option:((always\:"always show in columns" never\:"never show in columns" auto\:"show in columns if the output is to the terminal" column\:"fill columns before rows (default)" row\:"fill rows before columns" plain\:"show in one column" dense\:"make unequal size columns to utilize more space" nodense\:"make equal size columns"))' \
+      '(--column)--no-column[do not display in columns]' \
       '--contains=[only list tags which contain the specified commit]: :__git_commits' \
       '--points-at=[only list tags of the given object]: :__git_commits' \
       '::pattern' \
@@ -1740,7 +1768,9 @@ _git-config () {
       '(2)--get-regexp[like "--get-all", but interpret "name" as a regular expression]' \
       '(2 3 --bool --int --bool-or-int --path -z --null)--get-colorbool[check if color should be used]: :->gettable-colorbool-option' \
       '(2 3 --bool --int --bool-or-int --path -z --null)--get-color[find color setting]: :->gettable-color-option' \
-      '(-e --edit --bool --int --bool-or-int --path -z --null)'{-e,--edit}'[open config file for editing]' && ret=0
+      '(-e --edit --bool --int --bool-or-int --path -z --null)'{-e,--edit}'[open config file for editing]' \
+      '(--no-includes)'--includes'[respect "include.*" directives in config files when looking up values]' \
+      '(--includes)'--no-includes'[do not respect "include.*" directives]' && ret=0
 
   # TODO: Most all _path_commands should be able to take arguments and so on.
   # How do we deal with that and how do we quote the whole argument to git
@@ -2677,7 +2707,9 @@ _git-fast-export () {
     '-C-[detect copies as well as renames with given scope]: :__git_guard_number size' \
     '--export-marks=[dump internal marks table when complete]: :_files' \
     '--import-marks=[load marks before processing input]: :_files' \
+    '--import-marks-if-exists=[silently skip if files does not exist]: :_files' \
     '--fake-missing-tagger=[fake a tagger when tags lack them]' \
+    '--use-done-feature[start with a "feature done" stanza, and terminate with a "done" command]' \
     '--no-data[do not output blocb objects, instead referring to them via their SHA-1 hash]' \
     '--full-tree[output full tree for each commit]' \
     '*: :__git_commit_ranges'
@@ -2686,9 +2718,11 @@ _git-fast-export () {
 (( $+functions[_git-fast-import] )) ||
 _git-fast-import () {
   _arguments -S -A '-*' \
+    '--cat-blob-fd=-[write responses to cat-blob and ls queries to <fd> instead of stdout]:file descriptor' \
     '--date-format=-[type of dates used in input]:format:((raw\:"native Git format"
                                                            rfc2822\:"standard email format from RFC 2822"
                                                            now\:"use current time and timezone"' \
+    '--done[terminate with error if there is no "done" command at the end of the stream]' \
     '--force[force updating modified existing branches]' \
     '--max-pack-size=-[maximum size of each packfile]: :__git_guard_bytes' \
     '--big-file-threshold=-[maximum size of blob to create deltas for]: :__git_guard_bytes' \
@@ -2730,6 +2764,7 @@ _git-mergetool () {
   # TODO: Only complete files with merge conflicts.
   _arguments -S -A '-*' \
     '(-t --tool)'{-t,--tool=}'[merge resolution program to use]: :__git_mergetools' \
+    '--tool-help[print a list of merge tools that may be used with "--tool"]' \
     '(-y --no-prompt --prompt)'{-y,--no-prompt}'[do not prompt before invocation of merge resolution program]' \
     '(-y --no-prompt)--prompt[prompt before invocation of merge resolution program]' \
     '*:conflicted file:_files'
@@ -3034,7 +3069,8 @@ _git-cherry () {
 (( $+functions[_git-count-objects] )) ||
 _git-count-objects () {
   _arguments \
-    '(-v --verbose)'{-v,--verbose}'[also report number of in-pack objects and objects that can be removed]'
+    '(-v --verbose)'{-v,--verbose}'[also report number of in-pack objects and objects that can be removed]' \
+    {-H,--human-readable}'[Print sizes in human readable format]'
 }
 
 (( $+functions[_git-difftool] )) ||
@@ -3046,6 +3082,9 @@ _git-difftool () {
     '(-y --no-prompt)--prompt[prompt before invocation of diff tool]' \
     '(-t --tool -x --extcmd)'{-t,--tool=-}'[merge resolution program to use]: :__git_difftools' \
     '(-t --tool -x --extcmd)'{-x,--extcmd=-}'[custom diff command to use]: :_path_commands' \
+    '--tool-help[print a list of diff tools that may be used with --tool]' \
+    '(--symlinks)--no-symlinks[make copies of instead of symlinks to the working tree]' \
+    '(---no-symlinks)--symlinks[make symlinks to instead of copies of the working tree]' \
     '(-g --gui)'{-g,--gui}'[use diff.guitool instead of diff.tool]'
 }
 
@@ -3075,10 +3114,11 @@ _git-get-tar-commit-id () {
 (( $+functions[_git-help] )) ||
 _git-help () {
   _arguments -w -S -s \
-    '(         -i --info -m --man -w --web)'{-a,--all}'[show all available commands]' \
-    '(-a --all           -m --man -w --web)'{-i,--info}'[show all available commands]' \
-    '(-a --all -i --info          -w --web)'{-m,--man}'[show all available commands]' \
-    '(-a --all -i --info -m --man         )'{-w,--web}'[show all available commands]' \
+    '(         -g --guides -i --info -m --man -w --web)'{-a,--all}'[show all available commands]' \
+    '(-a --all -g --guides           -m --man -w --web)'{-i,--info}'[show all available commands]' \
+    '(-a --all -g --guides -i --info          -w --web)'{-m,--man}'[show all available commands]' \
+    '(-a --all -g --guides -i --info -m --man         )'{-w,--web}'[show all available commands]' \
+    '(-g --guides)'{-g,--guides}'[prints a list of useful guides on the standard output]' \
     ': :_git_commands'
 }
 
@@ -3198,6 +3238,7 @@ _git-rev-parse () {
       '(           --symbolic-full-name)--symbolic[output in a format as true to input as possible]' \
       '(--symbolic                     )--symbolic-full-name[same as --symbolic, but omit non-ref inputs]' \
       '--abbrev-ref=-[a non-ambiguous short name of object]::mode:(strict loose)' \
+      '--disambiguate=-[show every object whose name begins with the given prefix]:prefix' \
       '--all[show all refs found in refs/]' \
       '--branches=-[show branch refs found in refs/heads/]::shell glob pattern' \
       '--tags=-[show tag refs found in refs/tags/]::shell glob pattern' \
@@ -3213,6 +3254,7 @@ _git-rev-parse () {
       '(--revs-only --no-revs --flags --no-flags --verify)--short=-[show only shorter unique name]:: :__git_guard_number length' \
       '(--since --after)'{--since=-,--after=-}'[show --max-age= parameter corresponding given date string]:datestring' \
       '(--until --before)'{--until=-,--before=-}'[show --min-age= parameter corresponding given date string]:datestring' \
+      '--resolve-git-dir[check if <path> is a valid repository or gitfile and print location]:git dir:_files -/' \
       '*: :__git_objects' && ret=0
   fi
 
@@ -3392,13 +3434,16 @@ _git-send-email () {
     '--subject=[specify the initial subject of the email thread]:subject' \
     '--to=[specify the primary recipient of the emails]: :_email_addresses' \
     '--8bit-encoding=[encoding to use for non-ASCII messages]: :__git_encodings' \
+    '--compose-encoding=[encoding to use for compose messages]: :__git_encodings' \
     '--envelope-sender[specify the envelope sender used to send the emails]: :_email_addresses' \
     '--smtp-encryption=[specify encryption method to use]: :__git_sendemail_smtpencryption_values' \
     '--smtp-domain=[specify FQDN used in HELO/EHLO]: :_domains' \
     '--smtp-pass=[specify password to use for SMTP-AUTH]::password' \
     '--smtp-server=[specify SMTP server to connect to]:smtp server:_hosts' \
     '--smtp-server-port=[specify port to connect to SMTP server on]:smtp port:_ports' \
+    '--smtp-server-option=[specify the outgoing SMTP server option to use]:SMPT server option' \
     '--smtp-user=[specify user to use for SMTP-AUTH]:smtp user:_users' \
+    '--smtp-debug=[enable or disable debug output]:smtp debug:((0\:"disable" 1\:"enable"))' \
     '--cc-cmd=[specify command to generate Cc\: header with]:Cc\: command:_path_commands' \
     '--to-cmd=[specify command to generate To\: header with]:To\: command:_path_commands' \
     '(                 --no-chain-reply-to)--chain-reply-to[send each email as a reply to previous one]' \
@@ -3917,6 +3962,7 @@ _git-read-tree () {
     $exclude_per_directory_opt \
     '--index-output=[write index in the named file instead of $GIT_INDEX_FILE]: :_files' \
     '--no-sparse-checkout[display sparse checkout support]' \
+    '--empty[instead of reading tree object(s) into the index, just empty it]' \
     '1:first tree-ish to be read/merged:__git_tree_ishs' \
     '2::second tree-ish to be read/merged:__git_tree_ishs' \
     '3::third tree-ish to be read/merged:__git_tree_ishs'
@@ -4331,6 +4377,8 @@ _git-daemon () {
     '--disable=-[disable site-wide service]: :__git_daemon_service' \
     '--allow-override[allow overriding site-wide service]: :__git_daemon_service' \
     '--forbid-override[forbid overriding site-wide service]: :__git_daemon_service' \
+    '(--no-informative-errors)--informative-errors[report more verbose errors to the client]' \
+    '(--informative-errors)--no-informative-errors[report all errors as "access denied" to the client]' \
     '*:repository:_directories'
 }
 
@@ -4535,7 +4583,10 @@ _git-check-attr () {
 _git-check-ref-format () {
   _arguments \
     '-h[display usage information]' \
-    '--print[display canonicalized name of hypothetical reference of given name]' \
+    '(--no-allow-onelevel)--allow-onelevel[accept one-level refnames]' \
+    '(--allow-onelevel)--no-allow-onelevel[do not accept one-level refnames]' \
+    '--refspec-pattern[interpret <refname> as a reference name pattern for a refspec]' \
+    '--normalize[Normalize refname by removing leading slashes]' \
     '--branch[expand previous branch syntax]' \
     ': :__git_references'
 }
@@ -4590,7 +4641,8 @@ _git-patch-id () {
 (( $+functions[_git-stripspace] )) ||
 _git-stripspace () {
   _arguments \
-    '(-s --strip-comments)'{-s,--strip-comments}'[also strip lines starting with #]'
+    '(-s --strip-comments)'{-s,--strip-comments}'[also strip lines starting with #]' \
+    '(-c --comment-lines)'{-c,--comment-lines}'[prepend comment character and blank to each line]'
 }
 
 # INTERNAL GIT COMPLETION FUNCTIONS
@@ -5747,13 +5799,11 @@ __git_setup_diff_options () {
     '--full-index[show full object name of pre- and post-image blob]'
     '(--full-index)--binary[in addition to --full-index, output binary diffs for git-apply]'
     '--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length'
-    # TODO: --break-rewrites is undocumented.
     '(-B --break-rewrites)'{-B-,--break-rewrites=-}'[break complete rewrite changes into pairs of given size]:: :__git_guard_number size'
-    # TODO: --detect-renames is undocumented.
-    '(-M --detect-renames)'{-M-,--detect-renames=-}'[detect renames with given scope]:: :__git_guard_number size'
-    # TODO: --detect-copies is undocumented.
-    '(-C --detect-copies)'{-C-,--detect-copies=-}'[detect copies as well as renames with given scope]:: :__git_guard_number size'
+    '(-M --find-renames)'{-M-,--find-renames=-}'[Detect renames with given scope]:: :__git_guard_number size'
+    '(-C --find-copies)'{-C-,--find-copies=-}'[detect copies as well as renames with given scope]:: :__git_guard_number size'
     '--find-copies-harder[try harder to find copies]'
+    '(-D --irreversible-delete)'{-D,--irreversible-delete}'[omit the preimage for deletes]'
     '-l-[limit number of rename/copy targets to run]: :__git_guard_number'
     '--diff-filter=-[select certain kinds of files for diff]: :_guard "[ACDMRTUXB*]#" kinds'
     '-S-[look for differences that contain the given string]:string'
@@ -5812,7 +5862,8 @@ __git_setup_revision_options () {
                                                                                     email\:"use email headers like From and Subject"
                                                                                     raw\:"the raw commits"
                                                                                     format\:"specify own format"))'
-    '--abbrev-commit[show only partial prefixes of commit object names]'
+    '(--abbrev-commit --no-abbrev-commit)--abbrev-commit[show only partial prefixes of commit object names]'
+    '(--abbrev-commit --no-abbrev-commit)--no-abbrev-commit[show the full 40-byte hexadecimal commit object name]'
     '--oneline[shorthand for --pretty=oneline --abbrev-commit]'
     '--encoding=-[output log messages in given encoding]:: :__git_encodings'
     '(--no-notes --notes)--no-notes[do not show notes that annotate commit]'
@@ -5841,6 +5892,10 @@ __git_setup_revision_options () {
     '--remove-empty[stop when given path disappears from tree]'
     '--merges[display only merge commits]'
     '--no-merges[do not display commits with more than one parent]'
+    '(--min-parents --no-min-parents)--min-parents=-[show only commits having at least <n> commits]: :__git_guard_number "minimum number of parents"'
+    '(--min-parents --no-min-parents)--no-min-parents[reset limit]'
+    '(--max-parents --no-max-parents)--max-parents=-[show only commits having at most <n> commits]: :__git_guard_number "maximum number of parents"'
+    '(--max-parents --no-max-parents)--no-max-parents[reset limit]'
     '--first-parent[follow only first parent from merge commits]'
     '*--not[reverses meaning of ^ prefix for revisions that follow]'
     '--all[show all commits from refs]'
@@ -5910,6 +5965,8 @@ __git_setup_merge_options () {
     '--ff-only[refuse to merge unless HEAD is up to date or merge can be resolved as a fast-forward]'
     '*'{-s,--strategy=}'[use given merge strategy]:merge strategy:__git_merge_strategies'
     '*'{-X,--strategy-option=}'[pass merge-strategy-specific option to merge strategy]'
+    '(--verify-signatures)--no-verify-signatures[verify the commits being merged or abort]'
+    '(--no-verify-signatures)--verify-signatures[do not verify the commits being merged]'
     '(-q --quiet -v --verbose)'{-q,--quiet}'[suppress all output]'
     '(-q --quiet -v --verbose)'{-v,--verbose}'[output additional information]')
 }
@@ -5929,10 +5986,13 @@ __git_setup_fetch_options () {
     '(--no-tags -t --tags)'{-t,--tags}'[fetch remote tags]'
     '(-u --update-head-ok)'{-u,--update-head-ok}'[allow updates of current branch head]'
     '--upload-pack=[specify path to git-upload-pack on remote side]:remote path'
-    '(--no-recurse-submodules --recurse-submodules)--recurse-submodules=[specify when to fetch commits of submodules]:recursive fetching mode:((no\:"disable recursion"
+    '(--no-recurse-submodules --recurse-submodules)--recurse-submodules=-[specify when to fetch commits of submodules]::recursive fetching mode:((no\:"disable recursion"
                                                                                                                                                 yes\:"always recurse"
                                                                                                                                                 on-demand\:"only when submodule reference in superproject is updated"))'
     '(--no-recurse-submodules --recurse-submodules)--no-recurse-submodules[disable recursive fetching of submodules]'
+    '(--no-recurse-submodules)--recurse-submodules-default=-[provide internal temporary non-negative value for "--recurse-submodules"]::recursive fetching mode:((yes\:"always recurse"
+                                                                                                                                                                 on-demand\:"only when submodule reference in superproject is updated"))'
+    '--submodule-prefix=-[prepend <path> to paths printed in informative messages]:submodule prefix path:_files -/'
     '(-q --quiet -v --verbose --progress)'{-q,--quiet}'[suppress all output]'
     '(-q --quiet -v --verbose)'{-v,--verbose}'[output additional information]'
     '(-q --quiet)--progress[output progress information]')
@@ -6267,13 +6327,17 @@ _git() {
       '(- :)--help[display help message]' \
       '-c[pass configuration parameter to command]:parameter' \
       '--exec-path=-[path containing core git-programs]:: :_directories' \
-      '--html-path[display path to HTML documentation and exit]' \
+      '(: -)--man-path[print the manpath for the man pages for this version of Git and exit]' \
+      '(: -)--info-path[print the path where the info files are installed and exit]' \
+      '(: -)--html-path[display path to HTML documentation and exit]' \
       '(-p --paginate)'{-p,--paginate}'[pipe output into $PAGER]' \
       '--no-pager[do not pipe git output into a pager]' \
       '--git-dir=-[path to repository]: :_directories' \
       '--work-tree=-[path to working tree]: :_directories' \
+      '--namespace=-[set the Git namespace]: :_directories' \
       '--bare[use $PWD as repository]' \
       '--no-replace-objects[do not use replacement refs to replace git objects]' \
+      '--literal-pathspecs[treat pathspecs literally, rather than as glob patterns]' \
       '(-): :->command' \
       '(-)*:: :->option-or-argument' && return
 
-- 
1.8.2.2


^ permalink raw reply	[relevance 1%]

* [PATCH v2 05/14] _git: completion updates to match latest git v1.8.3
  @ 2013-09-22 10:48  3% ` Øystein Walle
  2013-09-22 10:48  1% ` [PATCH v2 06/14] _git: completion updates to match latest git v1.8.3 part 2 Øystein Walle
  1 sibling, 0 replies; 200+ results
From: Øystein Walle @ 2013-09-22 10:48 UTC (permalink / raw)
  To: zsh-workers; +Cc: m0viefreak

From: m0viefreak <m0viefreak.cm@googlemail.com>

---
 Completion/Unix/Command/_git | 250 ++++++++++++++++++++++++++++++++-----------
 1 file changed, 186 insertions(+), 64 deletions(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 6797f9c..867bd67 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -277,12 +277,13 @@ _git-bisect () {
 
 (( $+functions[_git-branch] )) ||
 _git-branch () {
-  declare l c m d
+  declare l c m d e
 
-  l='--color --no-color -r -a -v --verbose --abbrev --no-abbrev'
-  c='-l -f --force -t --track --no-track --set-upstream --contains --merged --no-merged'
-  m='-m -M'
-  d='-d -D'
+  l='--color --no-color -r -a -v --verbose --abbrev --no-abbrev --list'
+  c='-l -f --force -t --track --no-track -u --set-upstream --set-upstream-to --unset-upstream --contains --merged --no-merged'
+  m='-m --move -M'
+  d='-d --delete -D'
+  e='--edit-description'
 
   declare -a dependent_creation_args
   if (( words[(I)-r] == 0 )); then
@@ -312,27 +313,31 @@ _git-branch () {
   fi
 
   _arguments -w -S -s \
-    "($c $m $d --no-color :)--color=-[turn on branch coloring]:: :__git_color_whens" \
-    "($c $m $d : --color)--no-color[turn off branch coloring]" \
-    "($c $m      -a)-r[list or delete only remote-tracking branches]" \
-    "($c $m $d : -r)-a[list both remote-tracking branches and local branches]" \
-    "($c $m $d : -v --verbose)"{-v,--verbose}'[show SHA1 and commit subject line for each head]' \
-    "($c $m $d :)--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length" \
-    "($c $m $d :)--no-abbrev[do not abbreviate sha1s]" \
-    "($l $m $d)-l[create the branch's reflog]" \
-    "($l $m $d -f --force)"{-f,--force}"[force the creation of a new branch]" \
-    "($l $m $d -t --track)"{-t,--track}"[set up configuration so that pull merges from the start point]" \
-    "($l $m $d)--no-track[override the branch.autosetupmerge configuration variable]" \
-    "($l $m $d)--set-upstream[set up configuration so that pull merges]" \
-    "($l $m $d)--contains=[only list branches which contain the specified commit]: :__git_committishs" \
-    "($l $m $d)--merged=[only list branches which are fully contained by HEAD]: :__git_committishs" \
-    "($l $m $d)--no-merged=[do not list branches which are fully contained by HEAD]: :__git_committishs" \
+    "($c $m $d $e --no-color :)--color=-[turn on branch coloring]:: :__git_color_whens" \
+    "($c $m $d $e : --color)--no-color[turn off branch coloring]" \
+    "($c $m $d $e )*--list[list only branches matching glob]:pattern" \
+    "($c $m    $e  -a)-r[list or delete only remote-tracking branches]" \
+    "($c $m $d $e: -r)-a[list both remote-tracking branches and local branches]" \
+    "($c $m $d $e : -v --verbose)"{-v,--verbose}'[show SHA1 and commit subject line for each head]' \
+    "($c $m $d $e :)--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length" \
+    "($c $m $d $e :)--no-abbrev[do not abbreviate sha1s]" \
+    "($l $m $d $e)-l[create the branch's reflog]" \
+    "($l $m $d $e -f --force)"{-f,--force}"[force the creation of a new branch]" \
+    "($l $m $d $e -t --track)"{-t,--track}"[set up configuration so that pull merges from the start point]" \
+    "($l $m $d $e)--no-track[override the branch.autosetupmerge configuration variable]" \
+    "($l $m $d $e -u --set-upstream --set-upstream-to --unset-upstream)"{-u,--set-upstream-to=}"[set up configuration so that pull merges]:remote-branches:__git_remote_branch_names" \
+    "($l $m $d $e -u --set-upstream --set-upstream-to --unset-upstream)--unset-upstream[remove upstream configuration]" \
+    "($l $m $d $e)--contains=[only list branches which contain the specified commit]: :__git_committishs" \
+    "($l $m $d $e)--merged=[only list branches which are fully contained by HEAD]: :__git_committishs" \
+    "($l $m $d $e)--no-merged=[do not list branches which are fully contained by HEAD]: :__git_committishs" \
+    "($c $l $m $d)--edit-description[edit branch description]" \
     $dependent_creation_args \
-    "($l $c $d -M)-m[rename a branch and the corresponding reflog]" \
-    "($l $c $d -m)-M[rename a branch even if the new branch-name already exists]" \
+    "($l $c $d $m $e)"{-m,--move}"[rename a branch and the corresponding reflog]" \
+    "($l $c $d $m $e)-M[rename a branch even if the new branch-name already exists]" \
     $dependent_modification_args \
-    "($l $c $m -D)-d[delete a fully merged branch]" \
-    "($l $c $m -d)-D[delete a branch]" \
+    "($l $c $m $d $e)"{-d,--delete}"[delete a fully merged branch]" \
+    "($l $c $m $d $e)-D[delete a branch]" \
+    {-q,--quiet}"[be more quiet]" \
     $dependent_deletion_args
 }
 
@@ -472,6 +477,8 @@ _git-cherry-pick () {
     '(-m --mainline)'{-m,--mainline}'[specify mainline when cherry-picking a merge commit]:parent number' \
     '(-n --no-commit --ff)'{-n,--no-commit}'[do not make the actually commit]' \
     '(-s --signoff --ff)'{-s,--signoff}'[add Signed-off-by line at the end of the commit message]' \
+    '*'{-s,--strategy=}'[use given merge strategy]:merge strategy:__git_merge_strategies' \
+    '*'{-X,--strategy-option=}'[pass merge-strategy-specific option to merge strategy]' \
     '(-e --edit -x -n --no-commit -s --signoff)--ff[fast forward, if possible]' \
     ': :__git_revisions'
 }
@@ -546,7 +553,8 @@ _git-clone () {
   # TODO: Argument to -b should complete branch names in the repository being
   # cloned.
   _arguments -w -C -S -s \
-    '(-l --local)'{-l,--local}'[clone locally, hardlink refs and objects if possible]' \
+    '(-l --local --no-local)'{-l,--local}'[clone locally, hardlink refs and objects if possible]' \
+    '(-l --local --no-local)--no-local[override --local, as if file:/// URL was given]' \
     '--no-hardlinks[copy files instead of hardlinking when doing a local clone]' \
     '(-s --shared)'{-s,--shared}'[share the objects with the source repository (warning: see man page)]' \
     '--reference[reference repository]:repository:_directories' \
@@ -560,7 +568,9 @@ _git-clone () {
     '(-b --branch)'{-b,--branch}'[point HEAD to the given branch]: :__git_guard_branch-name' \
     '(-u --upload-pack)'{-u,--upload-pack=}'[specify path to git-upload-pack on remote side]:remote path' \
     '--template=[directory to use as a template for the object database]: :_directories' \
+    '*'{-c,--config}'[<key>=<value> set a configuration variable in the newly created repository]' \
     '--depth[create a shallow clone, given number of revisions deep]: :__git_guard_number depth' \
+    '--single-branch[clone only history leading up to the main branch or the one specified by -b]' \
     '--recursive[initialize all contained submodules]' \
     ': :->repository' \
     ': :_directories' && ret=0
@@ -600,17 +610,19 @@ _git-commit () {
     '(        --porcelain --dry-run)--short[output dry run in short format]' \
     '(--short             --dry-run)--porcelain[output dry run in porcelain-ready format]' \
     '(--short --porcelain --dry-run -z --null)'{-z,--null}'[separate dry run entry output with NUL]' \
+    '--patch[use the interactive patch selection interface to chose which changes to commit]' \
     '(--reset-author)--author[override the author name used in the commit]:author name' \
     '--date=[override the author date used in the commit]:date' \
     '(-s --signoff)'{-s,--signoff}'[add Signed-off-by line at the end of the commit message]' \
     '(-n --no-verify)'{-n,--no-verify}'[do not look for suspicious lines the commit introduces]' \
     '--allow-empty[allow recording an empty commit]' \
     '--allow-empty-message[allow recording a commit with an empty message]' \
-    '--cleanup=[specify how the commit message should be cleaned up]:mode:((verbatim\:"don'\''t change the commit message at all"
+    '--cleanup=[specify how the commit message should be cleaned up]:mode:((verbatim\:"do not change the commit message at all"
                                                                             whitespace\:"remove leading and trailing whitespace lines"
                                                                             strip\:"remove both whitespace and commentary lines"
                                                                             default\:"act as '\''strip'\'' if the message is to be edited and as '\''whitespace'\'' otherwise"))' \
-    '(-e --edit)'{-e,--edit}'[edit the commit message before committing]' \
+    '(-e --edit --no-edit)'{-e,--edit}'[edit the commit message before committing]' \
+    '(-e --edit --no-edit)--no-edit[do not edit the commit message before committing]' \
     '(-a --all --interactive -o --only -i --include)'{-i,--include}'[update the given files and commit the whole index]' \
     '(-a --all --interactive -o --only -i --include)'{-o,--only}'[commit only the given files]' \
     '(-u --untracked-files)'{-u-,--untracked-files=}'[show files in untracked directories]::mode:((no\:"show no untracked files"
@@ -621,6 +633,7 @@ _git-commit () {
     '--dry-run[only show list of paths that are to be commited or not, and any untracked]' \
     '(         --no-status)--status[include the output of git status in the commit message template]' \
     '(--status            )--no-status[do not include the output of git status in the commit message template]' \
+    '(-S --gpg-sign)'{-S-,--gpg-sign=}'[GPG-sign the commit]::key id' \
     '(-a --all --interactive -o --only -i --include *)--interactive[interactively update paths in the index file]' \
     '*: :__git_ignore_line_inside_arguments __git_changed_files' \
     - '(message)' \
@@ -793,14 +806,17 @@ _git-format-patch () {
     '(--thread            )--no-thread[do not thread messages]' \
     '--in-reply-to=[make the first mail a reply to the given message]:message id' \
     '--ignore-if-in-upstream[do not include a patch that matches a commit in the given range]' \
+    '(-v --reroll-count)'{-v,--reroll-count=}'[mark the series as the <n>-th iteration of the topic]: :__git_guard_number iteration' \
     '(-k --keep-subject)--subject-prefix=[use the given prefix instead of \[PATCH\]]:prefix' \
     '*--to=[add To: header to email headers]: :_email_addresses' \
     '*--cc=[add Cc: header to email headers]: :_email_addresses' \
     '*--add-header=[add an arbitrary header to email headers]:header' \
     '--cover-letter[generate a cover letter template]' \
+    '--notes=[append notes for the commit after the three-dash line]:: :__git_notes_refs' \
     '(            --no-signature)--signature=[add a signature]:signature' \
     '(--signature               )--no-signature[do not add a signature]' \
     '--suffix=[use the given suffix for filenames]:filename suffix' \
+    '--quiet[suppress the output of the names of generated files]' \
     '--no-binary[do not output contents of changes in binary files, only note that they differ]' \
     '--root[treat the revision argument as a range]' \
     ': :->commit-or-commit-range' && ret=0
@@ -847,6 +863,8 @@ _git-grep () {
   _arguments -C -A '-*' \
     '(-O --open-files-in-pager --no-index)--cached[search blobs registered in index file instead of working tree]' \
     '(--cached)--no-index[search files in current directory, not just treacked files]' \
+    '--exclude-standard[exclude files standard ignore mechanisms]' \
+    '--untracked[search in untracked files]' \
     '(-a --text)'{-a,--text}'[process binary files as if they were text]' \
     '(-i --ignore-case)'{-i,--ignore-case}'[ignore case when matching]' \
     '-I[do not match pattern in binary files]' \
@@ -856,9 +874,10 @@ _git-grep () {
     '(   -H)-h[supress output of filenames]' \
     '(-h   )-H[show filenames]' \
     '--full-name[output paths relative to the project top directory]' \
-    '(-E --extended-regexp -G --basic-regexp)'{-E,--extended-regexp}'[use POSIX extended regexes]' \
-    '(-E --extended-regexp -G --basic-regexp)'{-G,--basic-regexp}'[use POSIX basic regexes]' \
-    '(-F --fixed-strings)'{-F,--fixed-strings}'[do not interpret pattern as a regex]' \
+    '(-E --extended-regexp -G --basic-regexp -P --perl-regexp -F --fixed-strings)'{-E,--extended-regexp}'[use POSIX extended regexes]' \
+    '(-E --extended-regexp -G --basic-regexp -P --perl-regexp -F --fixed-strings)'{-G,--basic-regexp}'[use POSIX basic regexes]' \
+    '(-E --extended-regexp -G --basic-regexp -P --perl-regexp -F --fixed-strings)'{-P,--perl-regexp}'[use perl-compatible regexes]' \
+    '(-E --extended-regexp -G --basic-regexp -P --perl-regexp -F --fixed-strings)'{-F,--fixed-strings}'[do not interpret pattern as a regex]' \
     '-n[prefix the line number to matching lines]' \
     '(-l --files-with-matches -L --files-without-match --name-only)'{-l,--files-with-matches,--name-only}'[show only names of matching files]' \
     '(-l --files-with-matches -L --files-without-match)'{-L,--files-without-match}'[show only names of non-matching files]' \
@@ -867,10 +886,13 @@ _git-grep () {
     '(-c --count)'{-c,--count}'[show number of matching lines in files]' \
     '(        --no-color)--color=-[color matches]:: :__git_color_whens' \
     '(--color           )---no-color[do not color matches]' \
+    '--break[prefix the line number to matching lines]' \
+    '--heading[show the filename above the matches]' \
     '-A[show trailing context]: :__git_guard_number lines' \
     '-B[show leading context]: :__git_guard_number lines' \
     '-C[show context]: :__git_guard_number lines' \
     '(-p --show-function)'{-p,--show-function}'[show preceding line containing function name of match]' \
+    '(-W --function-context)'{-W,--function-context}'[show whole function where a match was found]' \
     '(1)*-f[read patterns from given file]:pattern file:_files' \
     '(1)*-e[use the given pattern for matching]:pattern' \
     $pattern_operators \
@@ -984,6 +1006,7 @@ _git-init () {
     '--bare[create a bare repository]' \
     '--template=[directory to use as a template for the object database]: :_directories' \
     '--shared=[share repository amongst several users]:: :__git_repository_permissions' \
+    '--separate-git-dir=[create git dir elsewhere and link it using the gitdir mechanism]:: :_directories' \
     ':: :_directories'
 }
 
@@ -1044,6 +1067,7 @@ _git-merge () {
     '-m[set the commit message to be used for the merge commit]:merge message' \
     '(                    --no-rerere-autoupdate)--rerere-autoupdate[allow the rerere mechanism to update the index]' \
     '(--rerere-autoupdate                       )--no-rerere-autoupdate[do not allow the rerere mechanism to update the index]' \
+    '--abort[restore the original branch and abort the merge operation]' \
     '*: :__git_commits'
 }
 
@@ -1090,6 +1114,7 @@ _git-notes () {
         copy:'copy notes from one object to another'
         append:'append notes to a given object'
         edit:'edit notes for a given object'
+        merge:'merge the given notes ref into the current ref'
         show:'show notes for a given object'
         remove:'remove notes for a given object'
         prune:'remove all notes for non-existing/unreachable objects')
@@ -1124,6 +1149,15 @@ _git-notes () {
             ': :__git_commits' \
             ': :__git_commits' && ret=0
           ;;
+        (merge)
+          _arguments -w -S -s \
+            '(-s --strategy)--abort[abort an in-progress notes merge]' \
+            '(-s --strategy)--commit[finalize an in-progress notes merge]' \
+            {-q,--quiet}'[be quiet]' \
+            {-v,--verbose}'[be more verbose]' \
+            '(--abort --commit)'{-s,--strategy=}'[resolve conflicts using the given strategy]' \
+            ': :__git_notes_refs' && ret=0
+          ;;
         (append)
           _arguments -w -S -s \
             '*'{-m,--message=}'[use given note message]:message' \
@@ -1165,6 +1199,7 @@ _git-push () {
   # later on to match the remote end.
   _arguments -w -S -s \
     '--all[push all refs under refs/heads/]' \
+    '--prune[remove remote branches that do not have a local counterpart]' \
     '--mirror[push all refs under refs/heads/ and refs/tags/ and delete non-existing refs]' \
     '(-n --dry-run)'{-n,--dry-run}'[do everything except actually send the updates]' \
     '--porcelain[produce machine-readable output]' \
@@ -1173,12 +1208,14 @@ _git-push () {
     '(--receive-pack --exec)'{--receive-pack=-,--exec=-}'[path to git-receive-pack on remote]:remote git-receive-pack:_files' \
     '(-f --force)'{-f,--force}'[allow refs that are not ancestors to be updated]' \
     '(:)--repo=[default repository to use]:repository:__git_any_repositories' \
-    '(-u --set-upstream)'{-u,--set-upstream}'[add upstream reference for each branch that is up to date or pushed]' \
+    '(-u --set-upstream-to)'{-u,--set-upstream-to}'[add upstream reference for each branch that is up to date or pushed]' \
     '(       --no-thin)--thin[try to minimize number of objects to be sent]' \
     '(--thin          )--no-thin[do not try to minimize number of objects to be sent]' \
     '(-q --quiet -v --verbose --progress)'{-q,--quiet}'[suppress all output]' \
     '(-q --quiet -v --verbose)'{-v,--verbose}'[output additional information]' \
     '(-q --quiet)--progress[output progress information]' \
+    '--recurse-submodules=[submodule handling]:submodule handling:((check\:"refuse pushing of supermodule if submodule commit cannot be found on the remote"
+                                                                    on-demand\:"push all changed submodules"))' \
     ':: :__git_any_repositories' \
     '*: :__git_ref_specs'
 }
@@ -1209,7 +1246,9 @@ _git-rebase () {
     '(-i --interactive)--whitespace=-[detect a new or modified line that has whitespace errors]: :__git_apply_whitespace_strategies' \
     '(-i --interactive)--committer-date-is-author-date[use author date as committer date]' \
     '(-i --interactive --ignore-whitespace --whitespace --committer-date-is-author-date)'{-i,--interactive}'[make a list of commits to be rebased and open in $EDITOR]' \
+    '--edit-todo[edit interactive instruction sheet in an editor]' \
     '(-p --preserve-merges --interactive)'{-p,--preserve-merges}'[try to recreate merges instead of ignoring them]' \
+    {-x,--exec}'[with -i\: append "exec <cmd>" after each line]:command' \
     '(1)--root[rebase all reachable commits]' \
     $autosquash_opts \
     '--no-ff[cherry-pick all rebased commits with --interactive, otherwise synonymous to --force-rebase]' \
@@ -1254,7 +1293,6 @@ _git-revert () {
     '(- :)--quit[end revert or cherry-pick sequence]' \
     '(- :)--continue[resume revert or cherry-pick sequence]' \
     '(- :)--abort[cancel revert or cherry-pick sequence]' \
-    '(-e --edit --no-edit)'{-e,--edit}'[edit the commit before committing the revert]' \
     '(-m --mainline)'{-m+,--mainline=}'[pick which parent is mainline]:parent number' \
     '(-e --edit)--no-edit[do not edit the commit message]' \
     '(-n --no-commit)'{-n,--no-commit}'[do not commit the reversion]' \
@@ -1415,6 +1453,7 @@ _git-stash () {
             '(             --no-keep-index)--keep-index[all changes already added to the index are left intact]' \
             '(--keep-index                )--no-keep-index[all changes already added to the index are undone]' \
             '(-q --quiet)'{-q,--quiet}'[suppress all output]' \
+            '(-u --include-untracked)'{-u,--include-untracked}'[include untracked files]' \
             '::message' && ret=0
           ;;
         (list)
@@ -1504,6 +1543,7 @@ _git-submodule () {
         add:'add given repository as a submodule'
         status:'show the status of a submodule'
         init:'initialize a submodule'
+        deinit:'unregister a submodule'
         update:'update a submodule'
         summary:'show commit summary between given commit and working tree/index'
         foreach:'evaluate shell command in each checked-out submodule'
@@ -1522,6 +1562,7 @@ _git-submodule () {
             '(-q --quiet)'{-q,--quiet}'[suppress all output]' \
             '(-b --branch)'{-b,--branch}'[branch of repository to add as submodule]' \
             '(-f --force)'{-f,--force}'[allow adding an otherwise ignored submodule path]' \
+            '--name[use given name instead of defaulting to its path]:name' \
             '--reference=[remote repository to clone]: :__git_any_repositories' \
             ': :__git_any_repositories' \
             ':: :_directories' && ret=0
@@ -1538,6 +1579,11 @@ _git-submodule () {
             '(-q --quiet)'{-q,--quiet}'[suppress all output]' \
             '*: :__git_ignore_line_inside_arguments __git_submodules' && ret=0
           ;;
+        (deinit)
+          _arguments -S \
+            '(-f --force)'{-f,--force}'[remove submodule worktree even if local modifications are present]' \
+            '*: :__git_ignore_line_inside_arguments __git_submodules' && ret=0
+          ;;
         (update)
           # TODO: --init not properly documented.
           _arguments -S \
@@ -1547,6 +1593,7 @@ _git-submodule () {
             '--rebase[rebase current branch onto commit recorded in superproject]' \
             '--reference=[remote repository to clone]: :__git_any_repositories' \
             '--recursive[traverse submodules recursively]' \
+            '--force[discard local changes by checking out the current up-to-date version]' \
             '--init[initialize uninitialized submodules]' \
             '*: :__git_ignore_line_inside_arguments __git_submodules' && ret=0
           ;;
@@ -1580,6 +1627,7 @@ _git-submodule () {
           ;;
         (sync)
           _arguments -S \
+            '--recursive[traverse submodules recursively]' \
             '(-q --quiet)'{-q,--quiet}'[suppress all output]' \
             '*: :__git_ignore_line_inside_arguments __git_submodules' && ret=0
           ;;
@@ -1609,6 +1657,7 @@ _git-tag () {
       '(-a    -u)-s[create an signed and annotated tag]' \
       '(-a -s   )-u[create a tag, annotated and signed with the given key]: :__git_gpg_secret_keys' \
       '-f[replace existing tag]' \
+      '--cleanup=[cleanup message]:mode:((verbatim\:"no cleanup" whitespace\:"remove leading and trailing whitespace" strip\:"remove leading and trailing whitespace and comments"))' \
       $message_opts \
       ': :__git_tags' \
       ':: :__git_commits' \
@@ -1619,6 +1668,7 @@ _git-tag () {
       '-n+[limit line output of annotation]: :__git_guard_number "limit"' \
       '-l[list tags matching pattern]' \
       '--contains=[only list tags which contain the specified commit]: :__git_commits' \
+      '--points-at=[only list tags of the given object]: :__git_commits' \
       '::pattern' \
     - verification \
       '-v[verifies gpg signutare of tags]' \
@@ -1799,15 +1849,19 @@ _git-config () {
     color.status.untracked:'color of files not currently being tracked::->color'
     color.status.nobranch:'color of no-branch warning::->color'
     color.ui:'color output of capable git commands::->color-bool'
+    commit.cleanup:'default --cleanup option::->commit.cleanup:default'
     commit.status:'include status information in commit message template::->bool:true'
     commit.template:'template file for commit messages:template:_files'
+    diff.algorithm:'default diff algorithm::->diff.algorithm:default'
     diff.autorefreshindex:'run git update-index --refresh before git diff::->bool:true'
+    diff.context:'default number of context lines::->int:3'
     diff.external:'command to generate diff with:diff command:_path_commands'
     diff.mnemonicprefix:'use mnemonic source and destination prefixes::->bool:false'
     diff.noprefix:'strip source and destination prefixes::->bool:false'
     diff.renameLimit:'number of files to consider when detecting copy/renames:rename limit:->int'
     diff.renames:'try to detect renames::->diff.renames:true'
     diff.ignoreSubmodules:'ignore submodules::->bool:false'
+    diff.submodule:'output format for submodule differences::->diff.submodule:short'
     diff.suppressBlankEmpty:'inbihit printing space before empty output lines::->bool:false'
     diff.tool:'diff tool to use::__git_difftools'
     'difftool.*.cmd:command to invoke for the diff tool::_path_commands'
@@ -1877,7 +1931,10 @@ _git-config () {
     guitool.revunmerged:'show only unmerged branches in revprompt::->bool:false'
     guitool.title:'title of prompt dialog:prompt title:->string'
     guitool.prompt:'prompt to display:prompt:->string'
+    grep.lineNumber:'enable -n option by default::->bool:false'
+    grep.patternType:'default matching pattern type::->grep.patternType:default'
     help.browser:'browser used to display help in web format::__git_browsers'
+    help.htmlpath:'location of HTML help::->help.htmlpath'
     help.format:'default help format used by git help::->help.format'
     help.autocorrect:'execute corrected mistyped commands::->bool:false'
     http.proxy:'HTTP proxy to use:proxy:_urls'
@@ -1955,8 +2012,9 @@ _git-config () {
     pack.indexVersion:'default pack index version:index version:->string'
     pack.packSizeLimit:'maximum size of packs:maximum size of packs:->bytes'
     pull.octopus:'default merge strategy to use when pulling multiple branches::__git_merge_strategies'
+    pull.rebase:'rebase branches on top of the fetched branch, instead of merging::->bool:false'
     pull.twohead:'default merge strategy to use when pulling a single branch::__git_merge_strategies'
-    push.default:'action git push should take if no refspec is given::->push.default'
+    push.default:'action git push should take if no refspec is given::->push.default:matching'
     rebase.stat:'show a diffstat of what changed upstream since last rebase::->bool:false'
     rebase.autosquash:'autosquash by default::->bool:false'
     receive.autogc:'run git gc --auto after receiving data::->bool:true'
@@ -1989,6 +2047,7 @@ _git-config () {
     sendemail.bcc:'value of Bcc\: header::_email_addresses'
     sendemail.cc:'value of Cc\: header::_email_addresses'
     sendemail.cccmd:'command to generate Cc\: header with:Cc\: command:_path_commands'
+    sendemail.toccmd:'command to generate To\: header with:To\: command:_path_commands'
     sendemail.chainreplyto:'send each email as a reply to the previous one::->bool:false'
     sendemail.confirm:'type of confirmation required before sending::->sendemail.confirm:auto'
     sendemail.envelopesender:'envelope sender to send emails as::_email_addresses'
@@ -2010,6 +2069,7 @@ _git-config () {
     'sendemail.*.bcc:value of Bcc\: header::_email_addresses'
     'sendemail.*.cc:value of Cc\: header::_email_addresses'
     'sendemail.*.cccmd:command to generate Cc\: header with:Cc\: command:_path_commands'
+    'sendemail.*.tocmd:command to generate To\: header with:To\: command:_path_commands'
     'sendemail.*.chainreplyto:send each email as a reply to the previous one::->bool:false'
     'sendemail.*.confirm:type of confirmation required before sending::->sendemail.confirm:auto'
     'sendemail.*.envelopesender:envelope sender to send emails as::_email_addresses'
@@ -2365,6 +2425,13 @@ _git-config () {
                 always:"always $parts[2]" \
                 {auto,true,yes,on}:$parts[2] && ret=0
               ;;
+            (commit.cleanup)
+              __git_config_values -- "$current" "$parts[5]" \
+                strip:'remove both whitespace and commentary lines' \
+                whitespace:'remove leading and trailing whitespace lines' \
+                verbatim:'no not change the commit message at all' \
+                default:'act as '\''strip'\'' if the message is to be edited and as '\''whitespace'\'' otherwise' && ret=0
+              ;;
             (compression)
               __git_compression_levels && ret=0
               ;;
@@ -2413,10 +2480,23 @@ _git-config () {
                 __git_guard_number 'number of days'
               fi
               ;;
+            (diff.algorithm)
+              __git_config_values -- "$current" "$parts[5]" \
+                default:'basic greedy diff algorithm' \
+                myers:'basic greedy diff algorithm' \
+                minimal:'spend extra time to make sure the smallest possible diff is produced' \
+                patience:'generate diffs with patience algorithm' \
+                histogram:'generate diffs with histogram algorithm' && ret=0
+              ;;
             (diff.renames)
               __git_config_booleans "$current" "$parts[5]" "$parts[2]" \
                 {copies,copy}:'try to detect both renames and copies' && ret=0
               ;;
+            (diff.submodule)
+              __git_config_values -- "$current" "$parts[5]" \
+                short:'show pairs of commit name' \
+                log:'list commits like git submodule does' && ret=0
+              ;;
             (encoding)
               __git_encodings && ret=0
               ;;
@@ -2446,12 +2526,25 @@ _git-config () {
                 SQLite:'use the SQLite database driver' \
                 Pg:'use the Pg database driver' && ret=0
               ;;
+            (grep.patternType)
+              __git_config_values -- "$current" "$parts[5]" \
+                basic:'use --basic-regexp' \
+                default:'use default' \
+                extended:'use --extended-regexp' \
+                fixed:'use --fixed-strings' \
+                perl:'use --perl-regexp' && ret=0
+              ;;
             (help.format)
               __git_config_values -- "$current" "$parts[5]" \
                 man:'use man' \
                 info:'use info' \
                 {web,html}:'use HTML' && ret=0
               ;;
+            (help.htmlpath)
+              _alternative \
+                'path::_files -/' \
+                'url::_urls' && ret=0
+              ;;
             (imap.authMethod)
               __git_config_values -- "$current" "$parts[5]" \
                 CRAM-MD5:'use CRAM-MD5' && ret=0
@@ -2472,9 +2565,9 @@ _git-config () {
               ;;
             (merge.verbosity)
               __git_config_values -t verbosity-levels -l 'verbosity level' -- "$current" "$parts[5]" \
-                0:'only final error message if conflicts were detected'
-                1:'conflicts'
-                2:'conflicts and file changes'
+                0:'only final error message if conflicts were detected' \
+                1:'conflicts' \
+                2:'conflicts and file changes' \
                 5:'debugging information' && ret=0
               ;;
             (notes.rewriteMode)
@@ -2490,7 +2583,8 @@ _git-config () {
               __git_config_values -- "$current" "$parts[5]" \
                 nothing:'do not push anything' \
                 matching:'push all matching branches' \
-                tracking:'push current branch to its upstream branch' \
+                upstream:'push current branch to its upstream branch' \
+                simple:'like upstream, but only if local and remote names are the same' \
                 current:'push current branch to branch of same name' && ret=0
               ;;
             (receive.denyCurrentBranch)
@@ -2893,11 +2987,13 @@ _git-blame () {
     '-S[use revs from revs-file]:revs-file:_files' \
     '--reverse[walk histor forward instead of backward]' \
     '(-p --porcelain)'{-p,--porcelain}'[show results designed for machine processing]' \
+    '--line-porcelain[show results designed for machine processing but show commit information for every line]' \
     '--incremental[show results incrementally for machine processing]' \
     '--contents[annotate against the given file if no rev is specified]: :_files' \
     '(-h --help)'{-h,--help}'[show help message]' \
     '-c[use same output format as git annotate]' \
     '--score-debug[output debugging information relating to -C and -M line movement]' \
+    '(-e --show-email)'{-e,--show-email}'[show the author email instead of the author name]' \
     '(-f --show-name)'{-f,--show-name}'[show the filename of the original commit]' \
     '(-n --show-number)'{-n,--show-number}'[show the line number in the original commit]' \
     '-s[suppress author name and timestamp]' \
@@ -2945,6 +3041,7 @@ _git-count-objects () {
 _git-difftool () {
   # TODO: Is this fine, or do we need to modify the context or similar?
   _git-diff \
+    '--dir-diff[diff a whole tree by prepare a temporary copy]' \
     '(-y --no-prompt --prompt)'{-y,--no-prompt}'[do not prompt before invocation of diff tool]' \
     '(-y --no-prompt)--prompt[prompt before invocation of diff tool]' \
     '(-t --tool -x --extcmd)'{-t,--tool=-}'[merge resolution program to use]: :__git_difftools' \
@@ -2957,6 +3054,8 @@ _git-fsck () {
   # TODO: -v is undocumented.
   _arguments -w -S -s \
     '--unreachable[show objects that are unreferenced in the object database]' \
+    '(--dangling --no-dangling)--dangling[print dangling objects (default)]' \
+    '(--dangling --no-dangling)--no-dangling[do not print dangling objects]' \
     '--root[show root nodes]' \
     '--tags[show tags]' \
     '--cache[consider objects recorded in the index as head nodes for reachability traces]' \
@@ -3040,7 +3139,8 @@ _git-rerere () {
         'clear[reset metadata used by rerere]' \
         'forget[resets metadata used by rerere for specific conflict]: :__git_cached_files' \
         'diff[output diffs for the current state of the resolution]' \
-        'status[like diff, but only output filesames]' \
+        'status[print paths with conflicts whose merge resolution rerere will record]' \
+        'remaining[print paths with conflicts that have not been autoresolved by rerere]' \
         'gc[prune old records of conflicted merges]' && ret=0
       ;;
   esac
@@ -3300,6 +3400,7 @@ _git-send-email () {
     '--smtp-server-port=[specify port to connect to SMTP server on]:smtp port:_ports' \
     '--smtp-user=[specify user to use for SMTP-AUTH]:smtp user:_users' \
     '--cc-cmd=[specify command to generate Cc\: header with]:Cc\: command:_path_commands' \
+    '--to-cmd=[specify command to generate To\: header with]:To\: command:_path_commands' \
     '(                 --no-chain-reply-to)--chain-reply-to[send each email as a reply to previous one]' \
     '(--chain-reply-to                    )--no-chain-reply-to[send all emails after first as replies to first one]' \
     '--identity=[specify configuration identity]: :__git_sendemail_identities' \
@@ -3593,8 +3694,6 @@ _git-apply () {
     '--unidiff-zero[disable unified-diff-context check]' \
     '--apply[apply patches that would otherwise not be applied]' \
     '--no-add[ignore additions made by the patch]' \
-    '*--exclude=[skip files matching specified pattern]:pattern' \
-    '*--include=[include files matching specified pattern]:pattern' \
     '--inaccurate-eof[work around missing-new-line-at-EOF bugs]' \
     '(-v --verbose)'{-v,--verbose}'[display progress on stderr]' \
     '--recount[do not trust line counts in hunk headers]' \
@@ -3784,9 +3883,10 @@ _git-prune-packed () {
 
 (( $+functions[_git-read-tree] )) ||
 _git-read-tree () {
-  local trivial_opt= aggressive_opt=
+  local trivial_opt= aggressive_opt= dryrun_opt=
 
   if (( words[(I)-m] )); then
+    dryrun_opt='--dry-run[report if a merge would fail without touching the index or the working tree]'
     trivial_opt='--trivial[restrict three-way merge to only happen if no file-level merging is required]'
     aggressive_opt='--aggressive[try harder to resolve merge conflicts]'
   fi
@@ -3810,6 +3910,7 @@ _git-read-tree () {
     '(-m         --prefix)--reset[perform a merge, not just a read, ignoring unmerged entries]' \
     '(-m --reset          2 3)--prefix=-[read the contents of specified tree-ish under specified directory]:prefix:_directories -r ""' \
     $ui_opts \
+    $dryrun_opt \
     '-v[display progress on standard error]' \
     $trivial_opt \
     $aggressive_opt \
@@ -3824,7 +3925,9 @@ _git-read-tree () {
 (( $+functions[_git-symbolic-ref] )) ||
 _git-symbolic-ref () {
   _arguments -w -S -s \
+    '(-d --delete)'{-d,--delete}'[delete symbolic ref]' \
     '(-q --quiet)'{-q,--quiet}'[do not issue error if specified name is not a symbolic ref]' \
+    '--short[shorten the ref name (eg. refs/heads/master -> master)]' \
     '-m[update reflog for specified name with specied reason]:reason for update' \
     ':symbolic reference:__git_heads' \
     ':: :__git_references'
@@ -4050,6 +4153,8 @@ _git-ls-remote () {
     '(-h --heads)'{-h,--heads}'[show only refs under refs/heads]' \
     '(-t --tags)'{-t,--tags}'[show only refs under refs/tags]' \
     '(-u --upload-pack)'{-u,--upload-pack=-}'[specify path to git-upload-pack on remote side]:remote path' \
+    '--exit-code[exit with status 2 when no matching refs are found in the remote repository]' \
+    '--get-url[expand the URL of the given repository taking into account any "url.<base>.insteadOf" config setting]' \
     ': :__git_any_repositories' \
     '*: :__git_references'
 }
@@ -4086,6 +4191,7 @@ _git-merge-base () {
   _arguments -w -S -s \
     '(-a --all)'{-a,--all}'[display all common ancestors]' \
     '--octopus[compute best common ancestors of all supplied commits]' \
+    '--is-ancestor[tell if A is ancestor of B (by exit status)]' \
     '(-)--independent[display minimal subset of supplied commits with same ancestors]' \
     ': :__git_commits' \
     '*: :__git_commits'
@@ -4202,6 +4308,7 @@ _git-daemon () {
   # TODO: --interpolated-path should complete %H, %CH, %IP, %P, and %D.
   _arguments -S \
     '--strict-paths[match paths exactly]' \
+    '--access-hook=-[allow an external tool to accept or decline service]:path:_directories' \
     '--base-path=-[remap all the path requests as relative to the given path]:path:_directories' \
     '--base-path-relaxed[allow lookup of base path witout prefix]' \
     '--interpolated-path=-[dynamically construct alternate paths]:path:_directories' \
@@ -4390,7 +4497,9 @@ _git-check-attr () {
   fi
 
   _arguments -C \
+    {-a,--all}'[list all attributes that are associated with the specified paths]' \
     '--stdin[read file names from stdin instead of from command line]' \
+    '--cached[consider .gitattributes in the index only, ignoring the working tree.]' \
     $z_opt \
     '(-)--[interpret preceding arguments as attributes and following arguments as path names]' \
     '*:: :->attribute-or-file' && ret=0
@@ -5308,15 +5417,6 @@ __git_remote_references () {
   __git_references
 }
 
-(( $+functions[__git_note_references] )) ||
-__git_local_references () {
-  local references expl
-
-  references=(${${(M)${${(f)"$(_call_program references git ls-remote ./. 2>/dev/null)"}#*$'\t'}:#refs/notes/*}#refs/notes/})
-  __git_command_successful $pipestatus || return 1
-
-  _wanted references expl reference compadd - $references
-}
 (( $+functions[__git_notes_refs] )) ||
 __git_notes_refs () {
   local expl
@@ -5600,6 +5700,8 @@ __git_setup_log_options () {
     '(- *)-h[display help]'
     '(           --no-decorate)--decorate=-[print out ref names of any commits that are shown]: :__git_log_decorate_formats'
     '(--decorate              )--no-decorate[do not print out ref names of any commits that are shown]'
+    '(          --no-follow)--follow[follow renames]'
+    '(--follow             )--no-follow[do not follow renames]'
     '--source[show which ref each commit is reached from]')
 }
 
@@ -5612,7 +5714,14 @@ __git_setup_diff_options () {
     $diff_types{-U,--unified=}'[generate diff with given lines of context]: :__git_guard_number lines'
     $diff_types'--raw[generate default raw diff output]'
     $diff_types'--patch-with-raw[generate patch but also keep the default raw diff output]'
-    '--patience[generate diffs with patience algorithm]'
+    '(--minimal --patience --histogram --diff-algorithm)--minimal[spend extra time to make sure the smallest possible diff is producedm]'
+    '(--minimal --patience --histogram --diff-algorithm)--patience[generate diffs with patience algorithm]'
+    '(--minimal --patience --histogram --diff-algorithm)--histogram[generate diffs with histogram algorithm]'
+    '(--minimal --patience --histogram --diff-algorithm)--diff-algorithm=[choose a diff algorithm]:diff algorithm:((default\:"basic greedy diff algorithm"
+                                                                                                                    myers\:"basic greedy diff algorithm"
+                                                                                                                    minimal\:"spend extra time to make sure the smallest possible diff is produced"
+                                                                                                                    patience\:"generate diffs with patience algorithm"
+                                                                                                                    histogram\:"generate diffs with histogram algorithm"))'
     $diff_types'--stat=-[generate diffstat instead of patch]:: :__git_guard_diff-stat-width'
     $diff_types'--numstat[generate more machine-friendly diffstat]'
     $diff_types'--shortstat[generate summary diffstat]'
@@ -5624,7 +5733,7 @@ __git_setup_diff_options () {
     $diff_types'--name-only[show only names of changed files]'
     $diff_types'--name-status[show only names and status of changed files]'
     '--submodule=-[select output format for submodule differences]::format:((short\:"show pairs of commit names"
-                                                                            log\:"list commits like git submodule does (default)"))'
+                                                                            log\:"list commits like git submodule does"))'
     '(        --no-color --color-words)--color=-[show colored diff]:: :__git_color_whens'
     '(--color            --color-words)--no-color[turn off colored diff]'
     '--word-diff=-[show word diff]::mode:((color\:"highlight changed words using color"
@@ -5676,8 +5785,6 @@ __git_setup_diff_options () {
 
     # TODO: --cumulative is undocumented.
     '--cumulative[undocumented]'
-    # TODO: --follow is undocumented.
-    '--follow[undocumented]'
     # TODO: --textconv is undocumented.
     '--textconv[undocumented]'
     # TODO: --no-textconv is undocumented.
@@ -5708,10 +5815,9 @@ __git_setup_revision_options () {
     '--abbrev-commit[show only partial prefixes of commit object names]'
     '--oneline[shorthand for --pretty=oneline --abbrev-commit]'
     '--encoding=-[output log messages in given encoding]:: :__git_encodings'
-    '(--no-notes --show-notes --standard-notes --no-standard-notes)--no-notes[do not show notes that annotate commit]'
-    '(--no-notes --show-notes --standard-notes --no-standard-notes)--show-notes[do not show notes that annotate commit]:: :__git_note_references'
-    '(--no-notes --show-notes --standard-notes --no-standard-notes)--no-standard-notes[enable populating notes ref list from core.notesRef and notes.displayRef]'
-    '(--no-notes --show-notes --standard-notes --no-standard-notes)--no-standard-notes[disable populating notes ref list from core.notesRef and notes.displayRef]'
+    '(--no-notes --notes)--no-notes[do not show notes that annotate commit]'
+    '(--no-notes        )*--notes=[show notes that annotate commit, with optional ref argument show this notes ref instead of the default notes ref(s)]:: :__git_notes_refs'
+    '--show-signature[validate GPG signature of commit]'
     '(                --date)--relative-date[show dates relative to current time]'
     '(--relative-date       )--date=-[format of date output]: :__git_date_formats'
     '--parents[display parents of commit]'
@@ -5743,8 +5849,8 @@ __git_setup_revision_options () {
     '--remotes=[-show all commits from refs/remotes]::pattern'
     '--glob=[show all commits from refs matching glob]:pattern'
     '--stdin[read commit objects from standard input]'
-    '--cherry-pick[omit any same-change commits]'
     '(-g --walk-reflogs --reverse)'{-g,--walk-reflogs}'[walk reflog entries from most recent to oldest]'
+    '--grep-reflog=[limit commits to ones whose reflog message matches the given pattern (with -g, --walk-reflogs)]:pattern'
     '--merge[after a failed merge, show refs that touch files having a conflict]'
     '--boundary[output uninteresting commits at boundary]'
     '--simplify-by-decoration[show only commits that are referenced by a ref]'
@@ -5760,21 +5866,26 @@ __git_setup_revision_options () {
     '(--objects               )--objects-edge[display object ids of objects referenced by listed and excluded commits]'
     '(          --do-walk)--no-walk[only display given revs, do not traverse their ancestors]'
     '(--no-walk          )--do-walk[only display given revs, traversing their ancestors]'
+    '(              --cherry-pick)--cherry-mark[like --cherry-pick but mark equivalent commits instead of omitting them]'
+    '(--cherry-pick              )--cherry-pick[omit any commit that introduces the same change as another commit on "the other side" of a symmetric range]'
+    '(            --right-only)--left-only[list only commits on the left side of a symmetric range]'
+    '(--left-only             )--right-only[list only commits on the right side of a symmetric range]'
+    '(--left-only --right-only --cherry-pick --cherry-mark)--cherry[synonym for --right-only --cherry-mark --no-merges]'
+    '(-c --cc            )--full-diff[show full commit diffs when using log -p, not only those affecting the given path]'
+    '--log-size[print log message size in bytes before the message]'
+    '--use-mailmap[use mailmap file to map author and committer names and email]'
 
     # TODO: --reflog is undocumented.
     '--reflog[show all commits from reflogs]'
     # TODO: --default is undocumented.
     '--default[use argument as default revision]:default revision:__git_revisions'
-    # TODO: --full-diff is undocumented.
-    '(-c --cc            )--full-diff[undocumented]'
     # TODO: --abrev is undocumented.
     '--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length'
     # TODO: --no-abbrev is undocumented.
     '--no-abbrev[undocumented]'
     # TODO: --early-output is undocumented.
     '--early-output=-[undocumented]::undocumented'
-    # TODO: --log-size is undocumented.
-    '--log-size[undocumented]')
+    )
 
   if (( words[(I)--objects(|-edge)] )); then
     revision_options+=('--unpacked[print object IDs not in packs]')
@@ -5786,6 +5897,8 @@ __git_setup_merge_options () {
   merge_options=(
     '(         --no-commit)--commit[perform the merge and commit the result]'
     '(--commit            )--no-commit[perform the merge but do not commit the result]'
+    '(         --no-edit)--edit[open an editor to change the commit message]'
+    '(--edit            )--no-edit[do not open an editor to change the commit message]'
     '(     --no-ff)--ff[do not generate a merge commit if the merge resolved as a fast-forward]'
     '(--ff        )--no-ff[generate a merge commit even if the merge resolved as a fast-forward]'
     '(      --no-log)--log[fill in one-line descriptions of the commits being merged in the log message]'
@@ -5807,6 +5920,7 @@ __git_setup_fetch_options () {
     '(: *)--all[fetch all remotes]'
     '(-a --append)'{-a,--append}'[append ref names and object names of fetched refs to "$GIT_DIR/FETCH_HEAD"]'
     '--depth=[deepen the history of a shallow repository by the given number of commits]: :__git_guard_number depth'
+    '--unshallow[convert a shallow clone to a complete one]'
     '--dry-run[show what would be done, without making any changes]'
     '(-f --force)'{-f,--force}'[allow refs that are not ancestors to be updated]'
     '(-k --keep)'{-k,--keep}'[keep downloaded pack]'
@@ -5815,6 +5929,10 @@ __git_setup_fetch_options () {
     '(--no-tags -t --tags)'{-t,--tags}'[fetch remote tags]'
     '(-u --update-head-ok)'{-u,--update-head-ok}'[allow updates of current branch head]'
     '--upload-pack=[specify path to git-upload-pack on remote side]:remote path'
+    '(--no-recurse-submodules --recurse-submodules)--recurse-submodules=[specify when to fetch commits of submodules]:recursive fetching mode:((no\:"disable recursion"
+                                                                                                                                                yes\:"always recurse"
+                                                                                                                                                on-demand\:"only when submodule reference in superproject is updated"))'
+    '(--no-recurse-submodules --recurse-submodules)--no-recurse-submodules[disable recursive fetching of submodules]'
     '(-q --quiet -v --verbose --progress)'{-q,--quiet}'[suppress all output]'
     '(-q --quiet -v --verbose)'{-v,--verbose}'[output additional information]'
     '(-q --quiet)--progress[output progress information]')
@@ -5828,7 +5946,10 @@ __git_setup_apply_options () {
     '-C-[ensure at least N lines of context match before and after each change]: :_guard  "[[\:digit\:]]#" "number of lines of context"'
     '--reject[apply hunks that apply and leave rejected hunks in .rej files]'
     '(--ignore-space-change --ignore-whitespace)'{--ignore-space-change,--ignore-whitespace}'[ignore changes in whitespace in context lines]'
-    '--directory=[root to prepend to all filenames]:root:_directories')
+    '--directory=[root to prepend to all filenames]:root:_directories'
+    '*--exclude=[skip files matching specified pattern]:pattern'
+    '*--include=[include files matching specified pattern]:pattern'
+    )
 }
 
 # Git Config Helpers
@@ -6085,6 +6206,7 @@ __git_sendemail_suppresscc_values () {
     bodycc:'avoid including anyone mentiond in Cc lines in patch body except for self' \
     sob:'avoid including anyone mentiond in Signed-off-by lines except for self' \
     cccmd:'avoid running --cc-cmd' \
+    tocmd:'avoid running --to-cmd' \
     body:'equivalent to sob + bodycc' \
     all:'avoid all auto Cc values'
 }
-- 
1.8.2.2


^ permalink raw reply	[relevance 3%]

* Important discussion about "local" on the POSIX list
@ 2013-10-17  0:27  8% Bart Schaefer
  2013-10-17  0:51  5% ` Chet Ramey
  2013-10-17  9:06  5% ` Peter Stephenson
  0 siblings, 2 replies; 200+ results
From: Bart Schaefer @ 2013-10-17  0:27 UTC (permalink / raw)
  To: Zsh hackers list

austin-group is discussing a proposal to make local variables
lexical/static in scope, rather than dynamic in scope as in bash and
zsh.

I don't seem to be able to post to that list, so if there's someone
here who still can, please have a gander and chime it.

The discussion ranges over

(1) whether "function name { ... }" vs. "name() { ... }" syntax
determines whether a variable defined within the function has static
scope (ksh93) and the keyword used to declare it is irrelevant;

(2) whether "typeset" or "local" or something else would be used to
declare such variables;

(3) whether "local" would be allowed to have dynamic scope at all.

It would be rather difficult in zsh's implementation to enforce
lexical scoping, so we'd be faced with either giving up POSIX
compliance or doing a massive rewrite.


^ permalink raw reply	[relevance 8%]

* Re: Important discussion about "local" on the POSIX list
  2013-10-17  0:27  8% Important discussion about "local" on the POSIX list Bart Schaefer
@ 2013-10-17  0:51  5% ` Chet Ramey
  2013-10-17  9:06  5% ` Peter Stephenson
  1 sibling, 0 replies; 200+ results
From: Chet Ramey @ 2013-10-17  0:51 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh hackers list, chet.ramey

On 10/16/13 8:27 PM, Bart Schaefer wrote:
> austin-group is discussing a proposal to make local variables
> lexical/static in scope, rather than dynamic in scope as in bash and
> zsh.

I will object to any change that requires static scoping.  At worst,
scoping rules will be undefined.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/


^ permalink raw reply	[relevance 5%]

* Re: Important discussion about "local" on the POSIX list
  2013-10-17  0:27  8% Important discussion about "local" on the POSIX list Bart Schaefer
  2013-10-17  0:51  5% ` Chet Ramey
@ 2013-10-17  9:06  5% ` Peter Stephenson
  1 sibling, 0 replies; 200+ results
From: Peter Stephenson @ 2013-10-17  9:06 UTC (permalink / raw)
  To: Zsh hackers list

On Wed, 16 Oct 2013 17:27:34 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> austin-group is discussing a proposal to make local variables
> lexical/static in scope, rather than dynamic in scope as in bash and
> zsh.
> 
> I don't seem to be able to post to that list, so if there's someone
> here who still can, please have a gander and chime it.

I'm not on that list at the moment --- I didn't sign up again when I got
transferred from CSR.

> It would be rather difficult in zsh's implementation to enforce
> lexical scoping, so we'd be faced with either giving up POSIX
> compliance or doing a massive rewrite.

It does seem unlikely we'd be implementing lexical scoping.

If we ever did, it would have to be an option.  The assumption that we
can address local variables in enclosing functions is very widely made
in function suites, presumably including many we never see.

pws


^ permalink raw reply	[relevance 5%]

* completion file for the command 'cat'
@ 2013-10-27 16:06  3% Jun T.
  0 siblings, 0 replies; 200+ results
From: Jun T. @ 2013-10-27 16:06 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 124 bytes --]

Attached is a completion function for the command 'cat'.

Only Linux and Mac OS X (and relatives) are supported seriously.


[-- Attachment #2: _cat --]
[-- Type: application/octet-stream, Size: 1444 bytes --]

#compdef cat

local -a args

if _pick_variant gnu=GNU unix --version; then
  args=(
    '(-A --show-all)'{-A,--show-all}'[equivalent to -vET]'
    '(-b --number-nonblank -n --number)'{-b,--number-nonblank}'[number nonempty output lines, overrides -n]'
    '-e[equivalent to -vE]'
    '(-E --show-ends)'{-E,--show-ends}'[display $ at end of each line]'
    '(-n --number)'{-n,--number}'[number all output lines]'
    '(-s --squeeze-blank)'{-s,--squeeze-blank}'[suppress repeated empty output lines]'
    '-t[equivalent to -vT]'
    '(-T --show-tabs)'{-T,--show-tabs}'[display TAB characters as ^I]'
    '-u[ignored]'
    '(-v --show-nonprinting)'{-v,--show-nonprinting}'[use ^ and M- notation, except for LFD and TAB]'
    '(- : *)--help[display help and exit]'
    '(- : *)--version[output version information and exit]'
    '*:files:_files'
  )

elif [[ "$OSTYPE" == (freebsd|dragonfly|darwin)* ]]; then
  args=(
    '(-n)-b[number non-blank output lines]'
    '(-v)-e[display $ at the end of each line (implies -v)]'
    '-n[number all output lines]'
    '-s[squeeze multiple blank lines into one]'
    '(-v)-t[display tab as ^I (implies -v)]'
    '-u[do not buffer output]'
    '-v[display non-printing chars as ^X or M-a]'
    '(-)*:files:_files'
  )

else
  # POSIX reqires '-u', and most OSes may support '-n'
  args=(
    '-n[number all output lines]'
    '-u[do not buffer output]'
    '*:files:_files'
  )
fi

_arguments -s -S : $args

^ permalink raw reply	[relevance 3%]

* PATCH: add more ulimit extensions from BSDs
@ 2013-10-30  1:33  4% Stefan Neudorf
    0 siblings, 1 reply; 200+ results
From: Stefan Neudorf @ 2013-10-30  1:33 UTC (permalink / raw)
  To: zsh-workers

On FreeBSD 10, ulimit -a shows at the end

  -N 11:                              unlimited
  -N 12:                              unlimited
  -N 13:                              unlimited

while sh's ulimit -a describes them as

  pseudo-terminals                (-p)  unlimited
  swap limit              (kbytes, -w)  unlimited
  kqueues                         (-k)  unlimited

and DragonFly only has

  posixlocks                      (-k)  unlimited

---
 Doc/Zsh/builtins.yo      |  4 ++++
 Src/Builtins/rlimits.awk |  4 ++++
 Src/Builtins/rlimits.c   | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac             |  4 ++++
 4 files changed, 58 insertions(+)

diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 6f33c02..54455a4 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -1013,6 +1013,10 @@ sitem(tt(sigpending))(Maximum number of pending signals.)
 sitem(tt(sockbufsize))(Maximum size of all socket buffers.)
 sitem(tt(stacksize))(Maximum stack size for each process.)
 sitem(tt(vmemorysize))(Maximum amount of virtual memory.)
+sitem(tt(posixlocks))(Maximum number of POSIX locks per user.)
+sitem(tt(pseudoterminals))(Maximum number of pseudo-terminals.)
+sitem(tt(swapuse))(Maximum amount of swap used.)
+sitem(tt(kqueues))(Maximum number of kqueues allocated.)
 endsitem()
 
 Which of these resource limits are available depends on the system.
diff --git a/Src/Builtins/rlimits.awk b/Src/Builtins/rlimits.awk
index bf91481..ccee49e 100644
--- a/Src/Builtins/rlimits.awk
+++ b/Src/Builtins/rlimits.awk
@@ -55,6 +55,10 @@ BEGIN {limidx = 0}
 	    if (limnam == "NICE") { msg[limnum] = "Nnice" }
 	    if (limnam == "RTPRIO") { msg[limnum] = "Nrt_priority" }
 	    if (limnam == "RTTIME") { msg[limnum] = "Urt_time" }
+	    if (limnam == "POSIXLOCKS") { msg[limnum] = "Nposixlocks" }
+	    if (limnam == "NPTS")    { msg[limnum] = "Npseudoterminals" }
+	    if (limnam == "SWAP")    { msg[limnum] = "Mswapuse" }
+	    if (limnam == "KQUEUES") { msg[limnum] = "Nkqueues" }
         }
     }
 }
diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c
index eedfa96..3095109 100644
--- a/Src/Builtins/rlimits.c
+++ b/Src/Builtins/rlimits.c
@@ -386,6 +386,32 @@ printulimit(char *nam, int lim, int hard, int head)
 	    printf("-r: max rt priority                 ");
 	break;
 # endif /* HAVE_RLIMIT_RTPRIO */
+# ifdef HAVE_RLIMIT_POSIXLOCKS
+    case RLIMIT_POSIXLOCKS:
+	if (head)
+	    printf("-k: posixlocks                      ");
+	break;
+# endif /* HAVE_RLIMIT_POSIXLOCKS */
+# ifdef HAVE_RLIMIT_NPTS
+    case RLIMIT_NPTS:
+	if (head)
+	    printf("-p: pseudo-terminals                ");
+	break;
+# endif /* HAVE_RLIMIT_NPTS */
+# ifdef HAVE_RLIMIT_SWAP
+    case RLIMIT_SWAP:
+	if (head)
+	    printf("-w: swap limit (kbytes)             ");
+	if (limit != RLIM_INFINITY)
+	    limit /= 1024;
+	break;
+# endif /* HAVE_RLIMIT_SWAP */
+# ifdef HAVE_RLIMIT_KQUEUES
+    case RLIMIT_KQUEUES:
+	if (head)
+	    printf("-k: kqueues                         ");
+	break;
+# endif /* HAVE_RLIMIT_KQUEUES */
     default:
 	if (head)
 	    printf("-N %2d:                              ", lim);
@@ -844,6 +870,26 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
 		    res = RLIMIT_RTPRIO;
 		    break;
 # endif
+# ifdef HAVE_RLIMIT_POSIXLOCKS
+		case 'k':
+		    res = RLIMIT_POSIXLOCKS;
+		    break;
+# endif
+# ifdef HAVE_RLIMIT_NPTS
+		case 'p':
+		    res = RLIMIT_NPTS;
+		    break;
+# endif
+# ifdef HAVE_RLIMIT_SWAP
+		case 'w':
+		    res = RLIMIT_SWAP;
+		    break;
+# endif
+# ifdef HAVE_RLIMIT_KQUEUES
+		case 'k':
+		    res = RLIMIT_KQUEUES;
+		    break;
+# endif
 		default:
 		    /* unrecognised limit */
 		    zwarnnam(name, "bad option: -%c", *options);
diff --git a/configure.ac b/configure.ac
index c3093f2..32872be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1812,6 +1812,10 @@ zsh_LIMIT_PRESENT(RLIMIT_SIGPENDING)
 zsh_LIMIT_PRESENT(RLIMIT_MSGQUEUE)
 zsh_LIMIT_PRESENT(RLIMIT_NICE)
 zsh_LIMIT_PRESENT(RLIMIT_RTPRIO)
+zsh_LIMIT_PRESENT(RLIMIT_POSIXLOCKS)
+zsh_LIMIT_PRESENT(RLIMIT_NPTS)
+zsh_LIMIT_PRESENT(RLIMIT_SWAP)
+zsh_LIMIT_PRESENT(RLIMIT_KQUEUES)
 
 AH_TEMPLATE([RLIMIT_VMEM_IS_RSS],
 [Define to 1 if RLIMIT_VMEM and RLIMIT_RSS both exist and are equal.])


^ permalink raw reply	[relevance 4%]

* Re: PATCH: add more ulimit extensions from BSDs
  @ 2013-10-31 20:10  9%       ` Peter Stephenson
  0 siblings, 0 replies; 200+ results
From: Peter Stephenson @ 2013-10-31 20:10 UTC (permalink / raw)
  To: zsh-workers

On Thu, 31 Oct 2013 11:33:07 +0000
Peter Stephenson <p.stephenson@samsung.com> wrote:
> In the absence of other suggestions I think I'll just turn posixlocks
> into -K (but note the incompatibility in the manual).

Done, with some additional documentation for ulimit.

diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 6f33c02..f33685b 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -1013,6 +1013,10 @@ sitem(tt(sigpending))(Maximum number of pending signals.)
 sitem(tt(sockbufsize))(Maximum size of all socket buffers.)
 sitem(tt(stacksize))(Maximum stack size for each process.)
 sitem(tt(vmemorysize))(Maximum amount of virtual memory.)
+sitem(tt(posixlocks))(Maximum number of POSIX locks per user.)
+sitem(tt(pseudoterminals))(Maximum number of pseudo-terminals.)
+sitem(tt(swapuse))(Maximum amount of swap used.)
+sitem(tt(kqueues))(Maximum number of kqueues allocated.)
 endsitem()
 
 Which of these resource limits are available depends on the system.
@@ -1893,7 +1897,7 @@ enditem()
 findex(ulimit)
 cindex(resource limits)
 cindex(limits, resource)
-item(tt(ulimit) [ [ tt(-SHacdfilmnpqrstvx) | tt(-N) var(resource) [ var(limit) ] ... ])(
+item(tt(ulimit) [ [ tt(-SHacdfikKlmnpqrstvwx) | tt(-N) var(resource) [ var(limit) ] ... ])(
 Set or display resource limits of the shell and the processes started by
 the shell.  The value of var(limit) can be a number in the unit specified
 below or one of the values `tt(unlimited)', which removes the limit on the
@@ -1924,9 +1928,13 @@ sitem(tt(-c))(512-byte blocks on the size of core dumps.)
 sitem(tt(-d))(Kilobytes on the size of the data segment.)
 sitem(tt(-f))(512-byte blocks on the size of files written.)
 sitem(tt(-i))(The number of pending signals.)
+sitem(tt(-k))(Maximum number of kqueues allocated.)
+sitem(tt(-K))(Maximum number of POSIX locks per user.  Note this is
+tt(-k) in some other shells.)
 sitem(tt(-l))(Kilobytes on the size of locked-in memory.)
 sitem(tt(-m))(Kilobytes on the size of physical memory.)
 sitem(tt(-n))(open file descriptors.)
+sitem(tt(-p))(Maximum number of pseudo-terminals.)
 sitem(tt(-q))(Bytes in POSIX message queues.)
 sitem(tt(-s))(Kilobytes on the size of the stack.)
 sitem(tt(-t))(CPU seconds to be used.)
@@ -1934,6 +1942,7 @@ sitem(tt(-r))(The number of simultaneous threads available to the user.)
 sitem(tt(-u))(The number of processes available to the user.)
 sitem(tt(-v))(Kilobytes on the size of virtual memory.  On some systems this
 refers to the limit called `address space'.)
+sitem(tt(-w))(Maximum amount of swap memory.)
 sitem(tt(-x))(The number of locks on files.)
 endsitem()
 
diff --git a/Src/Builtins/rlimits.awk b/Src/Builtins/rlimits.awk
index bf91481..ccee49e 100644
--- a/Src/Builtins/rlimits.awk
+++ b/Src/Builtins/rlimits.awk
@@ -55,6 +55,10 @@ BEGIN {limidx = 0}
 	    if (limnam == "NICE") { msg[limnum] = "Nnice" }
 	    if (limnam == "RTPRIO") { msg[limnum] = "Nrt_priority" }
 	    if (limnam == "RTTIME") { msg[limnum] = "Urt_time" }
+	    if (limnam == "POSIXLOCKS") { msg[limnum] = "Nposixlocks" }
+	    if (limnam == "NPTS")    { msg[limnum] = "Npseudoterminals" }
+	    if (limnam == "SWAP")    { msg[limnum] = "Mswapuse" }
+	    if (limnam == "KQUEUES") { msg[limnum] = "Nkqueues" }
         }
     }
 }
diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c
index eedfa96..a0f2948 100644
--- a/Src/Builtins/rlimits.c
+++ b/Src/Builtins/rlimits.c
@@ -386,6 +386,32 @@ printulimit(char *nam, int lim, int hard, int head)
 	    printf("-r: max rt priority                 ");
 	break;
 # endif /* HAVE_RLIMIT_RTPRIO */
+# ifdef HAVE_RLIMIT_POSIXLOCKS
+    case RLIMIT_POSIXLOCKS:
+	if (head)
+	    printf("-K: posixlocks                      ");
+	break;
+# endif /* HAVE_RLIMIT_POSIXLOCKS */
+# ifdef HAVE_RLIMIT_NPTS
+    case RLIMIT_NPTS:
+	if (head)
+	    printf("-p: pseudo-terminals                ");
+	break;
+# endif /* HAVE_RLIMIT_NPTS */
+# ifdef HAVE_RLIMIT_SWAP
+    case RLIMIT_SWAP:
+	if (head)
+	    printf("-w: swap limit (kbytes)             ");
+	if (limit != RLIM_INFINITY)
+	    limit /= 1024;
+	break;
+# endif /* HAVE_RLIMIT_SWAP */
+# ifdef HAVE_RLIMIT_KQUEUES
+    case RLIMIT_KQUEUES:
+	if (head)
+	    printf("-k: kqueues                         ");
+	break;
+# endif /* HAVE_RLIMIT_KQUEUES */
     default:
 	if (head)
 	    printf("-N %2d:                              ", lim);
@@ -844,6 +870,26 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
 		    res = RLIMIT_RTPRIO;
 		    break;
 # endif
+# ifdef HAVE_RLIMIT_POSIXLOCKS
+		case 'K':
+		    res = RLIMIT_POSIXLOCKS;
+		    break;
+# endif
+# ifdef HAVE_RLIMIT_NPTS
+		case 'p':
+		    res = RLIMIT_NPTS;
+		    break;
+# endif
+# ifdef HAVE_RLIMIT_SWAP
+		case 'w':
+		    res = RLIMIT_SWAP;
+		    break;
+# endif
+# ifdef HAVE_RLIMIT_KQUEUES
+		case 'k':
+		    res = RLIMIT_KQUEUES;
+		    break;
+# endif
 		default:
 		    /* unrecognised limit */
 		    zwarnnam(name, "bad option: -%c", *options);
diff --git a/configure.ac b/configure.ac
index c3093f2..32872be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1812,6 +1812,10 @@ zsh_LIMIT_PRESENT(RLIMIT_SIGPENDING)
 zsh_LIMIT_PRESENT(RLIMIT_MSGQUEUE)
 zsh_LIMIT_PRESENT(RLIMIT_NICE)
 zsh_LIMIT_PRESENT(RLIMIT_RTPRIO)
+zsh_LIMIT_PRESENT(RLIMIT_POSIXLOCKS)
+zsh_LIMIT_PRESENT(RLIMIT_NPTS)
+zsh_LIMIT_PRESENT(RLIMIT_SWAP)
+zsh_LIMIT_PRESENT(RLIMIT_KQUEUES)
 
 AH_TEMPLATE([RLIMIT_VMEM_IS_RSS],
 [Define to 1 if RLIMIT_VMEM and RLIMIT_RSS both exist and are equal.])

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


^ permalink raw reply	[relevance 9%]

* PATCH: Re: add more ulimit extensions from BSDs
    @ 2013-10-31 23:09  9%     ` Stefan Neudorf
  1 sibling, 0 replies; 200+ results
From: Stefan Neudorf @ 2013-10-31 23:09 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer <schaefer@brasslantern.com> writes:

> On Oct 30, 10:59am, Peter Stephenson wrote:
> } Subject: Re: PATCH: add more ulimit extensions from BSDs
> }
> } > while sh's ulimit -a describes them as
> } > 
> } >   kqueues                         (-k)  unlimited
> } > 
> } > and DragonFly only has
> } > 
> } >   posixlocks                      (-k)  unlimited
> } 
> } Thanks for the changes... are we sure that posixlocks and kqueues are
> } mutually incompatible, or should we move one to -K via #define's if both
> } exist?
>
> It makes me nervous to have two limits on the same option letter even if
> they are not mutually incompatible.  Lots of people (including me) have
> "portable" RC files.

Here's incomplete list of quirks:

  ulimit:
   -T maxpthreads (bash) vs. -N X maxpthreads (zsh)[*]
   -p pipesize (any bash) vs. -p pseudoterminals (freebsd sh)
   -r threads (netbsd sh) vs. -r rt_priority (linux bash, zsh)[*]
   -k posixlocks (dragonfly sh) vs. -k kqueues (freebsd sh)
  limit:
   maxthread (login.conf) vs. threads (tcsh) vs. maxthr (zsh)
   sbsize (login.conf, tcsh) vs. sockbufsize (zsh)
   swapuse (login.conf) vs. swapsize (tcsh)
   vmemoryuse (tcsh, login.conf) vs. vmemorysize (zsh)

After discussing a bit on FreeBSD side and looking at a patch for bash
I'd go with re-using an existing -x option letter and fix [*] as well.

http://lists.freebsd.org/pipermail/svn-src-head/2013-October/052947.html
http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/shells/bash/patches/patch-builtins_ulimit.def

> On Thu, 31 Oct 2013 11:33:07 +0000
> Peter Stephenson <p.stephenson@samsung.com> wrote:
>
>> In the absence of other suggestions I think I'll just turn posixlocks
>> into -K (but note the incompatibility in the manual).
>
> Done, with some additional documentation for ulimit.
>
> @@ -1893,7 +1897,7 @@ enditem()
>  findex(ulimit)
>  cindex(resource limits)
>  cindex(limits, resource)
> -item(tt(ulimit) [ [ tt(-SHacdfilmnpqrstvx) | tt(-N) var(resource) [ var(limit) ] ... ])(
> +item(tt(ulimit) [ [ tt(-SHacdfikKlmnpqrstvwx) | tt(-N) var(resource) [ var(limit) ] ... ])(

Thanks. I've missed usage line.

>  Set or display resource limits of the shell and the processes started by
>  the shell.  The value of var(limit) can be a number in the unit specified
>  below or one of the values `tt(unlimited)', which removes the limit on the
> @@ -1924,9 +1928,13 @@ sitem(tt(-c))(512-byte blocks on the size of core dumps.)
>  sitem(tt(-d))(Kilobytes on the size of the data segment.)
>  sitem(tt(-f))(512-byte blocks on the size of files written.)
>  sitem(tt(-i))(The number of pending signals.)
> +sitem(tt(-k))(Maximum number of kqueues allocated.)
> +sitem(tt(-K))(Maximum number of POSIX locks per user.  Note this is
> +tt(-k) in some other shells.)
>  sitem(tt(-l))(Kilobytes on the size of locked-in memory.)
>  sitem(tt(-m))(Kilobytes on the size of physical memory.)
>  sitem(tt(-n))(open file descriptors.)
> +sitem(tt(-p))(Maximum number of pseudo-terminals.)
>  sitem(tt(-q))(Bytes in POSIX message queues.)
>  sitem(tt(-s))(Kilobytes on the size of the stack.)
>  sitem(tt(-t))(CPU seconds to be used.)

Not consitent with the wording for other options.

---
 Doc/Zsh/builtins.yo      |  9 ++++++++-
 Src/Builtins/rlimits.awk |  4 ++++
 Src/Builtins/rlimits.c   | 39 +++++++++++++++++++++++++++++++++++++++
 configure.ac             |  4 ++++
 4 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 6f33c02..7927232 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -1003,15 +1003,19 @@ sitem(tt(cputime))(Maximum CPU seconds per process.)
 sitem(tt(datasize))(Maximum data size (including stack) for each process.)
 sitem(tt(descriptors))(Maximum value for a file descriptor.)
 sitem(tt(filesize))(Largest single file allowed.)
+sitem(tt(kqueues))(Maximum number of kqueues allocated.)
 sitem(tt(maxproc))(Maximum number of processes.)
 sitem(tt(maxpthreads))(Maximum number of threads per process.)
 sitem(tt(memorylocked))(Maximum amount of memory locked in RAM.)
 sitem(tt(memoryuse))(Maximum resident set size.)
 sitem(tt(msgqueue))(Maximum number of bytes in POSIX message queues.)
+sitem(tt(posixlocks))(Maximum number of POSIX advisory locks.)
+sitem(tt(pseudoterminals))(Maximum number of pseudo-terminals.)
 sitem(tt(resident))(Maximum resident set size.)
 sitem(tt(sigpending))(Maximum number of pending signals.)
 sitem(tt(sockbufsize))(Maximum size of all socket buffers.)
 sitem(tt(stacksize))(Maximum stack size for each process.)
+sitem(tt(swapsize))(Maximum amount of swap used.)
 sitem(tt(vmemorysize))(Maximum amount of virtual memory.)
 endsitem()
 
@@ -1893,7 +1897,7 @@ enditem()
 findex(ulimit)
 cindex(resource limits)
 cindex(limits, resource)
-item(tt(ulimit) [ [ tt(-SHacdfilmnpqrstvx) | tt(-N) var(resource) [ var(limit) ] ... ])(
+item(tt(ulimit) [ [ tt(-SHacdfiklmnpqrstvwx) | tt(-N) var(resource) [ var(limit) ] ... ])(
 Set or display resource limits of the shell and the processes started by
 the shell.  The value of var(limit) can be a number in the unit specified
 below or one of the values `tt(unlimited)', which removes the limit on the
@@ -1924,9 +1928,11 @@ sitem(tt(-c))(512-byte blocks on the size of core dumps.)
 sitem(tt(-d))(Kilobytes on the size of the data segment.)
 sitem(tt(-f))(512-byte blocks on the size of files written.)
 sitem(tt(-i))(The number of pending signals.)
+sitem(tt(-k))(The number of kqueues allocated.)
 sitem(tt(-l))(Kilobytes on the size of locked-in memory.)
 sitem(tt(-m))(Kilobytes on the size of physical memory.)
 sitem(tt(-n))(open file descriptors.)
+sitem(tt(-p))(The number of pseudo-terminals.)
 sitem(tt(-q))(Bytes in POSIX message queues.)
 sitem(tt(-s))(Kilobytes on the size of the stack.)
 sitem(tt(-t))(CPU seconds to be used.)
@@ -1934,6 +1940,7 @@ sitem(tt(-r))(The number of simultaneous threads available to the user.)
 sitem(tt(-u))(The number of processes available to the user.)
 sitem(tt(-v))(Kilobytes on the size of virtual memory.  On some systems this
 refers to the limit called `address space'.)
+sitem(tt(-w))(Kilobytes on the size of swapped out memory.)
 sitem(tt(-x))(The number of locks on files.)
 endsitem()
 
diff --git a/Src/Builtins/rlimits.awk b/Src/Builtins/rlimits.awk
index bf91481..b5a25fd 100644
--- a/Src/Builtins/rlimits.awk
+++ b/Src/Builtins/rlimits.awk
@@ -55,6 +55,10 @@ BEGIN {limidx = 0}
 	    if (limnam == "NICE") { msg[limnum] = "Nnice" }
 	    if (limnam == "RTPRIO") { msg[limnum] = "Nrt_priority" }
 	    if (limnam == "RTTIME") { msg[limnum] = "Urt_time" }
+	    if (limnam == "POSIXLOCKS") { msg[limnum] = "Nposixlocks" }
+	    if (limnam == "NPTS")    { msg[limnum] = "Npseudoterminals" }
+	    if (limnam == "SWAP")    { msg[limnum] = "Mswapsize" }
+	    if (limnam == "KQUEUES") { msg[limnum] = "Nkqueues" }
         }
     }
 }
diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c
index eedfa96..e48a1d3 100644
--- a/Src/Builtins/rlimits.c
+++ b/Src/Builtins/rlimits.c
@@ -32,6 +32,10 @@
 
 #if defined(HAVE_GETRLIMIT) && defined(RLIM_INFINITY)
 
+#ifdef RLIMIT_POSIXLOCKS
+#  define RLIMIT_LOCKS		RLIMIT_POSIXLOCKS
+#endif
+
 enum {
     ZLIMTYPE_MEMORY,
     ZLIMTYPE_NUMBER,
@@ -386,6 +390,26 @@ printulimit(char *nam, int lim, int hard, int head)
 	    printf("-r: max rt priority                 ");
 	break;
 # endif /* HAVE_RLIMIT_RTPRIO */
+# ifdef HAVE_RLIMIT_NPTS
+    case RLIMIT_NPTS:
+	if (head)
+	    printf("-p: pseudo-terminals                ");
+	break;
+# endif /* HAVE_RLIMIT_NPTS */
+# ifdef HAVE_RLIMIT_SWAP
+    case RLIMIT_SWAP:
+	if (head)
+	    printf("-w: swap size (kbytes)              ");
+	if (limit != RLIM_INFINITY)
+	    limit /= 1024;
+	break;
+# endif /* HAVE_RLIMIT_SWAP */
+# ifdef HAVE_RLIMIT_KQUEUES
+    case RLIMIT_KQUEUES:
+	if (head)
+	    printf("-k: kqueues                         ");
+	break;
+# endif /* HAVE_RLIMIT_KQUEUES */
     default:
 	if (head)
 	    printf("-N %2d:                              ", lim);
@@ -844,6 +868,21 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
 		    res = RLIMIT_RTPRIO;
 		    break;
 # endif
+# ifdef HAVE_RLIMIT_NPTS
+		case 'p':
+		    res = RLIMIT_NPTS;
+		    break;
+# endif
+# ifdef HAVE_RLIMIT_SWAP
+		case 'w':
+		    res = RLIMIT_SWAP;
+		    break;
+# endif
+# ifdef HAVE_RLIMIT_KQUEUES
+		case 'k':
+		    res = RLIMIT_KQUEUES;
+		    break;
+# endif
 		default:
 		    /* unrecognised limit */
 		    zwarnnam(name, "bad option: -%c", *options);
diff --git a/configure.ac b/configure.ac
index c3093f2..32872be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1812,6 +1812,10 @@ zsh_LIMIT_PRESENT(RLIMIT_SIGPENDING)
 zsh_LIMIT_PRESENT(RLIMIT_MSGQUEUE)
 zsh_LIMIT_PRESENT(RLIMIT_NICE)
 zsh_LIMIT_PRESENT(RLIMIT_RTPRIO)
+zsh_LIMIT_PRESENT(RLIMIT_POSIXLOCKS)
+zsh_LIMIT_PRESENT(RLIMIT_NPTS)
+zsh_LIMIT_PRESENT(RLIMIT_SWAP)
+zsh_LIMIT_PRESENT(RLIMIT_KQUEUES)
 
 AH_TEMPLATE([RLIMIT_VMEM_IS_RSS],
 [Define to 1 if RLIMIT_VMEM and RLIMIT_RSS both exist and are equal.])


^ permalink raw reply	[relevance 9%]

* PATCH: assign threads ulimit -T flag like in bash
@ 2013-10-31 23:41  4% Stefan Neudorf
  0 siblings, 0 replies; 200+ results
From: Stefan Neudorf @ 2013-10-31 23:41 UTC (permalink / raw)
  To: zsh-workers

Currently limiting threads in zsh is done via either -N X maxpthreads or
-r maxthr. However, ulimit -r occupied by two limits: RLIMIT_RTPRIO and
RLIMIT_NTHR. And to make matter worse bash uses -T option letter.

This change renames -r maxthr to -T maxpthread given that maxthr
csh-style limit wasn't documented in the zsh manpage. But maxpthread is
still different name from maxthread in login.conf or threads which tcsh
is going to use (my fault).

-r rt_priority as previously is left undocumented.

---
 Doc/Zsh/builtins.yo      |  4 ++--
 Src/Builtins/rlimits.awk |  2 +-
 Src/Builtins/rlimits.c   | 17 +++++------------
 3 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 7927232..4864e21 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -1897,7 +1897,7 @@ enditem()
 findex(ulimit)
 cindex(resource limits)
 cindex(limits, resource)
-item(tt(ulimit) [ [ tt(-SHacdfiklmnpqrstvwx) | tt(-N) var(resource) [ var(limit) ] ... ])(
+item(tt(ulimit) [ [ tt(-SHacdfiklmnpqsTtvwx) | tt(-N) var(resource) [ var(limit) ] ... ])(
 Set or display resource limits of the shell and the processes started by
 the shell.  The value of var(limit) can be a number in the unit specified
 below or one of the values `tt(unlimited)', which removes the limit on the
@@ -1935,8 +1935,8 @@ sitem(tt(-n))(open file descriptors.)
 sitem(tt(-p))(The number of pseudo-terminals.)
 sitem(tt(-q))(Bytes in POSIX message queues.)
 sitem(tt(-s))(Kilobytes on the size of the stack.)
+sitem(tt(-T))(The number of simultaneous threads available to the user.)
 sitem(tt(-t))(CPU seconds to be used.)
-sitem(tt(-r))(The number of simultaneous threads available to the user.)
 sitem(tt(-u))(The number of processes available to the user.)
 sitem(tt(-v))(Kilobytes on the size of virtual memory.  On some systems this
 refers to the limit called `address space'.)
diff --git a/Src/Builtins/rlimits.awk b/Src/Builtins/rlimits.awk
index b5a25fd..fe2d0e9 100644
--- a/Src/Builtins/rlimits.awk
+++ b/Src/Builtins/rlimits.awk
@@ -42,7 +42,7 @@ BEGIN {limidx = 0}
 	    if (limnam == "MEMLOCK") { msg[limnum] = "Mmemorylocked" }
 	    if (limnam == "NOFILE")  { msg[limnum] = "Ndescriptors" }
 	    if (limnam == "NPROC")   { msg[limnum] = "Nmaxproc" }
-	    if (limnam == "NTHR")    { msg[limnum] = "Nmaxthr" }
+	    if (limnam == "NTHR")    { msg[limnum] = "Nmaxpthreads" }
 	    if (limnam == "OFILE")   { msg[limnum] = "Ndescriptors" }
 	    if (limnam == "PTHREAD") { msg[limnum] = "Nmaxpthreads" }
 	    if (limnam == "RSS")     { msg[limnum] = "Mresident" }
diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c
index e48a1d3..fd4c94a 100644
--- a/Src/Builtins/rlimits.c
+++ b/Src/Builtins/rlimits.c
@@ -36,6 +36,10 @@
 #  define RLIMIT_LOCKS		RLIMIT_POSIXLOCKS
 #endif
 
+#ifdef RLIMIT_NTHR
+#  define RLIMIT_PTHREAD	RLIMIT_NTHR
+#endif
+
 enum {
     ZLIMTYPE_MEMORY,
     ZLIMTYPE_NUMBER,
@@ -318,12 +322,6 @@ printulimit(char *nam, int lim, int hard, int head)
 	    printf("-u: processes                       ");
 	break;
 # endif /* HAVE_RLIMIT_NPROC */
-# ifdef HAVE_RLIMIT_NTHR
-    case RLIMIT_NTHR:
-	if (head)
-	    printf("-r: threads                         ");
-	break;
-#endif /* HAVE_RLIMIT_NTHR */
 # if defined(HAVE_RLIMIT_VMEM) && (!defined(HAVE_RLIMIT_RSS) || !defined(RLIMIT_VMEM_IS_RSS))
     case RLIMIT_VMEM:
 	if (head)
@@ -375,7 +373,7 @@ printulimit(char *nam, int lim, int hard, int head)
 # ifdef HAVE_RLIMIT_PTHREAD
     case RLIMIT_PTHREAD:
 	if (head)
-	    printf("-N %2d: threads per process          ", RLIMIT_PTHREAD);
+	    printf("-T: threads per process             ");
 	break;
 # endif /* HAVE_RLIMIT_PTHREAD */
 # ifdef HAVE_RLIMIT_NICE
@@ -824,11 +822,6 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
 		    res = RLIMIT_NOFILE;
 		    break;
 # endif /* HAVE_RLIMIT_NOFILE */
-# ifdef HAVE_RLIMIT_NTHR
-		case 'r':
-		    res = RLIMIT_NTHR;
-		    break;
-# endif /* HAVE_RLIMIT_NTHR */
 # ifdef HAVE_RLIMIT_NPROC
 		case 'u':
 		    res = RLIMIT_NPROC;


^ permalink raw reply	[relevance 4%]

* Re: [PATCH] helpfiles: Also accept 'UTF-8' as an encoding name.
  @ 2013-11-14  0:06  3%                   ` Phil Pennock
  2013-11-14  7:50  3%                     ` Martin Vaeth
  0 siblings, 1 reply; 200+ results
From: Phil Pennock @ 2013-11-14  0:06 UTC (permalink / raw)
  To: Martin Vaeth; +Cc: zsh-workers

On 2013-11-13 at 18:28 +0000, Martin Vaeth wrote:
> There are so many "standards" for locale names that I really do not know
> what is the best: For instance, for the similar "de" (which might
> perhaps also be checked) there are besides de_* also fy_DE and hsb_DE on
> a Debian installation at my institute (though I do not know what
> they mean).

ISO 639 language code, followed by ISO 3166 region tag identifying a
regional dialect.

"en_US" is "English as spoken in the USA", "en_GB" is "English as spoken
in Britain".

"fy" is Frisian, as it spoken in the north-east of The Netherlands and
apparently also in Germany, per "fy_DE".

"hsb" appears to be "Upper Sorbian", per
<http://www.ethnologue.com/language/hsb>.

The POSIX locale stuff is not using the same separators as RFC5646 but
the same loose principles apply.

-Phil


^ permalink raw reply	[relevance 3%]

* Re: [PATCH] helpfiles: Also accept 'UTF-8' as an encoding name.
  2013-11-14  0:06  3%                   ` Phil Pennock
@ 2013-11-14  7:50  3%                     ` Martin Vaeth
  0 siblings, 0 replies; 200+ results
From: Martin Vaeth @ 2013-11-14  7:50 UTC (permalink / raw)
  To: zsh-workers

Phil Pennock <zsh-workers+phil.pennock@spodhuis.org> wrote:
>> perhaps also be checked) there are besides de_* also fy_DE and hsb_DE on
>> a Debian installation at my institute (though I do not know what
>> they mean).
>
> ISO 639 language code, followed by ISO 3166 region tag identifying a
> regional dialect.

Thanks for the information. That it is some sort of German dialect
spoken somewhere else was clear to me, that's why I think it *might*
be a possible fallback.
The more important question concerning the patch is whether it will
use utf8 or other character sets. I do not know how to get this
information (even less how to get it in a compatible way).
It is really a pity that the only "standard" locales (C and POSIX)
which a guaranteed do not produce correct files...

Anyway, I think this discussion becomes rather academic: It is hard
to believe that somebody generates e.g. fy_DE as utf8 on his system
but no other *.utf8 locales, even if theoretically possible.
So, concerning that patch, I still think it makes no sense to be
too careful about fallbacks. After all, if the wrong selection is
made for whatever reason, it can be overridden by the option resp. in
the makefile by setting a variable.
And whoever is generating the distribution tarball hopefully does
this on a system which has some *.utf8 locale.


^ permalink raw reply	[relevance 3%]

* [PATCH] _df: new completion for the df command
@ 2013-11-14 14:53  7% Jun T.
  0 siblings, 0 replies; 200+ results
From: Jun T. @ 2013-11-14 14:53 UTC (permalink / raw)
  To: zsh-workers


---
 Completion/Unix/Command/_df | 79 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 Completion/Unix/Command/_df

diff --git a/Completion/Unix/Command/_df b/Completion/Unix/Command/_df
new file mode 100644
index 0000000..892f91f
--- /dev/null
+++ b/Completion/Unix/Command/_df
@@ -0,0 +1,79 @@
+#compdef df
+
+local context state state_descr line args spec
+local -A opt_args
+
+if _pick_variant gnu=GNU unix --version; then
+  args=(
+    '(-B --block-size -k)'{-B+,--block-size=}'[specify block size]:size (bytes)'
+    '(-B --block-size -k)-k[like --block-size=1K]'
+    '(-P --portability)'{-P,--portability}'[use the POSIX output format]'
+    '(-h --human-readable -H --si)'{-h,--human-readable}'[print sizes in human readable format]'
+    '(-h --human-readable -H --si)'{-H,--si}'[human readable fomat, but use powers of 1000 not 1024]'
+    '(-i --inodes)'{-i,--inodes}'[list inode information instead of block usage]'
+    '--total[produce a grand total]'
+    '(-T --print-type)'{-T,--print-type}'[print file system type]'
+    '(-a --all)'{-a,--all}'[include dummy file systems]'
+    '(-l --local)'{-l,--local}'[limit listing to local file systems]'
+    '*'{-t+,--type=}'[limit listing to file systems of specified type]:file system type:_file_systems'
+    '*'{-x+,--exclude-type=}'[exclude file systems of specified type]:file system type:_file_systems'
+    '(--no-sync)--sync[invoke sync before getting usage info]'
+    '(--sync)--no-sync[do not invoke sync before getting usage info (default)]'
+    '-v[(ignored)]'
+    '(- : *)--help[display help and exit]'
+    '(- : *)--version[output version information and exit]'
+    '*:files:_files'
+  )
+elif [[ "$OSTYPE" == (darwin|freebsd|dragonfly)* ]]; then
+  args=(
+    '(-b -g -H -h -k -m)-b[use 512-byte blocks (default)]'
+    '(-b -g -H -h -k -m)-g[use 1024^3-byte blocks]'
+    '(-b -g -H -h -k -m)-H[human-readable output (base 10)]'
+    '(-b -g -H -h -k -m)-h[human-readable output (base 2)]'
+    '(-b -g -H -h -k -m)-k[use 1024-byte blocks]'
+    '(-b -g -H -h -k -m)-m[use 1024*1024-byte blocks]'
+    '-P[POSIX compliant output]'
+    '-a[show all mount points]'
+    '-i[include inode usage statistics (default)]'
+    '-l[only display locally-mounted file systems]'
+    '-n[use previously obtained statistics]'
+    '*:files:_files'
+  )
+  spec='[only display file systems of specified types]:file system type:->fslist'
+  case "$OSTYPE" in
+    (darwin*)
+      args+=(
+        "-T+$spec"
+#       '-t[same as -T (obsolete)]:file system type:->fslist'
+      )
+      ;;
+    (freebsd*|dragonfly*)
+      args+=( "-t+$spec" '-T[include file system type]' )
+      ;;
+  esac
+else
+  # POSIX
+  args=(
+    '-k[use 1024-byte blocks]'
+    '-P[POSIX compliant output]'
+    '-t[include total allocated-space figures in the output]'
+    '*:files:_files'
+  )
+fi
+
+_arguments -s -S : $args && return 0
+
+case "$state" in
+  (fslist)
+    local -a fsys used pre disp expl
+    _file_systems -U -O fsys
+    pre=$IPREFIX
+    # offer 'no' only if at the beginning of the list
+    if ! compset -P '*,' && ! compset -P 'no'; then
+      disp=( 'no  -- exclude file system types in the list' )
+      _wanted list-prefix expl 'prefix to list' compadd -d disp 'no'
+    fi
+    used=( ${(s:,:)${${IPREFIX#$pre}#no}} )
+    _wanted fsys-types expl "$state_descr" compadd -qS , -F used -a fsys
+    ;;
+esac
-- 
1.8.3.4 (Apple Git-47)


^ permalink raw reply	[relevance 7%]

Results 801-1000 of ~2400   |  | reverse | sort options + mbox downloads above
-- links below jump to the message on this page --
2009-02-25  0:17  4% zsh regards reserved word as candidate for alias substitution Vincent Lefevre
2009-03-03 17:23  0% ` Peter Stephenson
2009-02-26 15:52  1% PATCH: add -t <fmt> option to history Peter Stephenson
     [not found]     ` <20090226163512.GA5181@sc.homeunix.net>
2009-02-26 17:15  0%   ` Peter Stephenson
2009-02-28 19:52  3% Echoing of 8-bit-characters broken after 4.3.2? Wolfgang Hukriede
2009-02-28 20:40  3% ` Andrey Borzenkov
2009-02-28 22:00  0% Wolfgang Hukriede
2009-03-01  0:12  0% ` Phil Pennock
2009-03-08  8:21     Modules/attr.c compile error on Mac OS X Taro M
2009-03-08  9:10  3% ` François Revol
     [not found]     <20090224231846.GA15279@vin.lip.ens-lyon.fr>
2009-03-25 14:49  0% ` Bug#516998: zsh regards reserved word as candidate for alias substitution Clint Adams
2009-03-25 16:23  0%   ` Peter Stephenson
     [not found]     <20090225022850.GA4841@vin.lip.ens-lyon.fr>
2009-03-25 14:54  0% ` Bug#517008: alias not expanded with zsh -c Clint Adams
2009-03-25 16:30  0%   ` Peter Stephenson
2009-03-25 17:25  0%     ` Peter Stephenson
2009-03-25 18:11  3%       ` Bart Schaefer
2009-03-25 23:35  0%         ` Vincent Lefevre
     [not found]     <20090317114619.GA12579@vin.lip.ens-lyon.fr>
     [not found]     ` <20090313145134.GA23870@vin.lip.ens-lyon.fr>
     [not found]       ` <20090211123454.GA20425@vin.lip.ens-lyon.fr>
2009-03-25 14:57  0%     ` Bug#514857: zsh -c 'set -e; ! true; echo OK' fails Clint Adams
     [not found]     <20090506003505.GA29923@ngolde.de>
2009-05-06  1:38     ` Bug#527171: [zsh] segfaults on long environment variables Clint Adams
2009-05-06 19:41  3%   ` Peter Stephenson
2009-05-27 15:54  3% Here-docs and $(...) Bart Schaefer
2009-07-01 13:14  4% zsh bug in . builtin Eric Blake
2009-07-07 21:08  5% non-interactive set -m Eric Blake
2009-07-08  8:58  0% ` Peter Stephenson
2009-07-08 13:26  5%   ` Eric Blake
2009-07-08 13:49  4%     ` Peter Stephenson
2009-07-09 14:03  0%       ` Eric Blake
2009-07-09 14:13  0%         ` Peter Stephenson
2009-07-09 18:13           ` Eric Blake
2009-07-09 20:23             ` Peter Stephenson
2009-07-09 21:40  4%           ` Eric Blake
2009-07-10  8:58  0%             ` Peter Stephenson
2009-07-10 10:53  6%               ` Peter Stephenson
2009-07-09 13:12  3% bug: $? after empty command Eric Blake
2009-07-09 14:41  0% ` Peter Stephenson
2009-07-09 21:17  3%   ` Eric Blake
2009-07-09 21:41  3%     ` Eric Blake
2009-07-10  9:02  3%       ` Peter Stephenson
2009-07-10 22:05  0%         ` Peter Stephenson
     [not found]     <p.w.stephenson@ntlworld.com>
2009-07-11 19:05     ` non-interactive set -m Peter Stephenson
2009-07-11 23:16  3%   ` Eric Blake
2009-07-12 15:01 18%     ` Peter Stephenson
2009-07-12 18:28  4%       ` Bart Schaefer
2009-07-12 19:35  0%         ` Peter Stephenson
2009-07-12 21:19  4%           ` Bart Schaefer
2009-07-13  1:48  3%             ` Eric Blake
2009-07-13 13:20  0%         ` Eric Blake
2009-07-14 21:59  5% cd bugs Eric Blake
2009-07-14 22:30  4% ` Eric Blake
2009-07-19 19:00  8%   ` Peter Stephenson
2009-07-15  3:28  4% ` Eric Blake
2009-07-21  9:22  4% ` Peter Stephenson
     [not found]     <schaefer@brasslantern.com>
2009-07-13  2:36     ` zsh 4.3.10 terminates with SIGINT when one types Ctrl-G in emacs under Mac OS X Bart Schaefer
2009-07-13 18:39       ` Peter Stephenson
2009-07-16 16:24         ` Vincent Lefevre
2009-07-18  5:29           ` Bart Schaefer
2009-07-18 10:16             ` Vincent Lefevre
2009-07-18 18:35               ` Bart Schaefer
2009-07-18 23:09                 ` Vincent Lefevre
2009-07-19 18:31                   ` Bart Schaefer
2009-07-20  8:31                     ` Vincent Lefevre
2009-07-22  2:58  3%                   ` Eric Blake
2009-07-22  8:16  0%                     ` Vincent Lefevre
     [not found]     <19213.26295.345572.732238@gargle.gargle.HOWL>
     [not found]     ` <200911251748.nAPHmrCX010198@news01.csr.com>
     [not found]       ` <m3638sr72x.fsf_-_@klanderman.net>
     [not found]         ` <091129211436.ZM1769@torch.brasslantern.com>
2009-11-30 18:37  0%       ` unable to wait on completed job [was: should $! give the pid of subshell?] Peter Stephenson
2009-12-14 11:40  3% [PATCH] run-help: ugly workaround for run-help-$X with alias for $X Jörg Sommer
     [not found]     <20091219211403.GA94709@stack.nl>
     [not found]     ` <20091221101508.GA1634@squonk.masqnet>
     [not found]       ` <4B2FB116.4070900@case.edu>
     [not found]         ` <20091221175312.GA16707@squonk.masqnet>
     [not found]           ` <dd0728a90912211132g1e891e8bm766f0cc083820d45@mail.gmail.com>
     [not found]             ` <20091222113413.GA9234@squonk.masqnet>
2009-12-22 22:02  3%           ` Fwd: command substitutions starting with $(( Bart Schaefer
2010-01-17 21:30     cp file with a filter Peter Stephenson
2010-01-17 22:18     ` Bart Schaefer
2010-01-18  9:56  3%   ` Peter Stephenson
2010-01-18 12:42  3% PATCH: function support for regular expression substitution Peter Stephenson
     [not found]     <20100202081546.GA5930@panix.com>
     [not found]     ` <87vdefkeuf.fsf@ft.bewatermyfriend.org>
2010-02-02 15:06  0%   ` Want to replace bash w zsh as system shell on Ubuntu Peter Stephenson
2010-02-13 20:21  2% Improve job text for ( ... ) and { ... } Peter Stephenson
2010-02-15 14:10  5% PATCH: FAQ for advanced character sets Peter Stephenson
2010-03-11 22:04  8% PATCH: Standard IFS Peter Stephenson
2010-03-31  5:46     Is this a bug? Why not? Bart Schaefer
2010-03-31  6:06     ` Phil Pennock
2010-03-31 15:11  3%   ` Bart Schaefer
2010-04-01  8:26  0%     ` Phil Pennock
2010-04-01 14:36  3%       ` Bart Schaefer
2010-04-01 21:57  0%         ` Phil Pennock
2010-04-17 21:39     [PATCH 0/6] Proposed updates for the zsh website Simon Ruderich
2010-04-17 21:40  3% ` [PATCH 4/6] Update news and releases Simon Ruderich
2010-07-29  4:48  2% [hamer@hamer.org.ua: Bug#590736: zsh: Segmentation fault in completion] Clint Adams
     [not found]     <20100803203204.GG13690@gmx.de>
2010-08-03 20:55  3% ` Fix testsuite errors due to shell quoted parameter expansion issue Eric Blake
2010-08-03 21:21  0%   ` Mikael Magnusson
2010-08-03 21:28  3%     ` Eric Blake
2010-08-04 15:18  0%     ` John Lumby
2010-08-05 22:15  0%   ` Chet Ramey
2010-08-23 14:09     [RFC or so] Add HASH_LOOKUP option Mikael Magnusson
2010-08-23 17:46     ` Bart Schaefer
2010-08-23 18:25       ` Mikael Magnusson
2010-08-24  8:37  2%     ` Bart Schaefer
2010-09-08 14:02  6% PATCH: NEWS for 4.3.11 Peter Stephenson
2010-09-10 19:31  6% PATCH: POSIX_TRAPS option Peter Stephenson
2010-09-12  3:49  3% ` Bart Schaefer
2010-09-17 17:33  9% avoid $status and $options in POSIX mode Eric Blake
2010-09-18  3:25  8% ` Bart Schaefer
2010-09-18  7:25  8%   ` Bart Schaefer
2010-09-19 21:39  5%     ` Bart Schaefer
2010-09-20  8:45  5%       ` Peter Stephenson
2010-10-11  8:42  5% Fw: zsh POSIX_TRAPS option Peter Stephenson
2010-10-11 15:16  4% ` Bart Schaefer
2010-10-15 13:47  0%   ` Jilles Tjoelker
2010-11-09 22:08  4% static vs. dynamic scoping Eric Blake
2010-11-10 11:10  5% ` Peter Stephenson
2010-11-10 16:50  3% ` Bart Schaefer
2010-11-10 17:28  4%   ` Eric Blake
2010-11-10 17:22     ` Bart Schaefer
2010-11-10 17:30  3%   ` Eric Blake
2010-11-17 16:54     PATCH: bash-style substrings & subarrays Peter Stephenson
2010-11-18 12:44  3% ` Peter Stephenson
2010-11-19 18:16  7% PATCH: POSIX_STRINGS option Peter Stephenson
2010-11-21  6:34     PATCH: bash-style substrings & subarrays Bart Schaefer
2010-11-21 17:02     ` Peter Stephenson
2010-11-23 11:14  3%   ` Peter Stephenson
2010-11-25 20:41     `jobs' builtin does not work with pipe in scripts ZyX
2010-11-25 21:40     ` ZyX
2010-11-25 23:56       ` Marc Weber
2010-11-26  4:38  3%     ` ZyX
     [not found]     <21986.1292864174@csr.com>
2010-12-20 20:16  3% ` [PATCH 1/2] Website Update: Add release notes for 4.3.11 Simon Ruderich
2011-01-11  0:16     4.3.11 TRAPEXIT() on cygwin Anthony Heading
2011-01-11  0:46     ` Mikael Magnusson
2011-01-11  1:46       ` Anthony Heading
2011-01-11  1:50         ` Mikael Magnusson
2011-01-11  2:54  3%       ` Anthony Heading
2011-01-11  3:25  0%         ` Mikael Magnusson
2011-01-11  3:27               ` Mikael Magnusson
2011-01-11  9:38  5%             ` Peter Stephenson
2011-02-18  3:55     sh compatibility issue Vincent Stemen
2011-02-18 10:30  2% ` Peter Stephenson
2011-02-19 23:05  4%   ` Jilles Tjoelker
2011-02-20  0:41  3%     ` Vincent Stemen
2011-02-20 19:11  0%     ` Peter Stephenson
2011-02-20 20:17  0%       ` Peter Stephenson
     [not found]           ` <4D618A11.3050406@case.edu>
2011-02-22 20:02  7%         ` Peter Stephenson
2011-02-23  1:08  0%           ` Vincent Stemen
2011-02-23  1:51  3%             ` Bart Schaefer
2011-02-23  2:30  0%               ` Vincent Stemen
2011-02-23  9:25  4%               ` Peter Stephenson
2011-03-04 13:36  4%           ` Jilles Tjoelker
2011-03-06 20:26  5%             ` Peter Stephenson
2011-02-27 11:44  3% typeset -p output gives shows variables which can't be read back in Rocky Bernstein
2011-02-27 21:01     ` Bart Schaefer
2011-02-28  5:08       ` Rocky Bernstein
2011-02-28  7:09         ` Bart Schaefer
2011-03-01  3:09  4%       ` Rocky Bernstein
2011-03-11 19:07  3% bug in ${##} expansion Eric Blake
2011-03-11 20:04  3% ` Peter Stephenson
2011-03-21 10:15  0%   ` Peter Stephenson
2011-04-12 13:09  5% [PATCH v2] define _GNU_SOURCE Valentin Ochs
2011-04-13 16:10     ` build on os x 10.6.7, xcode 3.2.6 S. Cowles
2011-04-13 16:26  6%   ` Peter Stephenson
2011-04-13 19:32  0%     ` S. Cowles
2011-04-14  8:35     ` [PATCH v2] define _GNU_SOURCE Peter Stephenson
2011-04-14  9:03  5%   ` Peter Stephenson
2011-05-07 21:56     SIGFPE crash Jon Mayo
2011-05-07 22:17     ` Mikael Magnusson
2011-05-07 22:19       ` Jon Mayo
2011-05-07 22:27         ` Mikael Magnusson
2011-05-09 10:21  3%       ` Vincent Lefevre
2011-05-14 11:41  4% PATCH: expanding parameters like echo/print builtins Jilles Tjoelker
2011-05-14 18:41  3% ` Bart Schaefer
2011-06-03 18:00  3% regression in ${##""} Eric Blake
2011-06-03 18:55  0% ` Mikael Magnusson
2011-06-03 19:16  3%   ` Eric Blake
     [not found]     <AANLkTimiFku8Uj9haYAxXWyJQOGSV7Uz3i2k75+aMvTU@mail.gmail.com>
     [not found]     ` <20110707033749.GB16157@gondor.apana.org.au>
     [not found]       ` <4E15B41A.9020601@redhat.com>
     [not found]         ` <20110707144635.GA21272@gondor.apana.org.au>
2011-07-07 15:18  5%       ` 'continue' does not work in files sourced with dotcmd Eric Blake
2011-07-22 11:08     4.3.13 changes Peter Stephenson
2011-07-22 11:13     ` Nikolai Weibull
2011-09-12 19:51       ` Peter Stephenson
2011-09-25 22:48  3%     ` Bart Schaefer
2011-07-31 14:17  4% syntax error with anonymous functions when an argument begins with ( Jilles Tjoelker
2011-08-06  3:31     How to misplace an entire pipeline Bart Schaefer
2011-08-07 17:50     ` Peter Stephenson
2011-08-07 21:43       ` Bart Schaefer
2011-08-08  4:05         ` Bart Schaefer
2011-08-08 18:27           ` Peter Stephenson
2011-08-09  6:10             ` Bart Schaefer
2011-08-09 20:19               ` Peter Stephenson
2011-08-13 18:52                 ` Bart Schaefer
2011-09-12 13:51  3%               ` Alexey I. Froloff
2011-09-12 16:03  3%                 ` Bart Schaefer
2011-08-10 11:21  2% PATCH: zsh/datetime $EPOCHREALTIME Peter Stephenson
2011-12-09 14:11  3% Next release Peter Stephenson
2011-12-10  1:39     Bug in sh emulation Ivan S. Freitas
2011-12-10  2:47     ` Bart Schaefer
2011-12-10 19:40       ` Peter Stephenson
2011-12-10 23:28         ` Peter Stephenson
2011-12-11 19:39           ` Peter Stephenson
2011-12-11 20:20             ` Peter Stephenson
2011-12-11 20:56               ` Peter Stephenson
2011-12-11 23:39                 ` Bart Schaefer
2011-12-12 10:01                   ` Peter Stephenson
2011-12-12 10:14  3%                 ` Peter Stephenson
2011-12-10 12:24     $pipestatus broken? Frank Terbeck
2011-12-10 12:48     ` Frank Terbeck
2011-12-10 14:58       ` Bart Schaefer
2011-12-23 10:49  5%     ` Frank Terbeck
2011-12-21  2:08     bug Ray Andrews
2011-12-21  3:05     ` bug Bart Schaefer
2011-12-21 22:32 12%   ` bug Peter Stephenson
     [not found]     <201112221539.pBMFdlaj011933@penguin.research.att.com>
2011-12-22 21:03  3% ` '>;' redirection operator [was: [1003.1(2008)/Issue 7 0000530]: Support in-place editing in sed (-iEXTENSION)] Eric Blake
2011-12-22 22:09       ` Bruce Korb
2011-12-22 23:34  4%     ` '>;' redirection operator Thorsten Glaser
2012-01-29  2:46     Bug with bash emulation regarding ':' Felipe Contreras
2012-01-29 18:36     ` Peter Stephenson
2012-02-01  4:29       ` Bart Schaefer
2012-02-01 16:29         ` Bart Schaefer
2012-02-05 20:11  2%       ` Peter Stephenson
2012-02-05 21:21  3%         ` Bart Schaefer
2012-02-14 17:41             ` Peter Stephenson
2012-02-14 23:30  3%           ` Chet Ramey
2012-02-15 12:36  0%             ` Peter Stephenson
2012-02-19 23:45                   ` Bart Schaefer
2012-02-20  8:48  5%                 ` Bart Schaefer
2012-02-20 10:59  3%                 ` Peter Stephenson
2012-02-20 17:09  3%                   ` Bart Schaefer
2012-01-30 20:21     Bug with sh emulation; shouldn't KSH_TYPESET be set? Felipe Contreras
2012-01-30 20:43  5% ` Frank Terbeck
2012-01-30 21:46  0%   ` Felipe Contreras
2012-01-30 22:17  4%     ` Frank Terbeck
2012-01-30 22:20  0%     ` Vincent Lefevre
2012-01-31  9:43  3% ` Peter Stephenson
2012-02-10 11:08  4% Bug with bash emulation regarding ':' Jilles Tjoelker
2012-02-15  2:15 10% printf %<n>s in UTF-8 is not always POSIX-compliant Vincent Lefevre
2012-02-15  8:14  5% ` Bart Schaefer
2012-02-15  9:10  5%   ` Vincent Lefevre
2012-02-15 11:05  8%   ` Peter Stephenson
2012-02-15 11:53  5%     ` Vincent Lefevre
2012-02-15 12:09  5%       ` Frank Terbeck
2012-02-15 12:23  8%         ` Peter Stephenson
2012-02-15 12:42  5%         ` Vincent Lefevre
2012-02-15 14:42  9%   ` Oliver Kiddle
2012-02-15 14:56  5%     ` Vincent Lefevre
2012-02-23 10:40     zsh behavior when fork() failed Dipak Gaigole
2012-02-23 16:14     ` Bart Schaefer
2012-02-24 11:08       ` Dipak Gaigole
2012-02-24 18:05         ` Bart Schaefer
2012-02-25 16:33           ` Dipak Gaigole
2012-02-26 19:52  2%         ` Bart Schaefer
2012-04-13 22:14  8% PATCH: NEWS updated for 5.0 Peter Stephenson
2012-06-11 16:04     Possible 4.3.18? Frank Terbeck
2012-06-11 16:24     ` Peter Stephenson
2012-06-15 18:42  4%   ` Peter Stephenson
     [not found]     <20120724094229.6bd93bb9@pwslap01u.europe.root.pri>
2012-07-24 15:59     ` zsh 5.0.0 released, finally Simon Ruderich
2012-07-24 16:11 12%   ` Simon Ruderich
2012-08-16 12:04     tgoto issue in zsh-5.0.0 Thomas Klausner
2012-08-16 13:07     ` Peter Stephenson
2012-08-16 13:20       ` Thomas Klausner
2012-08-16 13:25         ` Peter Stephenson
2012-08-16 14:25           ` pkgsrc patches for zsh [was Re: tgoto issue in zsh-5.0.0] Thomas Klausner
     [not found]             ` <sfid-H20120816-211920-+043.99-1@spamfilter.osbf.lua>
2012-08-16 19:18               ` Peter Stephenson
2012-08-17  8:11                 ` Thomas Klausner
2012-08-17  9:38  4%               ` Peter Stephenson
2012-08-30 14:11  3% PATCH: (provisional) underscores in constants in numeric evaluation Peter Stephenson
2012-10-24 15:21  2% Bug with long multiline strings? Frank Terbeck
2012-11-02  9:09     Function code breaking out of if then ...fi Michal Maruska
2012-11-02 21:39     ` Bart Schaefer
2012-11-05 14:29  3%   ` Peter Stephenson
2012-11-05 14:55         ` Peter Stephenson
2012-11-05 16:08  9%       ` Peter Stephenson
2012-11-09 22:52 12%       ` Peter Stephenson
2012-11-07 19:13  3% bug in parameter expansion Scott Moser
2012-11-07 20:45  2% ` Peter Stephenson
2012-11-16 22:27 18% PATCH: updated find completion Oliver Kiddle
2012-12-13 14:57     Access to CVS Simon Ruderich
2012-12-07 11:03     ` Frank Terbeck
2013-03-17 14:55       ` Simon Ruderich
2013-04-04 13:38         ` Simon Ruderich
2013-04-05 16:57           ` One-command mail import with X-Seq: and ChangeLog (was: Re: Access to CVS) Frank Terbeck
2013-04-07 19:07             ` Bart Schaefer
2013-04-07 21:08  2%           ` One-command mail import with X-Seq: and ChangeLog Frank Terbeck
2013-04-11 15:10  3%           ` Frank Terbeck
2013-01-15 15:43     SIGPIPE echoing to fifo exits zsh Christian Neukirchen
2013-01-15 23:16     ` Han Pingtian
2013-01-16  2:53  2%   ` Bart Schaefer
2013-01-16  9:44  0%     ` Peter Stephenson
2013-01-26 22:25  3% *$var*/* and recursive globbing Stephane Chazelas
2013-02-21  9:55  2% PATCH: minor completion function updates Oliver Kiddle
2013-04-29 13:50  5% [PATCH] _cp: add support for Mac OS X Jun T
     [not found]     <CAOjwHPbVW8BQ2J==oYnDFXMTcMSVsP-uj7Qu42Y288SRHJG76g@mail.gmail.com>
2013-05-14 11:30  0% ` cygwin64 can not build zsh 5.0.2 Peter Stephenson
2013-05-14 13:14  0%   ` XueJia Zhe
2013-07-28 16:21     [PATCH 00/16] Improvements to the Git completion functions Øystein Walle
2013-07-28 16:22  3% ` [PATCH 05/16] _git: completion updates to match latest git v1.8.3 Øystein Walle
2013-07-28 16:22  1% ` [PATCH 06/16] _git: completion updates to match latest git v1.8.3 part 2 Øystein Walle
2013-08-31 23:47     sleep $floatval Phil Pennock
2013-09-01  7:45  3% ` Bart Schaefer
2013-09-01  8:16  3%   ` Phil Pennock
2013-09-04 16:15  3% Builtin test and parsing of conditionals Bart Schaefer
2013-09-04 16:31  0% ` Peter Stephenson
2013-09-04 17:39  3%   ` Bart Schaefer
2013-09-04 19:09  0%     ` Peter Stephenson
2013-09-05 14:25           ` Bart Schaefer
2013-09-06 19:20  5%         ` Peter Stephenson
2013-09-22 10:48     [PATCH v2 00/14] Improvements to the Git completion functions Øystein Walle
2013-09-22 10:48  3% ` [PATCH v2 05/14] _git: completion updates to match latest git v1.8.3 Øystein Walle
2013-09-22 10:48  1% ` [PATCH v2 06/14] _git: completion updates to match latest git v1.8.3 part 2 Øystein Walle
2013-10-17  0:27  8% Important discussion about "local" on the POSIX list Bart Schaefer
2013-10-17  0:51  5% ` Chet Ramey
2013-10-17  9:06  5% ` Peter Stephenson
2013-10-27 16:06  3% completion file for the command 'cat' Jun T.
2013-10-30  1:33  4% PATCH: add more ulimit extensions from BSDs Stefan Neudorf
2013-10-30 10:59     ` Peter Stephenson
2013-10-30 15:29       ` Bart Schaefer
2013-10-31 11:33         ` Peter Stephenson
2013-10-31 20:10  9%       ` Peter Stephenson
2013-10-31 23:09  9%     ` PATCH: " Stefan Neudorf
2013-10-31 23:41  4% PATCH: assign threads ulimit -T flag like in bash Stefan Neudorf
2013-11-11  9:09     Install run-help and *.zwc files system wide in build system Martin Vaeth
2013-11-11 16:42     ` Bart Schaefer
2013-11-11 22:59       ` Martin Vaeth
2013-11-12 10:11         ` Peter Stephenson
2013-11-12 17:41           ` Martin Vaeth
2013-11-13 13:30             ` [PATCH] helpfiles: Also accept 'UTF-8' as an encoding name Jun T.
2013-11-13 15:37               ` Jun T.
2013-11-13 16:56                 ` Martin Vaeth
2013-11-13 17:27                   ` Bart Schaefer
2013-11-13 18:28                     ` Martin Vaeth
2013-11-14  0:06  3%                   ` Phil Pennock
2013-11-14  7:50  3%                     ` Martin Vaeth
2013-11-14 14:53  7% [PATCH] _df: new completion for the df command Jun T.

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