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

Re: printf %b



Stephane Chazelas wrote:
> POSIX says
> 
> printf '\123'
> and
> printf %b '\0123'
> 
> should output "S" (note that the two syntaxes are different!)
> 
> and
> 
> printf '\0123' should output <NL>3
> printf %b '\123' should output \123 (I think).

Thanks, I hadn't found that bit.  At least the really world is screwed
up, too.

Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.171
diff -u -r1.171 builtin.c
--- Src/builtin.c	10 Dec 2006 23:27:03 -0000	1.171
+++ Src/builtin.c	4 Jan 2007 17:05:53 -0000
@@ -3490,7 +3490,7 @@
 	fmt = OPT_ARG(ops,'f');
     if (fmt)
 	fmt = getkeystring(fmt, &flen, OPT_ISSET(ops,'b') ? GETKEYS_BINDKEY :
-			   GETKEYS_PRINTF, &fmttrunc);
+			   GETKEYS_PRINTF_FMT, &fmttrunc);
 
     first = args;
     
@@ -3954,7 +3954,7 @@
 			b = getkeystring(metafy(curarg, curlen, META_USEHEAP),
 					 &l,
 					 OPT_ISSET(ops,'b') ? GETKEYS_BINDKEY :
-					 GETKEYS_PRINTF, &nnl);
+					 GETKEYS_PRINTF_ARG, &nnl);
 		    } else {
 			b = curarg;
 			l = curlen;
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.104
diff -u -r1.104 zsh.h
--- Src/zsh.h	4 Jan 2007 15:41:23 -0000	1.104
+++ Src/zsh.h	4 Jan 2007 17:05:55 -0000
@@ -1990,8 +1990,10 @@
  */
 /* echo builtin */
 #define GETKEYS_ECHO	(GETKEY_BACKSLASH_C)
-/* printf format string */
-#define GETKEYS_PRINTF	(GETKEY_BACKSLASH_C)
+/* printf format string:  \123 -> S, \0123 -> NL 3 */
+#define GETKEYS_PRINTF_FMT	(GETKEY_OCTAL_ESC|GETKEY_BACKSLASH_C)
+/* printf argument:  \123 -> \123, \0123 -> S */
+#define GETKEYS_PRINTF_ARG	(GETKEY_BACKSLASH_C)
 /* Full print without -e */
 #define GETKEYS_PRINT	(GETKEY_OCTAL_ESC|GETKEY_BACKSLASH_C|GETKEY_EMACS)
 /* bindkey */

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


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php



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