20100427

mktemp portability

If you ever need to create a script, to run in the closest possible way in all the unix flavours -
beware of HP-UX behaviour of mktemp command.

It is the only unix system (I know) where mktemp do not create randomly named file/directory.

The result of its actions is just a display of generated name.

2 comments:

ampledata said...

According to the HP UX mktemp(1) man page that's the expected behavior:

mktemp makes a name that is suitable for use as the pathname of a temporary file, and writes that name to the standard output.

But I get your point, Solaris' mktemp(1) man page is vague:

The mktemp utility makes a temporary filename.

It makes a temporary file NAME, it doesn't say that it makes a temporary FILE, which it actually does.

My hats off to HP UX for at least being explicit (if not somewhat limited).

Marcin Wiśnios said...

I agree.

Maybe it is not so handy as the other UX'es but I can not deny - HP-UX is the only one where the rights are fully respected.

Good example is swreg. When it has been executed with the option of run_as_superuser=false it makes the installation of package being prohibited to the privileged ones, even to root.

Hats off.