mktemp(1) sometimes ignores its -p option
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
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.