Skip to content

Commit 1185985

Browse files
committed
Fix double-quoted trap in tfenv-install to handle paths safely
Fix #455: Replace double-quoted trap string with a cleanup function. The previous "rm -rf ${download_tmp}" trap expanded the variable at definition time without quotes, making it vulnerable to word-splitting if the temp path contained spaces. Using a function reference ensures the variable is expanded at execution time with proper quoting.
1 parent fa8d238 commit 1185985

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

libexec/tfenv-install

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ fi;
170170
download_tmp="$(mktemp -d ${tmpdir_arg} tfenv_download.XXXXXX)" || log 'error' "Unable to create temporary download directory (mktemp -d ${tmpdir_arg} tfenv_download.XXXXXX). Working Directory is: $(pwd)";
171171

172172
# Clean it up in case of error
173-
trap "rm -rf ${download_tmp}" EXIT;
173+
cleanup_download() { rm -rf "${download_tmp}"; }
174+
trap cleanup_download EXIT;
174175

175176
declare curl_progress="";
176177
case "${TFENV_CURL_OUTPUT:-2}" in

0 commit comments

Comments
 (0)