From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 07 21:11:26 2022 Received: (at submit) by debbugs.gnu.org; 8 Jun 2022 01:11:26 +0000 Received: from localhost ([127.0.0.1]:41953 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nykEF-0000ww-7T for submit@debbugs.gnu.org; Tue, 07 Jun 2022 21:11:26 -0400 Received: from lists.gnu.org ([209.51.188.17]:37368) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nyja9-0008Lk-Hq for submit@debbugs.gnu.org; Tue, 07 Jun 2022 20:29:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyja9-0007p0-Bb for bug-coreutils@gnu.org; Tue, 07 Jun 2022 20:29:57 -0400 Received: from jaguar.webhosting.coop ([199.241.219.43]:46190) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyja6-0001Oe-9A for bug-coreutils@gnu.org; Tue, 07 Jun 2022 20:29:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mixedsignals.ml; s=default; h=Content-Type:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=p+P7qAPU4P3SwVu/a4oLIlZx+hexcRtNmzu0q+jlaxU=; b=J2dPcXfAueI1+IhnEGQVRhQ+vG JSAuZR87GoaNgLFqv+ADUHtU5SQ56Nnees5CMQVeLD8hNgxLFLickehHxE5m9ajPs8Vaq+hYUHj+J TjdjjUUTWPzSHRmBrLHWIHLO6DqVeC70eh5oi/6CUYTOQxobZ5n7Hw+1QWUrEw/bOFnZWIqGL/f/v eG3OEX4+ZWvLemBo7vrMprCiiAoF/rCsaLkt6NufhepeU2SHtOkBRIATRfuuqapg1WYfnlX04AXyR rxsKWfrTRMNNjX7tqR8tcEjTexwWDzF19LWwLNdd3mGwJjs0jX8pYSMP9l6NoL1utc4XRSo0IFcRg 7DbUZSeQ==; Received: from 222-152-75-205-fibre.sparkbb.co.nz ([222.152.75.205]:39250 helo=beast.slackermedia.local) by jaguar.webhosting.coop with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1nyjZV-0008Gz-Co for bug-coreutils@gnu.org; Tue, 07 Jun 2022 19:29:13 -0500 From: Klaatu To: bug-coreutils@gnu.org Subject: Options `-p` and `--tmpdir` behave differently Date: Wed, 08 Jun 2022 12:28:14 +1200 Message-ID: <2193203.vFx2qVVIhK@beast.slackermedia.local> Organization: Slackermedia MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - jaguar.webhosting.coop X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - mixedsignals.ml X-Get-Message-Sender-Via: jaguar.webhosting.coop: authenticated_id: klaatu@mixedsignals.ml X-Authenticated-Sender: jaguar.webhosting.coop: klaatu@mixedsignals.ml X-Source: X-Source-Args: X-Source-Dir: Received-SPF: pass client-ip=199.241.219.43; envelope-from=klaatu@mixedsignals.ml; helo=jaguar.webhosting.coop X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Tue, 07 Jun 2022 21:11:22 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) 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:

$ mktemp -p ~/Demo=20
/home/klaatu/Demo/tmp.6TWPxScyKK
$ mktemp -p ~/Demo XXX
/home/klaatu/Demo/KdC
However, `--tempdir` results in failure:

$ mktemp --tmpdir ~/Demo=20
mktemp: too few X's in template =E2=80=98/home/klaatu/Demo=E2=80=99
$ mktemp --tmpdir ~/Demo XXX
mktemp: too many templates
Try 'mktemp --help' for more information.
$ mktemp --tmpdir=3D'~/Demo' XXX
mktemp: failed to create file via template =E2=80=98~/Demo/XXX=E2=80=99: No=
 such file or=20
directory
Here's strace:

$ mktemp --version
mktemp (GNU coreutils) 8.32

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

$ strace mktemp --tmpdir ~/Demo XXX
execve("/usr/bin/mktemp", ["mktemp", "--tmpdir", "/home/klaatu/Demo", "XXX"=
],=20
0x7ffdb6f6dee8 /* 51 vars */) =3D 0
brk(NULL)                               =3D 0x5589aecdf000
arch_prctl(0x3001 /* ARCH_??? */, 0x7ffc6717d8b0) =3D -1 EINVAL (Invalid=20
argument)
access("/etc/ld.so.preload", R_OK)      =3D -1 ENOENT (No such file or=20
directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) =3D 3
newfstatat(3, "", {st_mode=3DS_IFREG|0644, st_size=3D57851, ...}, AT_EMPTY_=
PATH) =3D=20
0
mmap(NULL, 57851, PROT_READ, MAP_PRIVATE, 3, 0) =3D 0x7f2176368000
close(3)                                =3D 0
openat(AT_FDCWD, "/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) =3D 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"..=
=2E,=20
832) =3D 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".=
=2E.,=20
784, 64) =3D 784
pread64(3, "\4\0\0\0=20
\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) =3D 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) =3D 68
newfstatat(3, "", {st_mode=3DS_IFREG|0755, st_size=3D2389384, ...}, AT_EMPT=
Y_PATH)=20
=3D 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
=3D=20
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".=
=2E.,=20
784, 64) =3D 784
mmap(NULL, 2136752, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) =3D=20
0x7f217615c000
mprotect(0x7f2176188000, 1880064, PROT_NONE) =3D 0
mmap(0x7f2176188000, 1531904, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|
MAP_DENYWRITE, 3, 0x2c000) =3D 0x7f2176188000
mmap(0x7f21762fe000, 344064, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE=
,=20
3, 0x1a2000) =3D 0x7f21762fe000
mmap(0x7f2176353000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|
MAP_DENYWRITE, 3, 0x1f6000) =3D 0x7f2176353000
mmap(0x7f2176359000, 51888, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|
MAP_ANONYMOUS, -1, 0) =3D 0x7f2176359000
close(3)                                =3D 0
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
=3D=20
0x7f2176159000
arch_prctl(ARCH_SET_FS, 0x7f2176159740) =3D 0
set_tid_address(0x7f2176159a10)         =3D 42371
set_robust_list(0x7f2176159a20, 24)     =3D 0
mprotect(0x7f2176353000, 12288, PROT_READ) =3D 0
mprotect(0x5589adf75000, 4096, PROT_READ) =3D 0
mprotect(0x7f21763ab000, 8192, PROT_READ) =3D 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=3D8192*1024,=20
rlim_max=3DRLIM64_INFINITY}) =3D 0
munmap(0x7f2176368000, 57851)           =3D 0
getrandom("\x40\x9a\x11\x9c\x8d\x3b\x6d\x8a", 8, GRND_NONBLOCK) =3D 8
brk(NULL)                               =3D 0x5589aecdf000
brk(0x5589aed00000)                     =3D 0x5589aed00000
openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) =3D 3
newfstatat(3, "", {st_mode=3DS_IFREG|0644, st_size=3D223542144, ...},=20
AT_EMPTY_PATH) =3D 0
mmap(NULL, 223542144, PROT_READ, MAP_PRIVATE, 3, 0) =3D 0x7f2168c29000
close(3)                                =3D 0
openat(AT_FDCWD, "/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) =3D 3
newfstatat(3, "", {st_mode=3DS_IFREG|0644, st_size=3D2998, ...}, AT_EMPTY_P=
ATH) =3D=20
0
read(3, "# Locale name alias data base.\n#"..., 4096) =3D 2998
read(3, "", 4096)                       =3D 0
close(3)                                =3D 0
openat(AT_FDCWD, "/usr/share/locale/en_NZ.UTF-8/LC_MESSAGES/coreutils.mo",=
=20
O_RDONLY) =3D -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_NZ.utf8/LC_MESSAGES/coreutils.mo",=20
O_RDONLY) =3D -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_NZ/LC_MESSAGES/coreutils.mo", O_RDON=
LY)=20
=3D -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.UTF-8/LC_MESSAGES/coreutils.mo",=20
O_RDONLY) =3D -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo",=20
O_RDONLY) =3D -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY)=
 =3D=20
=2D1 ENOENT (No such file or directory)
write(2, "mktemp: ", 8mktemp: )                 =3D 8
write(2, "too many templates", 18too many templates)      =3D 18
write(2, "\n", 1
)                       =3D 1
write(2, "Try 'mktemp --help' for more inf"..., 42Try 'mktemp --help' for m=
ore=20
information.
) =3D 42
close(1)                                =3D 0
close(2)                                =3D 0
exit_group(1)                           =3D ?
+++ exited with 1 +++
 
From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 08 13:14:21 2022 Received: (at 55837) by debbugs.gnu.org; 8 Jun 2022 17:14:21 +0000 Received: from localhost ([127.0.0.1]:44198 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nyzG8-0003To-UC for submit@debbugs.gnu.org; Wed, 08 Jun 2022 13:14:21 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:44497) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nyzG6-0003TR-3q; Wed, 08 Jun 2022 13:14:19 -0400 Received: from [10.0.2.16] ([109.77.156.236]) by mrelayeu.kundenserver.de (mreue108 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MMXcP-1oIRwB0hq3-00Jely; Wed, 08 Jun 2022 19:13:24 +0200 Message-ID: <5e4527eb-e32c-c911-2805-40f0d5399855@bernhard-voelker.de> Date: Wed, 8 Jun 2022 19:11:59 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: bug#55837: Options `-p` and `--tmpdir` behave differently Content-Language: en-US To: Klaatu , 55837@debbugs.gnu.org References: <2193203.vFx2qVVIhK@beast.slackermedia.local> From: Bernhard Voelker In-Reply-To: <2193203.vFx2qVVIhK@beast.slackermedia.local> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:6GnOrvNVfdkwqHhRyBO6TWSkVy7/ZSHnQ0dVP5IWH1dBZJ92mu4 UHsGjyWDtft4BWCmg0OUkzJ/lF1uCMTIk/dzny/WD3viU1gPdWvE/CQq5zpDfwFNc5DugFF QfHZRVfAXZq8x6SYl6NEv1COfKGzPRFEqy1ZOyVbpM1b7LW1vVCCPpckmbCJIVt2bsxUIRh akIJ3ojtEVi81fQsB5Cig== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:b/pafoK+aps=:VszIvj+bn08n534jGZWr7u jGd5JubAQVy6utdoeVz72wtUP4bnw0NKnbnEFwKjUsezsQJbJMoxq7c33jn/R8vXEwLT/VI48 Lq9sHfVoaXm17JdI/8WUKa/IPSlIaFSGzZF1DXbM2p1LUaw5W2UIZHcpM/SS4yWAZN6dbC290 bGzc+GuMPZav7dsJEVVgfSgx/w+mIuMbTggEGzApqwXpURjRRQxC33nRHXM83gMZ5ATwdvcHu UYRqxZgXXe9ExZPYEmCbbpNnr4eZRZmZHYsNPq3Fa9aYMXwJNyNRXsET88GAdzC6NS/fMMSnF 3ZMxRww+WdZayQszKa4C79sdd1a1i9roL9lrZZQTJNxNSZYo8z/iyRacvM25yAtgasaPAawhX 7NvFLXoZ8ZRyR3okVSLJXfRxArTzgY7PnfDmYijLbocxMyMzV0SIWqKL1AmjlgSV6UhyF7C21 LLhwJklERyCz5QfKuKLDQ9Lv56ifbFxIwIha62nx3RLJF8OQH+f88xB4s1UccgOhI1eQxvpIZ mtz/lN0PIHmjpLZdzxhcewFZ2OUJlnGDCJZDobzuo17UTrkOioAKJj+NMkg4ACLOoGHDeWc2Z 89rOKsrwSWTwCGIKcE3jAB+v3A8dsTYyIVraszarLkRl95aVg8O/nGm2jUcOiZhKr68nxnsuZ XCW80s9Hn0iAgx1yxsW6SheOVd0wPc5G0AVKBMrLhjw4LOgx9WgEE5g2V1dRxCRsoFvPQgFW5 fWMgPwJz1HCbO/JthjZCLxtH8JEbnnenXHpzJG2Q/yo4mYpjWHsXVBflRgg= X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 55837 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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: > >

> $ mktemp -p ~/Demo
> /home/klaatu/Demo/tmp.6TWPxScyKK
> $ mktemp -p ~/Demo XXX
> /home/klaatu/Demo/KdC
> 
> > However, `--tempdir` results in failure: > >

> $ 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
> 
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 From unknown Wed Jun 18 23:11:15 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 07 Jul 2022 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator