Skip to content

Commit eb5beeb

Browse files
committed
use tempfile to create temporary files instead of the process id so the filenames are less predictable
1 parent 733d827 commit eb5beeb

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

docs/source/history.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Dev
66

77
- Add support for ksh. Thanks to Doug Latornell for doing the
88
research on what needed to be changed.
9+
- Switch to ``tempfile`` command for creating temporary hook files.
910

1011
2.0.2
1112

virtualenvwrapper.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,11 @@ virtualenvwrapper_run_hook () {
8989
# First anything that runs directly from the plugin
9090
"$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION "$@"
9191
# Now anything that wants to run inside this shell
92+
hook_script=$(tempfile --directory "$VIRTUALENVWRAPPER_TMPDIR")
9293
"$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION \
93-
--source "$@" >>$VIRTUALENVWRAPPER_TMPDIR/$$.hook
94-
source $VIRTUALENVWRAPPER_TMPDIR/$$.hook
95-
rm -f $VIRTUALENVWRAPPER_TMPDIR/$$.hook
94+
--source "$@" >>"$hook_script"
95+
source "$hook_script"
96+
rm -f "$hook_script"
9697
}
9798

9899
# Set up virtualenvwrapper properly

0 commit comments

Comments
 (0)