Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: printf --



Reluctantly, I here add removal of an inital `--' to printf to satisfy
POSIX.

Except for cd, command (which we knew anyway) and possibly ulimit, I
think we have it right for other standard commands. I'm not sure in the
case of fg, bg and wait. If my understanding of the POSIX standard is
correct, the builtins which should not ignore an initial `--' are:
break, dot, eval, shift, exec, exit, return, test/[ and continue. Zsh
gets all these right. Also, having noticed that `ARGV0=whatever exec
command' is clever enough to change the command name for the command
and not for exec, I don't think we should follow bash and ksh93 in
giving exec arguments. Though zsh can't easily do the -c functionality
which passes an empty environment.

--- Src/builtin.c	2002-08-28 08:22:23.000000000 +0100
+++ Src/builtin.c	2002-09-15 18:52:11.000000000 +0100
@@ -3024,9 +3024,15 @@
     zulong zulongval;
     char *stringval;
     
-    if (func == BIN_PRINTF)
+    if (func == BIN_PRINTF) {
+	if (!strcmp(*args, "--")) {
+	  if (!*++args) {
+	    zwarnnam(name, "not enough arguments", NULL, 0);
+	    return 1;
+          }
+	}
 	fmt = *args++;
-    else if (OPT_HASARG(ops,'f'))
+    } else if (OPT_HASARG(ops,'f'))
 	fmt = OPT_ARG(ops,'f');
     if (fmt)
 	fmt = getkeystring(fmt, &flen, OPT_ISSET(ops,'b') ? 2 : 0, &nnl);

This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.



Messages sorted by: Reverse Date, Date, Thread, Author