Skip to content

Commit 4a3624e

Browse files
committed
Some cleanup after talking with dhellmann
1 parent 58cca48 commit 4a3624e

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

virtualenvwrapper.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fi
5959

6060
# If the path is relative, prefix it with $HOME
6161
# (note: for compatibility)
62-
if echo "$WORKON_HOME" | grep -e '^[^/~]'
62+
if echo "$WORKON_HOME" | grep -e '^[^/~]' > /dev/null
6363
then
6464
export WORKON_HOME="$HOME/$WORKON_HOME"
6565
fi
@@ -68,7 +68,7 @@ fi
6868
# path might contain stuff to expand.
6969
# (it might be possible to do this in shell, but I don't know a
7070
# cross-shell-safe way of doing it -wolever)
71-
if echo "$WORKON_HOME" | grep -e "[$~]"
71+
if echo "$WORKON_HOME" | grep -e "[$~]" > /dev/null
7272
then
7373
# This will normalize the path by:
7474
# - Expanding variables (eg, $foo)
@@ -91,20 +91,20 @@ virtualenvwrapper_verify_workon_home () {
9191

9292
# Expects 1 argument, the suffix for the new file.
9393
virtualenvwrapper_tempfile () {
94-
tempfile "virtualenvwrapper-XXXXXX-$1"
94+
mktemp "virtualenvwrapper-XXXXXX-$1"
9595
}
9696

9797
# Run the hooks
9898
virtualenvwrapper_run_hook () {
9999
hook_script="$(virtualenvwrapper_tempfile hook)"
100-
"$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' $HOOK_VERBOSE_OPTION --run-hook-and-write-source "$hook_script" "$@"
100+
"$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' $HOOK_VERBOSE_OPTION --script "$hook_script" "$@"
101101
result=$?
102102

103103
if [ $result -eq 0 ]
104104
then
105105
source "$hook_script"
106106
fi
107-
rm -f "$hook_script" > /dev/null 2>&1
107+
rm -f "$hook_script" &> /dev/null
108108
return $result
109109
}
110110

@@ -424,7 +424,7 @@ cpvirtualenv() {
424424
echo "Please specify target virtualenv"
425425
return 1
426426
fi
427-
if echo "$WORKON_HOME" | grep -e "/$"
427+
if echo "$WORKON_HOME" | grep -e "/$" > /dev/null
428428
then
429429
env_home="$WORKON_HOME"
430430
else

virtualenvwrapper/hook_loader.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ def main():
2222
description='Manage hooks for virtualenvwrapper',
2323
)
2424

25-
parser.add_option('-S', '--run-hook-and-write-source',
26-
help='Runs "hook" and runs "<hook>_source", writing the ' +
25+
parser.add_option('-S', '--script',
26+
help='Runs "hook" then "<hook>_source", writing the ' +
2727
'result to <file>',
28-
dest='source_filename',
28+
dest='script_filename',
2929
default=None,
3030
)
3131
parser.add_option('-s', '--source',
@@ -93,18 +93,17 @@ def main():
9393
parser.error('Please specify the hook to run')
9494
hook = args[0]
9595

96-
if options.sourcing and options.source_filename:
97-
parser.error('--source and --run-hook-and-write-source are mutually ' +
98-
'exclusive.')
96+
if options.sourcing and options.script_filename:
97+
parser.error('--source and --script are mutually exclusive.')
9998

10099
if options.sourcing:
101100
hook += '_source'
102101

103102
run_hooks(hook, options, args)
104103

105-
if options.source_filename:
104+
if options.script_filename:
106105
options.sourcing = True
107-
output = open(options.source_filename, "w")
106+
output = open(options.script_filename, "w")
108107
try:
109108
run_hooks(hook + '_source', options, args, output)
110109
finally:

0 commit comments

Comments
 (0)