GNU bug report logs - #55837
Options `-p` and `--tmpdir` behave differently

Previous Next

Package: coreutils;

Reported by: Klaatu <klaatu <at> mixedsignals.ml>

Date: Wed, 8 Jun 2022 01:12:01 UTC

Severity: normal

Tags: notabug

Done: Bernhard Voelker <mail <at> bernhard-voelker.de>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 55837 in the body.
You can then email your comments to 55837 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#55837; Package coreutils. (Wed, 08 Jun 2022 01:12:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Klaatu <klaatu <at> mixedsignals.ml>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Wed, 08 Jun 2022 01:12:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Klaatu <klaatu <at> mixedsignals.ml>
To: bug-coreutils <at> gnu.org
Subject: Options `-p` and `--tmpdir` behave differently
Date: Wed, 08 Jun 2022 12:28:14 +1200
According to the man page, `--tmpfile` is the long option for `-p`
However, I get different results when using one or the other.
The `-p` option results in success:

<pre><code>
$ mktemp -p ~/Demo 
/home/klaatu/Demo/tmp.6TWPxScyKK
$ mktemp -p ~/Demo XXX
/home/klaatu/Demo/KdC
</code></pre>

However, `--tempdir` results in failure:

<pre><code>
$ mktemp --tmpdir ~/Demo 
mktemp: too few X's in template ‘/home/klaatu/Demo’
$ mktemp --tmpdir ~/Demo XXX
mktemp: too many templates
Try 'mktemp --help' for more information.
$ mktemp --tmpdir='~/Demo' XXX
mktemp: failed to create file via template ‘~/Demo/XXX’: No such file or 
directory
</code></pre>

Here's strace:

<pre><code>
$ mktemp --version
mktemp (GNU coreutils) 8.32

$ cat /etc/os-release | grep PRETTY
PRETTY_NAME="Red Hat Enterprise Linux 9.0 (Plow)"

$ strace mktemp --tmpdir ~/Demo XXX
execve("/usr/bin/mktemp", ["mktemp", "--tmpdir", "/home/klaatu/Demo", "XXX"], 
0x7ffdb6f6dee8 /* 51 vars */) = 0
brk(NULL)                               = 0x5589aecdf000
arch_prctl(0x3001 /* ARCH_??? */, 0x7ffc6717d8b0) = -1 EINVAL (Invalid 
argument)
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or 
directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=57851, ...}, AT_EMPTY_PATH) = 
0
mmap(NULL, 57851, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f2176368000
close(3)                                = 0
openat(AT_FDCWD, "/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220P\4\0\0\0\0\0"..., 
832) = 832
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 
784, 64) = 784
pread64(3, "\4\0\0\0 
\0\0\0\5\0\0\0GNU\0\2\0\0\300\4\0\0\0\3\0\0\0\0\0\0\0"..., 48, 848) = 48
pread64(3, "\4\0\0\0\24\0\0\0\3\0\0\0GNU\0y\356%$
[\271\321\0350\340\225\347\356&)\252"..., 68, 896) = 68
newfstatat(3, "", {st_mode=S_IFREG|0755, st_size=2389384, ...}, AT_EMPTY_PATH) 
= 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x7f2176366000
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 
784, 64) = 784
mmap(NULL, 2136752, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 
0x7f217615c000
mprotect(0x7f2176188000, 1880064, PROT_NONE) = 0
mmap(0x7f2176188000, 1531904, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|
MAP_DENYWRITE, 3, 0x2c000) = 0x7f2176188000
mmap(0x7f21762fe000, 344064, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 
3, 0x1a2000) = 0x7f21762fe000
mmap(0x7f2176353000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|
MAP_DENYWRITE, 3, 0x1f6000) = 0x7f2176353000
mmap(0x7f2176359000, 51888, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|
MAP_ANONYMOUS, -1, 0) = 0x7f2176359000
close(3)                                = 0
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x7f2176159000
arch_prctl(ARCH_SET_FS, 0x7f2176159740) = 0
set_tid_address(0x7f2176159a10)         = 42371
set_robust_list(0x7f2176159a20, 24)     = 0
mprotect(0x7f2176353000, 12288, PROT_READ) = 0
mprotect(0x5589adf75000, 4096, PROT_READ) = 0
mprotect(0x7f21763ab000, 8192, PROT_READ) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, 
rlim_max=RLIM64_INFINITY}) = 0
munmap(0x7f2176368000, 57851)           = 0
getrandom("\x40\x9a\x11\x9c\x8d\x3b\x6d\x8a", 8, GRND_NONBLOCK) = 8
brk(NULL)                               = 0x5589aecdf000
brk(0x5589aed00000)                     = 0x5589aed00000
openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=223542144, ...}, 
AT_EMPTY_PATH) = 0
mmap(NULL, 223542144, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f2168c29000
close(3)                                = 0
openat(AT_FDCWD, "/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=2998, ...}, AT_EMPTY_PATH) = 
0
read(3, "# Locale name alias data base.\n#"..., 4096) = 2998
read(3, "", 4096)                       = 0
close(3)                                = 0
openat(AT_FDCWD, "/usr/share/locale/en_NZ.UTF-8/LC_MESSAGES/coreutils.mo", 
O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_NZ.utf8/LC_MESSAGES/coreutils.mo", 
O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_NZ/LC_MESSAGES/coreutils.mo", O_RDONLY) 
= -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.UTF-8/LC_MESSAGES/coreutils.mo", 
O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo", 
O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = 
-1 ENOENT (No such file or directory)
write(2, "mktemp: ", 8mktemp: )                 = 8
write(2, "too many templates", 18too many templates)      = 18
write(2, "\n", 1
)                       = 1
write(2, "Try 'mktemp --help' for more inf"..., 42Try 'mktemp --help' for more 
information.
) = 42
close(1)                                = 0
close(2)                                = 0
exit_group(1)                           = ?
+++ exited with 1 +++
 </code></pre>







Information forwarded to bug-coreutils <at> gnu.org:
bug#55837; Package coreutils. (Wed, 08 Jun 2022 17:15:02 GMT) Full text and rfc822 format available.

Message #8 received at 55837 <at> debbugs.gnu.org (full text, mbox):

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: Klaatu <klaatu <at> mixedsignals.ml>, 55837 <at> debbugs.gnu.org
Subject: Re: bug#55837: Options `-p` and `--tmpdir` behave differently
Date: Wed, 8 Jun 2022 19:11:59 +0200
tag 55837 notabug
close 55837
stop

On 6/8/22 02:28, Klaatu wrote:
> According to the man page, `--tmpfile` is the long option for `-p`
> However, I get different results when using one or the other.
> The `-p` option results in success:
> 
> <pre><code>
> $ mktemp -p ~/Demo
> /home/klaatu/Demo/tmp.6TWPxScyKK
> $ mktemp -p ~/Demo XXX
> /home/klaatu/Demo/KdC
> </code></pre>
> 
> However, `--tempdir` results in failure:
> 
> <pre><code>
> $ mktemp --tmpdir ~/Demo
> mktemp: too few X's in template ‘/home/klaatu/Demo’
> $ mktemp --tmpdir ~/Demo XXX
> mktemp: too many templates
> Try 'mktemp --help' for more information.

The option --tmpdir is indeed the long option for -p, but it has to be used with
it's argument following immediately and beginning after the '=' character:

  $ mktemp --help | grep -- '-p.*tmpdir'
    -p DIR, --tmpdir[=DIR]  interpret TEMPLATE relative to DIR; if DIR is not

As the documentation states, the argument is optional, and therefore `mktemp`
took ~/Demo as pattern instead of argument to --tmpdir.

Use `mktemp --tmpdir=/some/dir` instead.

> $ mktemp --tmpdir='~/Demo' XXX
> mktemp: failed to create file via template ‘~/Demo/XXX’: No such file or
> directory
> </code></pre>

In this last code example, `mktemp` will receive the '~/Demo' literally because
the calling shell doesn't replace it with the real path (like /home/someuser/Demo)
as it usually would do without the quoting; therefore `mktemp` fails to create
a file there.

The program works as specified, and therefore I'm marking this as not a bug.

Have a nice day,
Berny




Added tag(s) notabug. Request was from Bernhard Voelker <mail <at> bernhard-voelker.de> to control <at> debbugs.gnu.org. (Wed, 08 Jun 2022 17:15:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 55837 <at> debbugs.gnu.org and Klaatu <klaatu <at> mixedsignals.ml> Request was from Bernhard Voelker <mail <at> bernhard-voelker.de> to control <at> debbugs.gnu.org. (Wed, 08 Jun 2022 17:15:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 07 Jul 2022 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 347 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.