Open tertsdiepraam opened 1 year ago
I think this touches on a larger question about the direction of the project on Windows. Which is: should we follow GNU or Windows conventions?
Following GNU conventions gives us more compatibility with ourselves on different platforms, but following Windows conventions gives us more compatibility with other Windows utilities.
Personally, I'm leaning towards following GNU, because the promise that you can take any script using uutils and run it without problems on any supported platform is really useful.
I think this specific issue can be solved with a compromise.
So I'll propose something like 2 but a predictable fallback. If TMPDIR
is defined use it, which will make it consistent with the GNU and enables cross-platform operation, otherwise pull the temp directory from std::env::tmp_dir
which will make Windows applications happy.
Sounds good!
mktemp
usesenv::temp_dir
to get the default temporary directory. The behaviour of this function is different between platforms, which is confusing for writing cross-platforms scripts (which is supposed to be a strength of uutils!).Here's what's different:
TMPDIR
is ignored.TMP
,TEMP
andUSERPROFILE
are ignored.TMPDIR
is a relative path, a relative path is printed.So we have a couple of options.
std::env::temp_dir
from Unix. This makes it consistent, but a bit weird on Windows, because we ignore standard environment variables.TMPDIR
to the Windows implementation. This helps consistency, but then Unix does not behave like Windows.TMPDIR
,TMP
&TEMP
). This is consistent between platforms, but not consistent with GNU.Any opinions on this?