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

Re: PATCH: support \u and \U in echo/print/$''



I wrote:
> '\unnnn' instead of one or other of the error messages. It should probably
> be consistent with \xx - currently \xZZ prints `ZZ'. I'd have thought
> `\xZZ' would be better. sh, ksh, bash and coreutils vary on this. Any
> thoughts?

Apparently, \xZZ prints a null followed by `ZZ'. So it allows less than
two digits. This is nice and easy to implement so the patch below, to
go on top of the previous makes \u consistent with \x.

The other two errors - where it is unable to convert the character are
still there as messages.

> Also, should this be disabled in sh emulation? Is it okay to just do

It seems not - SUSv3 apparently leaves other sequences after a backslash
as "unspecified".

Oliver

--- utils.c	2003-03-12 20:09:08.000000000 +0100
+++ utils.c	2003-03-13 00:04:56.000000000 +0100
@@ -3402,14 +3402,8 @@
 		            (*s >= 'A' && *s <= 'F'))
 		        wval = wval * 16 + (*s & 0x1f) + 9;
 		    else {
-		        zerr("expected hexadecimal digit", NULL, 0);
-			if (fromwhere == 4) {
-			    for (u = t; (*u++ = *++s););
-			    return t;
-			}
-			*t = '\0';
-			*len = t - buf;
-			return buf;
+		    	s--;
+		        break;
 		    }
 		}
     	    	if (fromwhere == 6) {



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