-
Notifications
You must be signed in to change notification settings - Fork 72
fix(wrapper): replace mktemp with POSIX-compliant temp dir creation in only-mvnw #418
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -160,8 +160,10 @@ case "${distributionUrl-}" in | |
| *) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; | ||
| esac | ||
|
|
||
| # prepare tmp dir | ||
| if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then | ||
| # prepare tmp dir (POSIX-compatible: avoid mktemp which is not available in all shells) | ||
| _tmp_base="${TMPDIR:-/tmp}" | ||
| TMP_DOWNLOAD_DIR="$_tmp_base/maven_wrapper.$$_$(date +%s)" | ||
| if mkdir -p -- "$TMP_DOWNLOAD_DIR" && [ -d "$TMP_DOWNLOAD_DIR" ]; then | ||
| clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } | ||
|
Comment on lines
+163
to
167
|
||
| trap clean HUP INT TERM EXIT | ||
| else | ||
|
|
||
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.
date +%sis not specified by POSIX and is missing on some platforms (incl. AIX), so this temp dir name generation can fail or produce non-unique names. Use a POSIX format (e.g.,date '+%Y%m%d%H%M%S') and/or a small looped suffix counter to guarantee uniqueness without relying on%s.