Bug #10047
mktemp(1) sometimes ignores its -p option
0%
Description
On a fresh OpenIndiana installation
(The Illumos Project SunOS 5.11 illumos-7d1eae8c55 December 2018)
the mktemp(1) command seems sensitive to the order of its -p and -t options
and may ignore the existence of "-p DIRECTORY" option, using /tmp rather
than DIRECTORY. The error is strange, as it only occurs if mktemp is invoked
within a shell script, but not from the command-line in a terminal window.
The error also requires that mktemp is invoked without absolute path.
Create a file named SHOWBUG containing the following code
#! /bin/sh # to know the current shell echo $SHELL # to know which mktemp is invoked which mktemp # to create a working directory mkdir -p "$HOME/tmp" mktemp -d -p "$HOME/tmp" -t "file.XXXX" mktemp -d -t -p "$HOME/tmp" "file.XXXX" /bin/mktemp -d -p "$HOME/tmp" -t "file.XXXX" /bin/mktemp -d -t -p "$HOME/tmp" "file.XXXX" /usr/bin/mktemp -d -p "$HOME/tmp" -t "file.XXXX" /usr/bin/mktemp -d -t -p "$HOME/tmp" "file.XXXX"
Then, type the commands
$ chmod a+rx SHOWBUG
$ ./SHOWBUG
which produces output such as:
/bin/bash /usr/bin/mktemp /tmp/file.3k9r /export/home/cadp/tmp/file.1u8s /export/home/cadp/tmp/file.IgXR /export/home/cadp/tmp/file.KoXR /export/home/cadp/tmp/file.MwXR /export/home/cadp/tmp/file.NUWR
The 3rd line is clearly incorrect.
The problem does not seem to occur if the commands
are typed in a terminal windows rather than being put
in the SHOWBUG file.
Updated by Gary Mills about 2 years ago
Which version are you talking about? There are two in OI. One is /usr/bin/mktemp . The other is /usr/gnu/bin/mktemp .
Updated by Hubert Garavel about 2 years ago
Hi,
/usr/bin/mktemp (this is confirmed by the "which" command in the script)