-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mktemp -t foo.XXXX should create in TMPDIR #4832
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the PR is incomplete because mktemp -t -p ~/projects/playground foo.XXXX
doesn't work as expected if $TMPDIR
is not set: it creates the file in /tmp
instead of ~/projects/playground
.
From the GNU mktemp documentation:
-t
interpret TEMPLATE as a single file name component,
relative to a directory: $TMPDIR, if set; else the
directory specified via -p; else /tmp [deprecated]
GNU testsuite comparison:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not quite complete yet ;-)
With GNU mktemp:
$ TMPDIR=dir_a mktemp -t -p dir_b foo.XXXX
dir_a/foo.CnlA
With uutils mktemp:
$ TMPDIR=dir_a cargo run mktemp -t -p dir_b foo.XXXX
dir_b/foo.DAXt
sure but afaik, i didn't regress this issue :) |
Ah no, it's not a regression, I just didn't test this variant in my first review :) |
GNU testsuite comparison:
|
GNU testsuite comparison:
|
src/uu/mktemp/src/mktemp.rs
Outdated
// Ignore TMPDIR when it's set to "." | ||
if tmpdir_env == "." { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you ignore .
? GNU mktemp accepts it:
$ TMPDIR=. mktemp -t -p dir_b foo.XXXX
./foo.6Nai
src/uu/mktemp/src/mktemp.rs
Outdated
@@ -191,7 +191,22 @@ impl Options { | |||
(tmpdir, template.to_string()) | |||
} | |||
Some(template) => { | |||
let tmpdir = matches.get_one::<String>(OPT_TMPDIR).map(String::from); | |||
let tmpdir = if let Ok(tmpdir_env) = env::var("TMPDIR") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need an additional condition here. It currently breaks the GNU tests because GNU mktemp ignores TMPDIR
in the following case:
$ TMPDIR=dir_a mktemp foo.XXXX
foo.fgPS
this is why i would have prefer to land the previous commit as i didn't introduce a regression ;) |
I removed the last patch of the stack It doesn't fix |
Sorry, I misunderstood what you meant with "regression" :| |
GNU testsuite comparison:
|
yeah, sorry :) i use that word every day at Mozilla :) By regression, i meant that this current PR is still an improvement over the current main. Even if it isn't perfect as you noticed :) |
closes: #4821