Commits

Doug Latornell committed 6633b59

Modified to work with Korn shell (ksh).

Function calls changed (removed function keyword) to syntax that is
common to bash, sh, zsh and ksh.

Changed 2 tests that were using pushd/popd that are not built-ins in
ksh. Those tests didn't actually need directory stack functionality
more than 1 level deep.

  • Participants
  • Parent commits 503455e

Comments (0)

Files changed (3)

 def test():
     sh('bash ./tests/test.sh')
     sh('SHUNIT_PARENT=./tests/test.sh zsh -o shwordsplit ./tests/test.sh')
+    sh('SHUNIT_PARENT=./tests/test.sh ksh ./tests/test.sh')
     sh('bash ./tests/test_misconfigured.sh')
     return

File tests/test.sh

 }
 
 test_cdvirtual() {
-    pushd "$(pwd)" >/dev/null
+    return_dir=$(pwd)
     cdvirtualenv
     assertSame "$VIRTUAL_ENV" "$(pwd)"
     cdvirtualenv bin
     assertSame "$VIRTUAL_ENV/bin" "$(pwd)"
-    popd >/dev/null
+    cd $return_dir
 }
 
 test_cdsitepackages () {
-    pushd "$(pwd)" >/dev/null   
+    return_dir=$(pwd) 
     cdsitepackages
     pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.)
     sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages"
     assertSame "$sitepackages" "$(pwd)"
-    popd >/dev/null
+    cd $return_dir
 }
 
 test_mkvirtualenv_activates () {

File virtualenvwrapper_bashrc

 export WORKON_HOME
 
 # Verify that the WORKON_HOME directory exists
-function virtualenvwrapper_verify_workon_home () {
+virtualenvwrapper_verify_workon_home () {
     if [ ! -d "$WORKON_HOME" ]
     then
         echo "ERROR: Virtual environments directory '$WORKON_HOME' does not exist." >&2
 #
 # Usage: virtualenvwrapper_make_hook filename comment
 #
-function virtualenvwrapper_make_hook () {
+virtualenvwrapper_make_hook () {
     filename="$1"
     comment="$2"
     if [ ! -f "$filename" ]
 }
 
 # Set up virtualenvwrapper properly
-function virtualenvwrapper_initialize () {
+virtualenvwrapper_initialize () {
     virtualenvwrapper_verify_workon_home || return 1
     # mkvirtualenv
     virtualenvwrapper_make_hook "$WORKON_HOME/premkvirtualenv" \
 virtualenvwrapper_initialize
 
 # Verify that virtualenv is installed and visible
-function virtualenvwrapper_verify_virtualenv () {
+virtualenvwrapper_verify_virtualenv () {
     venv=$(which virtualenv | grep -v "not found")
     if [ "$venv" = "" ]
     then
 }
 
 # Verify that the requested environment exists
-function virtualenvwrapper_verify_workon_environment () {
+virtualenvwrapper_verify_workon_environment () {
     typeset env_name="$1"
     if [ ! -d "$WORKON_HOME/$env_name" ]
     then
 }
 
 # Verify that the active environment exists
-function virtualenvwrapper_verify_active_environment () {
+virtualenvwrapper_verify_active_environment () {
     if [ ! -n "${VIRTUAL_ENV}" ] || [ ! -d "${VIRTUAL_ENV}" ]
     then
         echo "ERROR: no virtualenv active, or active virtualenv is missing" >&2
 }
 
 # Run a hook script in the current shell
-function virtualenvwrapper_source_hook () {
+virtualenvwrapper_source_hook () {
     scriptname="$1"
     #echo "Looking for hook $scriptname"
     if [ -f "$scriptname" ]
 }
 
 # Run a hook script in its own shell
-function virtualenvwrapper_run_hook () {
+virtualenvwrapper_run_hook () {
     scriptname="$1"
     shift
     #echo "Looking for hook $scriptname"
 # Usage: mkvirtualenv [options] ENVNAME
 # (where the options are passed directly to virtualenv)
 #
-function mkvirtualenv () {
+mkvirtualenv () {
     eval "envname=\$$#"
     virtualenvwrapper_verify_workon_home || return 1
     virtualenvwrapper_verify_virtualenv || return 1
 }
 
 # Remove an environment, in the WORKON_HOME.
-function rmvirtualenv () {
+rmvirtualenv () {
     typeset env_name="$1"
     virtualenvwrapper_verify_workon_home || return 1
     if [ "$env_name" = "" ]
 }
 
 # List the available environments.
-function virtualenvwrapper_show_workon_options () {
+virtualenvwrapper_show_workon_options () {
     virtualenvwrapper_verify_workon_home || return 1
     # NOTE: DO NOT use ls here because colorized versions spew control characters
     #       into the output list.
 #
 # Usage: workon [environment_name]
 #
-function workon () {
+workon () {
 	typeset env_name="$1"
 	if [ "$env_name" = "" ]
     then
     virtualenvwrapper_saved_deactivate=$(typeset -f deactivate)
 
     # Replace the deactivate() function with a wrapper.
-    eval 'function deactivate () {
+    eval 'deactivate () {
         # Call the local hook before the global so we can undo
         # any settings made by the local postactivate first.
         virtualenvwrapper_source_hook "$VIRTUAL_ENV/bin/predeactivate"
 fi
 
 # Prints the Python version string for the current interpreter.
-function virtualenvwrapper_get_python_version () {
+virtualenvwrapper_get_python_version () {
     python -c 'import sys; print ".".join(str(p) for p in sys.version_info[:2])'
 }
 
 # Prints the path to the site-packages directory for the current environment.
-function virtualenvwrapper_get_site_packages_dir () {
+virtualenvwrapper_get_site_packages_dir () {
     echo "$VIRTUAL_ENV/lib/python`virtualenvwrapper_get_python_version`/site-packages"    
 }
 
 # "virtualenv_path_extensions.pth" inside the virtualenv's
 # site-packages directory; if this file does not exist, it will be
 # created first.
-function add2virtualenv () {
+add2virtualenv () {
 
     virtualenvwrapper_verify_active_environment || return 1
     
 
 # Does a ``cd`` to the site-packages directory of the currently-active
 # virtualenv.
-function cdsitepackages () {
+cdsitepackages () {
     virtualenvwrapper_verify_active_environment || return 1
     site_packages="`virtualenvwrapper_get_site_packages_dir`"
     cd "$site_packages"
 }
 
 # Does a ``cd`` to the root of the currently-active virtualenv.
-function cdvirtualenv () {
+cdvirtualenv () {
     virtualenvwrapper_verify_active_environment || return 1
     cd $VIRTUAL_ENV/$1
 }
 
 # Shows the content of the site-packages directory of the currently-active
 # virtualenv
-function lssitepackages () {
+lssitepackages () {
     virtualenvwrapper_verify_active_environment || return 1
     site_packages="`virtualenvwrapper_get_site_packages_dir`"
     ls $@ $site_packages