mktemp can't create a file with a suffix/file extension

Bug #589408 reported by Tomas Pospisek
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
coreutils (Debian)
Fix Released
Unknown
coreutils (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

Binary package hint: coreutils

Package: coreuils
Version: 7.4-2ubuntu2
Release: 10.04

$ mktemp XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.png
mktemp: too few X's in template `XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.png'

WTF?!

$ mktemp tmp.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.png
mktemp: too few X's in template `tmp.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.png'

Say what again?

$ mktemp tmp.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
$

Allright, so mktemp seems to need a prefix.

That makes it quite useless for some task, like if you want to produces files of a specific "type", for today's luser-proof GUI Apps that won't list files that don't fit into their narrow horizon.

Tomas Pospisek (tpo-deb)
description: updated
Revision history for this message
C de-Avillez (hggdh2) wrote :

Thank you for opening this bug and helping make Ubuntu better. 'mktemp' does not need a prefixed template to work, 'mktemp whyXXXX' should work as well:

cerdea@xango2:~$ /bin/mktemp whyXXXX
whyev0E
cerdea@xango2:~$ /bin/mktemp why.XXXX
why.A972
cerdea@xango2:~$ /bin/mktemp --version
mktemp (GNU coreutils) 7.4
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jim Meyering.
cerdea@xango2:~$

Now, on *newer* coreutils, you would also be able to use a '--suffix' parameter:

cerdea@xango2:~$ /usr/local/bin/mktemp --suffix=.test whyXXXX
whySAE8.test
cerdea@xango2:~$ /usr/local/bin/mktemp --version
mktemp (GNU coreutils) 8.5.51-c0cfa0
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jim Meyering and Eric Blake.
cerdea@xango2:~$

As such, closing INVALID (not a bug)

Changed in coreutils (Ubuntu):
importance: Undecided → Low
status: New → Invalid
Revision history for this message
Tomas Pospisek (tpo-deb) wrote :

And what happens, when you leave out the 'why' prefix?

Changed in coreutils (Ubuntu):
status: Invalid → New
Revision history for this message
C de-Avillez (hggdh2) wrote :

It works as expected, for both 7.4 (Lucid) and GIT head.

cerdea@xango2:~$ /bin/mktemp XXXX
KtiV
cerdea@xango2:~$ /usr/local/bin/mktemp XXXX
NyAi
cerdea@xango2:~$

Please give a reason for a status change. A question -- what sounds like one, at least -- is not a reason.

Closing INVALID (not a bug).

Changed in coreutils (Ubuntu):
status: New → Invalid
Changed in coreutils (Debian):
status: Unknown → Fix Released
Tomas Pospisek (tpo-deb)
summary: - mktemp seems to need a prefixed template to work
+ mktemp can't create a file with a suffix/file extension
Revision history for this message
Tomas Pospisek (tpo-deb) wrote :

> Please give a reason for a status change. A question -- what sounds like one, at least -- is not a reason.

Changed the title accordingly, to express the actual problem.

The point being:

1. one needs to be able to create temporary files that have a filename extensions/suffixes, since most of todays Gnome/KDE GUI programms expect files to have filename extensions

2. mktemp can't do filename extensions

3. the error message being displayed, when using tryng to create files with fileextension is wrong.

4. the manpage doesn't say *anything* about how TEMPLATES should or should not look like and the info page is missing

5. AFAIK the previous separate mktemp (from OpenBSD I think) worked as expected, so that would be a regression

6. coreutils 8.5 fixes the problem

Here I go having spelled the problem character by character to make the real problem clear.

So the logical next step would seem to be to flag the real problem as such (Wishlist) in order for it to be fixed. However users can't do that in Ubuntu. Would you mind fixing this problem that exists for real?

Revision history for this message
C de-Avillez (hggdh2) wrote :

> Here I go having spelled the problem character by character to make the real problem clear.

You might want to consider doing that on your next bugs as well -- both spelling the problem character by character, and giving the bug a nice title. We would not have lost that much time if you had done so from the beginning.

> So the logical next step would seem to be to flag the real problem as such (Wishlist)
> in order for it to be fixed. However users can't do that in Ubuntu. Would you mind
> fixing this problem that exists for real?

Not at all, considering the suffix problem that indeed exists (and not a prefix problem that did not). Set to triaged/Medium. Frankly, I do not see it as WishList, if the suffix functionality was available on the previous incarnation of 'mktemp'.

The fix should be available for Maverick when we sync coreutils from Debian. If you need it in a previous version, please nominate accordingly, and *give a strong reason of why it is needed*. This fix will, then, be considered for a SRU (Stable Release Update).

Changed in coreutils (Ubuntu):
importance: Low → Medium
status: Invalid → Triaged
Revision history for this message
Tomas Pospisek (tpo-deb) wrote :

On Fri, 4 Jun 2010, C de-Avillez wrote:

>> Here I go having spelled the problem character by character to make
> the real problem clear.
>
> You might want to consider doing that on your next bugs as well -- both
> spelling the problem character by character, and giving the bug a nice
> title. We would not have lost that much time if you had done so from the
> beginning.

Thanks, very cool!

>> So the logical next step would seem to be to flag the real problem as such (Wishlist)
>> in order for it to be fixed. However users can't do that in Ubuntu. Would you mind
>> fixing this problem that exists for real?
>
> Not at all, considering the suffix problem that indeed exists (and not a
> prefix problem that did not). Set to triaged/Medium. Frankly, I do not
> see it as WishList, if the suffix functionality was available on the
> previous incarnation of 'mktemp'.

Unfortunately I rechecked (I installed the old mktemp tool from Debian)
and it wasn *not* able to create files with suffixes either.

Even worse, it would create the file "XXXXXX.bla" as such without
replacing the 'X'es without complaining.

> The fix should be available for Maverick when we sync coreutils from
> Debian. If you need it in a previous version, please nominate
> accordingly, and *give a strong reason of why it is needed*. This fix
> will, then, be considered for a SRU (Stable Release Update).

Considering the above I think releasing Maverick synched to Debian's
coreutils is fine.

Thanks again,
*t

Revision history for this message
C de-Avillez (hggdh2) wrote :

coreutils (8.5-1ubuntu1) has been released on Maverick, with support for '--suffix=', which addresses this bug:

cerdea@xango2:/build/buildd/uec/uec-testing-scripts$ /bin/mktemp --help
Usage: /bin/mktemp [OPTION]... [TEMPLATE]
Create a temporary file or directory, safely, and print its name.
TEMPLATE must contain at least 3 consecutive `X's in last component.
If TEMPLATE is not specified, use tmp.XXXXXXXXXX, and --tmpdir is implied.

  -d, --directory create a directory, not a file
  -u, --dry-run do not create anything; merely print a name (unsafe)
  -q, --quiet suppress diagnostics about file/dir-creation failure
      --suffix=SUFF append SUFF to TEMPLATE. SUFF must not contain slash.
                        This option is implied if TEMPLATE does not end in X.
      --tmpdir[=DIR] interpret TEMPLATE relative to DIR. If DIR is not
                        specified, use $TMPDIR if set, else /tmp. With
                        this option, TEMPLATE must not be an absolute name.
                        Unlike with -t, TEMPLATE may contain slashes, but
                        mktemp creates only the final component

  -p DIR use DIR as a prefix; implies -t [deprecated]
  -t interpret TEMPLATE as a single file name component,
                        relative to a directory: $TMPDIR, if set; else the
                        directory specified via -p; else /tmp [deprecated]

      --help display this help and exit
      --version output version information and exit

Report mktemp bugs to <email address hidden>
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'mktemp invocation'
cerdea@xango2:/build/buildd/uec/uec-testing-scripts$

Changed in coreutils (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.