about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Functions/Calendar/calendar_add7
-rw-r--r--Src/builtin.c9
-rw-r--r--Src/parse.c6
-rw-r--r--Test/C02cond.ztst26
5 files changed, 47 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index d0edf2f4e..ab841aee1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2008-01-10  Peter Stephenson  <pws@csr.com>
 
+	* users/12412: Src/builtin.c, Src/parse.c, Test/C02cond.ztst:
+	check for extra arguments in test and [.
+
 	* 24384: Src/params.c: eliminate invalid pointer and also
 	(unposted) add debug check for use.
 
diff --git a/Functions/Calendar/calendar_add b/Functions/Calendar/calendar_add
index e8c535d59..04401bc9f 100644
--- a/Functions/Calendar/calendar_add
+++ b/Functions/Calendar/calendar_add
@@ -74,7 +74,7 @@ fi
 	if [[ -n $reply[rpttime] && $line = ${~uidpat} ]]; then
 	  # Yes, so record this as a recurring event.
 	  their_uid=${(U)match[1]}
-	  recurring_uids[$their_uid]=1
+	  recurring_uids[$their_uid]=$reply[time]
 	fi
       done
     fi
@@ -113,6 +113,11 @@ fi
 	      # No, so assume this is a straightforward replacement
 	      # of a non-recurring event.
 	      (( ! old_recurring )) && continue
+	      # It's recurring, but if this is a one-off at the
+	      # same time as the previous one, replace anyway.
+	      [[ -z $parse_old[$rpttime] ]] &&
+	        (( ${parse_new[time]} == ${parse_old[time]} )) &&
+		continue
 	    fi
 	  fi
 	fi
diff --git a/Src/builtin.c b/Src/builtin.c
index 8ded1c131..299ad3758 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -5472,7 +5472,7 @@ zread(int izle, int *readchar)
 
 /* holds arguments for testlex() */
 /**/
-char **testargs;
+char **testargs, **curtestarg;
 
 /* test, [: the old-style general purpose logical expression builtin */
 
@@ -5483,7 +5483,7 @@ testlex(void)
     if (tok == LEXERR)
 	return;
 
-    tokstr = *testargs;
+    tokstr = *(curtestarg = testargs);
     if (!*testargs) {
 	/* if tok is already zero, reading past the end:  error */
 	tok = tok ? NULLTOK : LEXERR;
@@ -5557,6 +5557,11 @@ bin_test(char *name, char **argv, UNUSED(Options ops), int func)
 	return 1;
     }
 
+    if (*curtestarg) {
+	zwarnnam(name, "too many arguments");
+	return 1;
+    }
+
     /* syntax is OK, so evaluate */
 
     state.prog = prog;
diff --git a/Src/parse.c b/Src/parse.c
index 30f3abe50..af3cba9d3 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -537,6 +537,12 @@ parse_list(void)
     return bld_eprog();
 }
 
+/*
+ * This entry point is only used for bin_test, our attempt to
+ * provide compatibility with /bin/[ and /bin/test.  Hence
+ * at this point condlex should always be set to testlex.
+ */
+
 /**/
 mod_export Eprog
 parse_cond(void)
diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst
index 0057e3a10..ff5afeb08 100644
--- a/Test/C02cond.ztst
+++ b/Test/C02cond.ztst
@@ -199,7 +199,31 @@ F:Failures in these cases do not indicate a problem in the shell.
 0:strings with `[' builtin
 
   [ `echo 0` -lt `echo 1` ]
-0:substituion in `[' builtin
+0:substitution in `[' builtin
+
+  [ -n foo scrimble ]
+1:argument checking for [ builtin
+?(eval):[:1: too many arguments
+
+  test -n foo scramble
+1:argument checking for test builtin
+?(eval):test:1: too many arguments
+
+  [ -n foo scrimble scromble ]
+1:argument checking for [ builtin
+?(eval):[:1: too many arguments
+
+  test -n foo scramble scrumble
+1:argument checking for test builtin
+?(eval):test:1: too many arguments
+
+  [ -n foo -a -n bar scrimble ]
+1:argument checking for [ builtin
+?(eval):[:1: too many arguments
+
+  test -n foo -a -z "" scramble
+1:argument checking for test builtin
+?(eval):test:1: too many arguments
 
   fn() {
     # careful: first file must exist to trigger bug