[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#55837: Options `-p` and `--tmpdir` behave differently
From: |
Bernhard Voelker |
Subject: |
bug#55837: Options `-p` and `--tmpdir` behave differently |
Date: |
Wed, 8 Jun 2022 19:11:59 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 |
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