1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

mktemp: note that windows uses a different env var for tmpdir

On windows `std::env::temp_dir` uses the `TMP` environment variable
instead of `TMPDIR`.
This commit is contained in:
Michael Debertol 2021-06-22 17:36:56 +02:00
parent e5a7bcbb9d
commit 622504467f
2 changed files with 5 additions and 2 deletions

View file

@ -77,14 +77,14 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.long(OPT_TMPDIR) .long(OPT_TMPDIR)
.help( .help(
"interpret TEMPLATE relative to DIR; if DIR is not specified, use \ "interpret TEMPLATE relative to DIR; if DIR is not specified, use \
$TMPDIR if set, else /tmp. With this option, TEMPLATE must not \ $TMPDIR ($TMP on windows) if set, else /tmp. With this option, TEMPLATE must not \
be an absolute name; unlike with -t, TEMPLATE may contain \ be an absolute name; unlike with -t, TEMPLATE may contain \
slashes, but mktemp creates only the final component", slashes, but mktemp creates only the final component",
) )
.value_name("DIR"), .value_name("DIR"),
) )
.arg(Arg::with_name(OPT_T).short(OPT_T).help( .arg(Arg::with_name(OPT_T).short(OPT_T).help(
"Generate a template (using the supplied prefix and TMPDIR if set) \ "Generate a template (using the supplied prefix and TMPDIR (TMP on windows) if set) \
to create a filename template [deprecated]", to create a filename template [deprecated]",
)) ))
.arg( .arg(

View file

@ -17,7 +17,10 @@ static TEST_TEMPLATE8: &str = "tempXXXl/ate";
#[cfg(windows)] #[cfg(windows)]
static TEST_TEMPLATE8: &str = "tempXXXl\\ate"; static TEST_TEMPLATE8: &str = "tempXXXl\\ate";
#[cfg(not(windows))]
const TMPDIR: &str = "TMPDIR"; const TMPDIR: &str = "TMPDIR";
#[cfg(windows)]
const TMPDIR: &str = "TMP";
#[test] #[test]
fn test_mktemp_mktemp() { fn test_mktemp_mktemp() {