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

Re: [bug] Incorrect output from printf '{%-5.s}' 123456789



On Apr 21,  5:21pm, Ryan Wilson wrote:
} Subject: [bug] Incorrect output from printf '{%-5.s}' 123456789
}
} It appears that zsh doesn't handle the precision specifier for %s
} correctly in the printf builtin:
} 
} % builtin printf '{%-5.s}' 123456789
} {123456789}

Well, hrm.

diff --git a/Src/builtin.c b/Src/builtin.c
index 4c8fbcd..ad01ad4 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -4736,7 +4736,8 @@ bin_print(char *name, char **args, Options ops, int func)
 		} else if (idigit(*c)) {
 		    prec = strtoul(c, &endptr, 0);
 		    c = endptr;
-		}
+		} else
+		    prec = 0;
 		if (prec >= 0) *d++ = '.', *d++ = '*';
 	    }
 



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