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.

Full log


Message #10 received at control <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




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.