I think this is a silly solution, and the documentation is clear
enough.

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.  If you
weren't familiar that the template has to be minimum 6 XXXXXX at
end of the string, then you hadn't achieved familiarity of the
subject matter yet.

>On Mon, Dec 25, 2017 at 08:36:07PM +0000, Stuart Henderson wrote:
>> 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.
>Fair enough, how about this?
>
>diff --git a/usr.bin/mktemp/mktemp.c b/usr.bin/mktemp/mktemp.c
>index 713b67fd105..96b6731ca90 100644
>--- a/usr.bin/mktemp/mktemp.c
>+++ b/usr.bin/mktemp/mktemp.c
>@@ -78,7 +78,7 @@ main(int argc, char *argv[])
> 
>       len = strlen(template);
>       if (len < 6 || strcmp(&template[len - 6], "XXXXXX")) {
>-              fatalx("insufficient number of Xs in template `%s'",
>+              fatalx("insufficient number of Xs at end of template `%s'",
>                   template);
>       }
>       if (tflag) {
>
>

Reply via email to