On Tue, Dec 26, 2017 at 12:31:02AM +0100, Klemens Nanni wrote: > On Mon, Dec 25, 2017 at 03:57:00PM -0700, Theo de Raadt wrote: > > I think this is a silly solution, and the documentation is clear > > enough. > The manual page certainly is clear enough but the current error message > is logically wrong, as there are sufficient Xs *in* `XXXXXXs' but just > not at the end of it, call it nitpicking if you will. > > > How did this happen to you? Show the place where it happened to you. > > Would the text you propose actually have saved you 1 second of time > > to help you realize what was wrong? I don't think so. > Just a typo really making me think "this could be clearer". So yes, I > find telling this way actually saves time understanding the error, even > if so little.
I think your error message is too complex. It explains two possible error cases in a single go. This necessitates more thinking on the part of the user. Why not just acknowledge the two errors differently? $ mktemp test.XXXXX mktemp: insufficient number of Xs in template: test.XXXXX $ mktemp test.XXXXXXC mktemp: invalid template suffix: test.XXXXXXC # mktemp test.XXXXXX test.KJ9TG4 -- Scott Cheloha Index: mktemp.1 =================================================================== RCS file: /cvs/src/usr.bin/mktemp/mktemp.1,v retrieving revision 1.28 diff -u -p -r1.28 mktemp.1 --- mktemp.1 7 Aug 2013 06:19:36 -0000 1.28 +++ mktemp.1 26 Dec 2017 13:53:18 -0000 @@ -228,12 +228,17 @@ does not succeed and the .Fl q option was not specified: .Bl -tag -width indent +.It Li "invalid template suffix" +The specified +.Ar template +was suffixed with something other than +.Ql X Ns s. .It Li "insufficient number of Xs in template" The specified .Ar template contained fewer than six .Ql X Ns s -at the end. +in its suffix. .It Li "template must not contain directory separators in -t mode" The .Ar template Index: mktemp.c =================================================================== RCS file: /cvs/src/usr.bin/mktemp/mktemp.c,v retrieving revision 1.22 diff -u -p -r1.22 mktemp.c --- mktemp.c 9 Oct 2015 01:37:08 -0000 1.22 +++ mktemp.c 26 Dec 2017 13:53:18 -0000 @@ -77,10 +77,10 @@ main(int argc, char *argv[]) } len = strlen(template); - if (len < 6 || strcmp(&template[len - 6], "XXXXXX")) { - fatalx("insufficient number of Xs in template `%s'", - template); - } + if (template[len - 1] != 'X') + fatalx("invalid template suffix: %s", template); + if (len < 6 || strcmp(&template[len - 6], "XXXXXX")) + fatalx("insufficient number of Xs in template: %s", template); if (tflag) { if (strchr(template, '/')) { fatalx("template must not contain directory "