File tree Expand file tree Collapse file tree 4 files changed +33
-2
lines changed Expand file tree Collapse file tree 4 files changed +33
-2
lines changed Original file line number Diff line number Diff line change
1
+ 2011-04-13 Doug Hellmann <
[email protected] >
2
+
3
+ * virtualenvwrapper.sh (rmvirtualenv): Move to a safe directory
4
+ before removing the virtual environment, and only move back if the
5
+ previously occupied directory still exists.
6
+
1
7
2011-04-10 Doug Hellmann <
[email protected] >
2
8
3
9
* virtualenvwrapper.sh: Initialize VIRTUALENVWRAPPER_LOG_DIR and
Original file line number Diff line number Diff line change 29
29
locations of hooks and logs.
30
30
- Enabled tab completion for :ref: `command-showvirtualenv `
31
31
(:bbissue: `78 `).
32
+ - Fixed a problem with running :ref: `command-rmvirtualenv ` from
33
+ within the environment being removed (:bbissue: `83 `).
32
34
33
35
2.6.3
34
36
Original file line number Diff line number Diff line change @@ -22,15 +22,26 @@ setUp () {
22
22
}
23
23
24
24
test_remove () {
25
- mkvirtualenv " deleteme"
25
+ mkvirtualenv " deleteme" > /dev/null 2>&1
26
26
assertTrue " [ -d $WORKON_HOME /deleteme ]"
27
27
deactivate
28
28
rmvirtualenv " deleteme"
29
29
assertFalse " [ -d $WORKON_HOME /deleteme ]"
30
30
}
31
31
32
+ test_within_virtualenv () {
33
+ mkvirtualenv " deleteme" > /dev/null 2>&1
34
+ assertTrue " [ -d $WORKON_HOME /deleteme ]"
35
+ cdvirtualenv
36
+ assertSame " $VIRTUAL_ENV " " $( pwd) "
37
+ deactivate
38
+ rmvirtualenv " deleteme"
39
+ assertSame " $WORKON_HOME " " $( pwd) "
40
+ assertFalse " [ -d $WORKON_HOME /deleteme ]"
41
+ }
42
+
32
43
test_rm_aliased () {
33
- mkvirtualenv " deleteme"
44
+ mkvirtualenv " deleteme" > /dev/null 2>&1
34
45
deactivate
35
46
alias rm=' rm -i'
36
47
rmvirtualenv " deleteme"
Original file line number Diff line number Diff line change @@ -252,9 +252,21 @@ rmvirtualenv () {
252
252
echo " Either switch to another environment, or run 'deactivate'." >&2
253
253
return 1
254
254
fi
255
+
256
+ # Move out of the current directory to one known to be
257
+ # safe, in case we are inside the environment somewhere.
258
+ typeset prior_dir=" $( pwd) "
259
+ cd " $WORKON_HOME "
260
+
255
261
virtualenvwrapper_run_hook " pre_rmvirtualenv" " $env_name "
256
262
\r m -rf " $env_dir "
257
263
virtualenvwrapper_run_hook " post_rmvirtualenv" " $env_name "
264
+
265
+ # If the directory we used to be in still exists, move back to it.
266
+ if [ -d " $prior_dir " ]
267
+ then
268
+ cd " $prior_dir "
269
+ fi
258
270
}
259
271
260
272
# List the available environments.
You can’t perform that action at this time.
0 commit comments