Skip to content

Commit c5433fe

Browse files
committed
fix #50 by escaping rm before calling it
1 parent 5ef7081 commit c5433fe

File tree

5 files changed

+35
-3
lines changed

5 files changed

+35
-3
lines changed

README.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ issues and features.
7272
Report bugs via the `bug tracker on BitBucket
7373
<http://bitbucket.org/dhellmann/virtualenvwrapper/>`__.
7474

75+
Shell Aliases
76+
=============
77+
78+
Since virtualenvwrapper is largely a shell script, it uses shell
79+
commands for a lot of its actions. If your environment makes heavy
80+
use of shell aliases or other customizations, you may encounter
81+
issues. Before reporting bugs in the bug tracker, please test
82+
*without* your aliases enabled. If you can identify the alias causing
83+
the problem, that will help make virtualenvwrapper more robust.
84+
7585
=======
7686
License
7787
=======

docs/en/history.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Release History
88
- Integrate Manuel Kaufmann's patch to unset GREP_OPTIONS before
99
calling grep. Resolves :bbissue:`51`.
1010
- Escape ``$`` in regex to resolve :bbissue:`53`.
11+
- Escape ``rm`` to avoid issues with aliases and resolve
12+
:bbissue:`50`.
1113

1214
2.2
1315

docs/en/index.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,16 @@ issues and features.
212212
Report bugs via the `bug tracker on BitBucket
213213
<http://bitbucket.org/dhellmann/virtualenvwrapper/>`__.
214214

215+
Shell Aliases
216+
=============
217+
218+
Since virtualenvwrapper is largely a shell script, it uses shell
219+
commands for a lot of its actions. If your environment makes heavy
220+
use of shell aliases or other customizations, you may encounter
221+
issues. Before reporting bugs in the bug tracker, please test
222+
*without* your aliases enabled. If you can identify the alias causing
223+
the problem, that will help make virtualenvwrapper more robust.
224+
215225
=======
216226
License
217227
=======

tests/test_rmvirtualenv.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ test_remove () {
2929
assertFalse "[ -d $WORKON_HOME/deleteme ]"
3030
}
3131

32+
test_rm_aliased () {
33+
mkvirtualenv "deleteme"
34+
deactivate
35+
alias rm='rm -i'
36+
set -x
37+
rmvirtualenv "deleteme"
38+
set +x
39+
unalias rm
40+
}
41+
3242
test_no_such_env () {
3343
assertFalse "[ -d $WORKON_HOME/deleteme ]"
3444
assertTrue "rmvirtualenv deleteme"

virtualenvwrapper.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ virtualenvwrapper_tempfile () {
106106
echo "ERROR: virtualenvwrapper could not create a temporary file name." 1>&2
107107
return 1
108108
fi
109-
trap "rm -f '$file' >/dev/null 2>&1" EXIT
109+
trap "\rm -f '$file' >/dev/null 2>&1" EXIT
110110
echo $file
111111
return 0
112112
}
@@ -131,7 +131,7 @@ virtualenvwrapper_run_hook () {
131131
fi
132132
source "$hook_script"
133133
fi
134-
rm -f "$hook_script" >/dev/null 2>&1
134+
\rm -f "$hook_script" >/dev/null 2>&1
135135
return $result
136136
}
137137

@@ -223,7 +223,7 @@ rmvirtualenv () {
223223
return 1
224224
fi
225225
virtualenvwrapper_run_hook "pre_rmvirtualenv" "$env_name"
226-
rm -rf "$env_dir"
226+
\rm -rf "$env_dir"
227227
virtualenvwrapper_run_hook "post_rmvirtualenv" "$env_name"
228228
}
229229

0 commit comments

Comments
 (0)