about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-01-11 22:04:24 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-01-11 22:04:24 +0000
commitbfd6782b5a7a75568be3554bbdc7d7eee53e6538 (patch)
tree75fb9fce21e3897156eed95bb68428a659c711ad
parenta978d1c47cc8fab586b26b74a3abadbee0da3439 (diff)
downloadzsh-bfd6782b5a7a75568be3554bbdc7d7eee53e6538.tar.gz
zsh-bfd6782b5a7a75568be3554bbdc7d7eee53e6538.tar.xz
zsh-bfd6782b5a7a75568be3554bbdc7d7eee53e6538.zip
zsh-workers/9295
-rw-r--r--Doc/Zsh/grammar.yo26
-rw-r--r--Src/Modules/parameter.c4
-rw-r--r--Src/loop.c7
3 files changed, 28 insertions, 9 deletions
diff --git a/Doc/Zsh/grammar.yo b/Doc/Zsh/grammar.yo
index 5ae28dba1..8b25795d0 100644
--- a/Doc/Zsh/grammar.yo
+++ b/Doc/Zsh/grammar.yo
@@ -205,9 +205,10 @@ item(tt(select) var(name) [ tt(in) var(word) ... var(term) ] tt(do) var(list) tt
 where var(term) is one or more newline or tt(;) to terminate the var(word)s.
 Print the set of var(word)s, each preceded by a number.
 If the tt(in) var(word) is omitted, use the positional parameters.
-The tt(PROMPT3) prompt is printed and a line is read from standard
-input.  If this line consists of the number of one of the listed
-var(word)s, then the parameter var(name)
+The tt(PROMPT3) prompt is printed and a line is read from the line editor
+if the shell is interactive and that is active, or else standard input.
+If this line consists of the
+number of one of the listed var(word)s, then the parameter var(name)
 is set to the var(word) corresponding to this number.
 If this line is empty, the selection list is printed again.
 Otherwise, the value of the parameter var(name) is set to null.
@@ -263,11 +264,26 @@ versions of complex commands should be considered deprecated and may be
 removed in the future.  The versions in the previous section should be
 preferred instead.  The short versions below only work if var(sublist)
 is of the form `tt({) var(list) tt(})' or if the tt(SHORT_LOOPS)
-option is set.
+option is set.  In this case, the test part of the loop must also be
+suitably delimited, such as by `tt([[ ... ]])' or `tt((( ... )))', else
+the end of the test will not be recognized.
 
 startitem()
 item(tt(if) var(list) tt({) var(list) tt(}) [ tt(elif) var(list) tt({) var(list) tt(}) ] ... [ tt(else {) var(list) tt(}) ])(
-An alternate form of tt(if).
+An alternate form of tt(if).  The rules mean that
+
+example(if [[ -o ignorebraces ]] {
+  print yes
+})
+
+works, but
+
+example(if true {  # Does not work!
+  print yes
+}
+)
+
+does em(not), since the test is not suitably delimited.
 )
 item(tt(if) var(list) var(sublist))(
 A short form of the alternate `if'.
diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c
index 23097e10c..94aff0c18 100644
--- a/Src/Modules/parameter.c
+++ b/Src/Modules/parameter.c
@@ -838,8 +838,10 @@ scanpmoptions(HashTable ht, ScanFunc func, int flags)
 
     for (i = 0; i < optiontab->hsize; i++)
 	for (hn = optiontab->nodes[i]; hn; hn = hn->next) {
+	    int optno = ((Optname) hn)->optno, ison;
 	    pm.nam = hn->nam;
-	    pm.u.str = dupstring(opts[((Optname) hn)->optno] ? "on" : "off");
+	    ison = optno < 0 ? !opts[-optno] : opts[optno];
+	    pm.u.str = dupstring(ison ? "on" : "off");
 	    func((HashNode) &pm, flags);
 	}
 }
diff --git a/Src/loop.c b/Src/loop.c
index 0d7379c00..b8e7f956f 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -154,7 +154,7 @@ execselect(Cmd cmd, LinkList args, int flags)
     Forcmd node;
     char *str, *s;
     LinkNode n;
-    int i;
+    int i, usezle;
     FILE *inp;
     size_t more;
 
@@ -172,12 +172,13 @@ execselect(Cmd cmd, LinkList args, int flags)
     lastval = 0;
     pushheap();
     cmdpush(CS_SELECT);
-    inp = fdopen(dup((SHTTY == -1) ? 0 : SHTTY), "r");
+    usezle = interact && SHTTY != -1 && isset(USEZLE);
+    inp = fdopen(dup(usezle ? SHTTY : 0), "r");
     more = selectlist(args, 0);
     for (;;) {
 	for (;;) {
 	    if (empty(bufstack)) {
-	    	if (interact && SHTTY != -1 && isset(USEZLE)) {
+	    	if (usezle) {
 		    int oef = errflag;
 
 		    isfirstln = 1;