On 2017/12/25 20:52, Klemens Nanni wrote: > from mktemp(1): > > The template may be any filename with at least six ‘Xs’ appended > to it, for example /tmp/tfile.XXXXXXXXXX. > > Now when a template contains but does not end in six Xs, the error > message may imply errornous behaviour instead of bad usage: > > $ mktemp XXXXXX > oAQnQ5 > $ mktemp XXXXXXs > mktemp: insufficient number of Xs in template `XXXXXXs' > > I'd like to see a more precise error message here. > > Feedback? > > diff --git a/usr.bin/mktemp/mktemp.c b/usr.bin/mktemp/mktemp.c > index 713b67fd105..c080d1d6474 100644 > --- a/usr.bin/mktemp/mktemp.c > +++ b/usr.bin/mktemp/mktemp.c > @@ -77,10 +77,9 @@ 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 (len < 6 || strcmp(&template[len - 6], "XXXXXX")) > + fatalx("template must end in six or more Xs"); > + > if (tflag) { > if (strchr(template, '/')) { > fatalx("template must not contain directory " >
Printing the actual template used makes it easier to track down the problematic call.