Skip to content

Commit 2652576

Browse files
committed
Remove escapes before command names
In the early days of `virtualenvwrapper.sh`, some commands were prefixed with an escape character (e.g. `\grep -E -v ...`) as a way of attempting to defeat local aliases and other redefinitions. (See, e.g. commit c5433fe.) But, the `command` and `builtin` metacommands are better ways of achieving that, and all of the commands in question have since been prefixed with the appropriate metacommand, making the escapes unnecessary. `command \grep -E -v ...` is just silly.
1 parent 2819e4d commit 2652576

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

virtualenvwrapper.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ fi
116116
function virtualenvwrapper_cd {
117117
if [ -n "${ZSH_VERSION:-}" ]
118118
then
119-
builtin \cd -q "$@"
119+
builtin cd -q "$@"
120120
else
121-
builtin \cd "$@"
121+
builtin cd "$@"
122122
fi
123123
}
124124

@@ -152,7 +152,7 @@ function virtualenvwrapper_derive_workon_home {
152152

153153
# If the path is relative, prefix it with $HOME
154154
# (note: for compatibility)
155-
if echo "$workon_home_dir" | (unset GREP_OPTIONS; command \grep '^[^/~]' > /dev/null)
155+
if echo "$workon_home_dir" | (unset GREP_OPTIONS; command grep '^[^/~]' > /dev/null)
156156
then
157157
workon_home_dir="$HOME/$WORKON_HOME"
158158
fi
@@ -161,7 +161,7 @@ function virtualenvwrapper_derive_workon_home {
161161
# path might contain stuff to expand.
162162
# (it might be possible to do this in shell, but I don't know a
163163
# cross-shell-safe way of doing it -wolever)
164-
if echo "$workon_home_dir" | (unset GREP_OPTIONS; command \grep -E '([\$~]|//)' >/dev/null)
164+
if echo "$workon_home_dir" | (unset GREP_OPTIONS; command grep -E '([\$~]|//)' >/dev/null)
165165
then
166166
# This will normalize the path by:
167167
# - Removing extra slashes (e.g., when TMPDIR ends in a slash)
@@ -197,7 +197,7 @@ function virtualenvwrapper_verify_workon_home {
197197
# Function to wrap mktemp so tests can replace it for error condition
198198
# testing.
199199
function virtualenvwrapper_mktemp {
200-
command \mktemp "$@"
200+
command mktemp "$@"
201201
}
202202

203203
# Expects 1 argument, the suffix for the new file.
@@ -240,7 +240,7 @@ function virtualenvwrapper_run_hook {
240240
if [ ! -f "$hook_script" ]
241241
then
242242
echo "ERROR: virtualenvwrapper_run_hook could not find temporary file $hook_script" 1>&2
243-
command \rm -f "$hook_script"
243+
command rm -f "$hook_script"
244244
return 2
245245
fi
246246
# cat "$hook_script"
@@ -256,7 +256,7 @@ VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON and that PATH is
256256
set properly.
257257
EOF
258258
fi
259-
command \rm -f "$hook_script"
259+
command rm -f "$hook_script"
260260
return $result
261261
}
262262

@@ -322,7 +322,7 @@ function virtualenvwrapper_initialize {
322322

323323
# Verify that the passed resource is in path and exists
324324
function virtualenvwrapper_verify_resource {
325-
typeset exe_path="$(command \which "$1" | (unset GREP_OPTIONS; command \grep -v "not found"))"
325+
typeset exe_path="$(command which "$1" | (unset GREP_OPTIONS; command grep -v "not found"))"
326326
if [ "$exe_path" = "" ]
327327
then
328328
echo "ERROR: virtualenvwrapper could not find $1 in your path" >&2
@@ -553,7 +553,7 @@ function rmvirtualenv {
553553
virtualenvwrapper_cd "$WORKON_HOME"
554554

555555
virtualenvwrapper_run_hook "pre_rmvirtualenv" "$env_name"
556-
command \rm -rf "$env_dir"
556+
command rm -rf "$env_dir"
557557
virtualenvwrapper_run_hook "post_rmvirtualenv" "$env_name"
558558

559559
# If the directory we used to be in still exists, move back to it.
@@ -585,11 +585,11 @@ function virtualenvwrapper_show_workon_options {
585585
# 5. Eliminate any lines with * on them because that means there
586586
# were no envs.
587587
(virtualenvwrapper_cd "$WORKON_HOME" && echo */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate) 2>/dev/null \
588-
| command \tr "\n" " " \
589-
| command \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate |/|g" \
590-
| command \tr "/" "\n" \
591-
| command \sed "/^[[:space:]]*$/d" \
592-
| (unset GREP_OPTIONS; command \grep -E -v '^\*$') 2>/dev/null
588+
| command tr "\n" " " \
589+
| command sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate |/|g" \
590+
| command tr "/" "\n" \
591+
| command sed "/^[[:space:]]*$/d" \
592+
| (unset GREP_OPTIONS; command grep -E -v '^\*$') 2>/dev/null
593593
}
594594

595595
function _lsvirtualenv_usage {

virtualenvwrapper_lazy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export _VIRTUALENVWRAPPER_API="$_VIRTUALENVWRAPPER_API mkvirtualenv rmvirtualenv
55

66
if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ]
77
then
8-
export VIRTUALENVWRAPPER_SCRIPT="$(command \which virtualenvwrapper.sh)"
8+
export VIRTUALENVWRAPPER_SCRIPT="$(command which virtualenvwrapper.sh)"
99
fi
1010
if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ]
1111
then

0 commit comments

Comments
 (0)