Subject: Re: [bug] Incorrect output from printf '{%-5.s}' 123456789
From: Bart Schaefer <[email-masked]>
To: Ryan Wilson <[email-masked]>, "[email-masked] " <[email-masked]>
Date: Thu, 21 Apr 2016 18:16:03 -0700
List-Id: Zsh Workers List <zsh-workers.zsh.org>

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++ = '*';
 	    }