Doug Hellmann avatar Doug Hellmann committed 87d60f2

fix #50 by escaping rm before calling it

Comments (0)

Files changed (5)

 Report bugs via the `bug tracker on BitBucket
 <http://bitbucket.org/dhellmann/virtualenvwrapper/>`__.
 
+Shell Aliases
+=============
+
+Since virtualenvwrapper is largely a shell script, it uses shell
+commands for a lot of its actions.  If your environment makes heavy
+use of shell aliases or other customizations, you may encounter
+issues.  Before reporting bugs in the bug tracker, please test
+*without* your aliases enabled.  If you can identify the alias causing
+the problem, that will help make virtualenvwrapper more robust.
+
 =======
 License
 =======

docs/en/history.rst

   - Integrate Manuel Kaufmann's patch to unset GREP_OPTIONS before
     calling grep.  Resolves :bbissue:`51`.
   - Escape ``$`` in regex to resolve :bbissue:`53`.
+  - Escape ``rm`` to avoid issues with aliases and resolve
+    :bbissue:`50`.
 
 2.2
 

docs/en/index.rst

 Report bugs via the `bug tracker on BitBucket
 <http://bitbucket.org/dhellmann/virtualenvwrapper/>`__.
 
+Shell Aliases
+=============
+
+Since virtualenvwrapper is largely a shell script, it uses shell
+commands for a lot of its actions.  If your environment makes heavy
+use of shell aliases or other customizations, you may encounter
+issues.  Before reporting bugs in the bug tracker, please test
+*without* your aliases enabled.  If you can identify the alias causing
+the problem, that will help make virtualenvwrapper more robust.
+
 =======
 License
 =======

tests/test_rmvirtualenv.sh

     assertFalse "[ -d $WORKON_HOME/deleteme ]"
 }
 
+test_rm_aliased () {
+    mkvirtualenv "deleteme"
+    deactivate
+    alias rm='rm -i'
+    set -x
+    rmvirtualenv "deleteme"
+    set +x
+    unalias rm
+}
+
 test_no_such_env () {
     assertFalse "[ -d $WORKON_HOME/deleteme ]"
     assertTrue "rmvirtualenv deleteme"

virtualenvwrapper.sh

         echo "ERROR: virtualenvwrapper could not create a temporary file name." 1>&2
         return 1
     fi
-    trap "rm -f '$file' >/dev/null 2>&1" EXIT
+    trap "\rm -f '$file' >/dev/null 2>&1" EXIT
     echo $file
     return 0
 }
         fi
         source "$hook_script"
     fi
-    rm -f "$hook_script" >/dev/null 2>&1
+    \rm -f "$hook_script" >/dev/null 2>&1
     return $result
 }
 
         return 1
     fi
     virtualenvwrapper_run_hook "pre_rmvirtualenv" "$env_name"
-    rm -rf "$env_dir"
+    \rm -rf "$env_dir"
     virtualenvwrapper_run_hook "post_rmvirtualenv" "$env_name"
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.