Skip to content

Commit da08f8a

Browse files
committed
add support for ksh (fixes #25)
1 parent 6ee31a3 commit da08f8a

File tree

4 files changed

+38
-31
lines changed

4 files changed

+38
-31
lines changed

Makefile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ ifeq ($(SUPPORTED_PYTHON_VERSIONS),)
1010
SUPPORTED_PYTHON_VERSIONS=2.5 2.6
1111
endif
1212

13+
SUPPORTED_SHELLS=bash sh ksh zsh
14+
1315
# Default target is to show help
1416
help:
1517
@echo "sdist - Source distribution"
@@ -54,17 +56,17 @@ docs/sphinx/web/templates/base.html: ~/Devel/doughellmann/doughellmann/templates
5456
# Testing
5557
TEST_SCRIPTS=$(wildcard tests/test*.sh)
5658

57-
.PHONY: develop test test-bash test-sh test-zsh test-loop test-install
58-
test: test-bash test-sh test-zsh test-install
59+
test:
60+
for name in $(SUPPORTED_SHELLS) ; do \
61+
$(MAKE) test-$$name || exit 1 ; \
62+
done
63+
$(MAKE) test-install
5964

6065
develop:
6166
python setup.py develop
6267

63-
test-bash:
64-
TEST_SHELL=bash $(MAKE) test-loop
65-
66-
test-sh:
67-
TEST_SHELL=sh $(MAKE) test-loop
68+
test-%:
69+
TEST_SHELL=$(subst test-,,$@) $(MAKE) test-loop
6870

6971
test-zsh:
7072
TEST_SHELL="zsh -o shwordsplit" $(MAKE) test-loop
@@ -80,6 +82,7 @@ test-loop:
8082
|| exit 1 ; \
8183
$$TMPDIR/virtualenvwrapper-test-env/bin/python setup.py install || exit 1 ; \
8284
for test_script in $(wildcard tests/test*.sh) ; do \
85+
echo ; \
8386
echo '********************************************************************************' ; \
8487
echo "Running $$test_script with $(TEST_SHELL) under Python $$py_ver" ; \
8588
VIRTUALENVWRAPPER_PYTHON=$$TMPDIR/virtualenvwrapper-test-env/bin/python SHUNIT_PARENT=$$test_script $(TEST_SHELL) $$test_script || exit 1 ; \

docs/source/history.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Release History
33
===============
44

5+
Dev
6+
7+
- Add support for ksh.
8+
59
2.0.2
610

711
- Fixed issue #32, making virtualenvwrapper.user_scripts compatible

tests/test_cd.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,31 @@ setUp () {
2222
}
2323

2424
test_cdvirtual() {
25-
pushd "$(pwd)" >/dev/null
25+
start_dir="$(pwd)"
2626
cdvirtualenv
2727
assertSame "$VIRTUAL_ENV" "$(pwd)"
2828
cdvirtualenv bin
2929
assertSame "$VIRTUAL_ENV/bin" "$(pwd)"
30-
popd >/dev/null
30+
cd "$(start_dir)"
3131
}
3232

3333
test_cdsitepackages () {
34-
pushd "$(pwd)" >/dev/null
34+
start_dir="$(pwd)"
3535
cdsitepackages
3636
pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.)
3737
sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages"
3838
assertSame "$sitepackages" "$(pwd)"
39-
popd >/dev/null
39+
cd "$(start_dir)"
4040
}
4141

4242
test_cdsitepackages_with_arg () {
43-
pushd "$(pwd)" >/dev/null
43+
start_dir="$(pwd)"
4444
pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.)
4545
sitepackage_subdir="$VIRTUAL_ENV/lib/python${pyvers}/site-packages/subdir"
4646
mkdir -p "${sitepackage_subdir}"
4747
cdsitepackages subdir
4848
assertSame "$sitepackage_subdir" "$(pwd)"
49-
popd >/dev/null
49+
cd "$(start_dir)"
5050
}
5151

5252
test_cdvirtualenv_no_workon_home () {

virtualenvwrapper.sh

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ then
7373
fi
7474

7575
# Verify that the WORKON_HOME directory exists
76-
function virtualenvwrapper_verify_workon_home () {
76+
virtualenvwrapper_verify_workon_home () {
7777
if [ ! -d "$WORKON_HOME" ]
7878
then
7979
[ "$1" != "-q" ] && echo "ERROR: Virtual environments directory '$WORKON_HOME' does not exist. Create it or set WORKON_HOME to an existing directory." >&2
@@ -85,7 +85,7 @@ function virtualenvwrapper_verify_workon_home () {
8585
#HOOK_VERBOSE_OPTION="-v"
8686

8787
# Run the hooks
88-
function virtualenvwrapper_run_hook () {
88+
virtualenvwrapper_run_hook () {
8989
# First anything that runs directly from the plugin
9090
"$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION "$@"
9191
# Now anything that wants to run inside this shell
@@ -96,15 +96,15 @@ function virtualenvwrapper_run_hook () {
9696
}
9797

9898
# Set up virtualenvwrapper properly
99-
function virtualenvwrapper_initialize () {
99+
virtualenvwrapper_initialize () {
100100
virtualenvwrapper_verify_workon_home -q || return 1
101101
virtualenvwrapper_run_hook "initialize"
102102
}
103103

104104
virtualenvwrapper_initialize
105105

106106
# Verify that virtualenv is installed and visible
107-
function virtualenvwrapper_verify_virtualenv () {
107+
virtualenvwrapper_verify_virtualenv () {
108108
venv=$(which virtualenv | grep -v "not found")
109109
if [ "$venv" = "" ]
110110
then
@@ -120,7 +120,7 @@ function virtualenvwrapper_verify_virtualenv () {
120120
}
121121

122122
# Verify that the requested environment exists
123-
function virtualenvwrapper_verify_workon_environment () {
123+
virtualenvwrapper_verify_workon_environment () {
124124
typeset env_name="$1"
125125
if [ ! -d "$WORKON_HOME/$env_name" ]
126126
then
@@ -131,7 +131,7 @@ function virtualenvwrapper_verify_workon_environment () {
131131
}
132132

133133
# Verify that the active environment exists
134-
function virtualenvwrapper_verify_active_environment () {
134+
virtualenvwrapper_verify_active_environment () {
135135
if [ ! -n "${VIRTUAL_ENV}" ] || [ ! -d "${VIRTUAL_ENV}" ]
136136
then
137137
echo "ERROR: no virtualenv active, or active virtualenv is missing" >&2
@@ -145,7 +145,7 @@ function virtualenvwrapper_verify_active_environment () {
145145
# Usage: mkvirtualenv [options] ENVNAME
146146
# (where the options are passed directly to virtualenv)
147147
#
148-
function mkvirtualenv () {
148+
mkvirtualenv () {
149149
eval "envname=\$$#"
150150
virtualenvwrapper_verify_workon_home || return 1
151151
virtualenvwrapper_verify_virtualenv || return 1
@@ -163,7 +163,7 @@ function mkvirtualenv () {
163163
}
164164

165165
# Remove an environment, in the WORKON_HOME.
166-
function rmvirtualenv () {
166+
rmvirtualenv () {
167167
typeset env_name="$1"
168168
virtualenvwrapper_verify_workon_home || return 1
169169
if [ "$env_name" = "" ]
@@ -184,7 +184,7 @@ function rmvirtualenv () {
184184
}
185185

186186
# List the available environments.
187-
function virtualenvwrapper_show_workon_options () {
187+
virtualenvwrapper_show_workon_options () {
188188
virtualenvwrapper_verify_workon_home || return 1
189189
# NOTE: DO NOT use ls here because colorized versions spew control characters
190190
# into the output list.
@@ -197,7 +197,7 @@ function virtualenvwrapper_show_workon_options () {
197197
#
198198
# Usage: workon [environment_name]
199199
#
200-
function workon () {
200+
workon () {
201201
typeset env_name="$1"
202202
if [ "$env_name" = "" ]
203203
then
@@ -232,7 +232,7 @@ function workon () {
232232
virtualenvwrapper_saved_deactivate=$(typeset -f deactivate)
233233

234234
# Replace the deactivate() function with a wrapper.
235-
eval 'function deactivate () {
235+
eval 'deactivate () {
236236
# Call the local hook before the global so we can undo
237237
# any settings made by the local postactivate first.
238238
virtualenvwrapper_run_hook "pre_deactivate"
@@ -288,12 +288,12 @@ elif [ -n "$ZSH_VERSION" ] ; then
288288
fi
289289

290290
# Prints the Python version string for the current interpreter.
291-
function virtualenvwrapper_get_python_version () {
291+
virtualenvwrapper_get_python_version () {
292292
python -c 'import sys; print ".".join(str(p) for p in sys.version_info[:2])'
293293
}
294294

295295
# Prints the path to the site-packages directory for the current environment.
296-
function virtualenvwrapper_get_site_packages_dir () {
296+
virtualenvwrapper_get_site_packages_dir () {
297297
echo "$VIRTUAL_ENV/lib/python`virtualenvwrapper_get_python_version`/site-packages"
298298
}
299299

@@ -308,7 +308,7 @@ function virtualenvwrapper_get_site_packages_dir () {
308308
# "virtualenv_path_extensions.pth" inside the virtualenv's
309309
# site-packages directory; if this file does not exist, it will be
310310
# created first.
311-
function add2virtualenv () {
311+
add2virtualenv () {
312312

313313
virtualenvwrapper_verify_workon_home || return 1
314314
virtualenvwrapper_verify_active_environment || return 1
@@ -350,23 +350,23 @@ function add2virtualenv () {
350350

351351
# Does a ``cd`` to the site-packages directory of the currently-active
352352
# virtualenv.
353-
function cdsitepackages () {
353+
cdsitepackages () {
354354
virtualenvwrapper_verify_workon_home || return 1
355355
virtualenvwrapper_verify_active_environment || return 1
356356
site_packages="`virtualenvwrapper_get_site_packages_dir`"
357357
cd "$site_packages"/$1
358358
}
359359

360360
# Does a ``cd`` to the root of the currently-active virtualenv.
361-
function cdvirtualenv () {
361+
cdvirtualenv () {
362362
virtualenvwrapper_verify_workon_home || return 1
363363
virtualenvwrapper_verify_active_environment || return 1
364364
cd $VIRTUAL_ENV/$1
365365
}
366366

367367
# Shows the content of the site-packages directory of the currently-active
368368
# virtualenv
369-
function lssitepackages () {
369+
lssitepackages () {
370370
virtualenvwrapper_verify_workon_home || return 1
371371
virtualenvwrapper_verify_active_environment || return 1
372372
site_packages="`virtualenvwrapper_get_site_packages_dir`"
@@ -382,7 +382,7 @@ function lssitepackages () {
382382
}
383383

384384
# Duplicate the named virtualenv to make a new one.
385-
function cpvirtualenv() {
385+
cpvirtualenv() {
386386

387387
typeset env_name="$1"
388388
if [ "$env_name" = "" ]

0 commit comments

Comments
 (0)