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

[PATCH] unmetafy Re: $var not expanded in ${x?$var}



On Wed, Feb 21, 2024 at 12:21 PM Stephane Chazelas
<stephane@xxxxxxxxxxxx> wrote:
>
> > What would you expect it to do?  You can't have it both raw and not
> > raw.
>
> I would expect it to write the NUL character ('\0') to stderr
[...]
> Maybe needs some unmetafy + fwrite.

Bleah, the argument to zerrmsg is const char * so can't be passed to
unmetafy without copy.

Is this more like it?
diff --git a/Src/subst.c b/Src/subst.c
index 650c09de2..ddf9f9de9 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -3272,7 +3272,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
                     *idend = '\0';
 		    if (*s){
 			singsub(&s);
-			zerr("%s: %s", idbeg, s);
+			zerr("%s: %S", idbeg, s);
 		    } else
 			zerr("%s: %s", idbeg, "parameter not set");
                     /*
diff --git a/Src/utils.c b/Src/utils.c
index 0fda92709..a15284815 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -123,6 +123,7 @@ set_widearray(char *mb_array, Widechar_array wca)
 
    Code	Argument types		Prints
    %s	const char *		C string (null terminated)
+   %S	const char *		C string (null terminated), output raw
    %l	const char *, int	C string of given length (null not required)
    %L	long			decimal value
    %d	int			decimal value
@@ -309,6 +310,10 @@ zerrmsg(FILE *file, const char *fmt, va_list ap)
 		str = va_arg(ap, const char *);
 		nicezputs(str, file);
 		break;
+	    case 'S':
+		str = va_arg(ap, const char *);
+		fwrite(unmetafy(dupstring(str), &num), num, 1, file);
+		break;
 	    case 'l': {
 		char *s;
 		str = va_arg(ap, const char *);


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