48f4b793a62e2fab944a18f2f7410f6b2d0565e0

Author
Michael Aquilina <michaelaquilina@gmail.com>
Committer
Michael Aquilina <michaelaquilina@gmail.com>
Date

Message

Mark variables as local to prevent poluting users shell

Diff

 1diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
 2index f152273fb1aeea42d82906dd41c595fe761aeb25..6d3da84bd982cb2f001215b956fe742ffa446cf2 100644
 3--- a/autoswitch_virtualenv.plugin.zsh
 4+++ b/autoswitch_virtualenv.plugin.zsh
 5@@ -27,7 +27,7 @@ function _virtual_env_dir() {
 6 
 7 
 8 function _python_version() {
 9-    PYTHON_BIN="$1"
10+    local PYTHON_BIN="$1"
11     if [[ -f "$PYTHON_BIN" ]] then
12         # For some reason python --version writes to stderr
13         printf "%s" "$($PYTHON_BIN --version 2>&1)"
14@@ -98,6 +98,8 @@ function _check_venv_path()
15 function check_venv()
16 {
17     local SWITCH_TO=""
18+    local file_owner
19+    local file_permissions
20 
21     # Get the .venv file, scanning parent directories
22     local venv_path=$(_check_venv_path "$PWD")
23@@ -190,7 +192,7 @@ function mkvenv()
24         printf "Creating ${PURPLE}%s${NONE} virtualenv\n" "$venv_name"
25 
26         # Copy parameters variable so that we can mutate it
27-        params=("${@[@]}")
28+        local params=("${@[@]}")
29 
30         if [[ -n "$AUTOSWITCH_DEFAULT_PYTHON" && ${params[(I)--python*]} -eq 0 ]]; then
31             params+="--python=$AUTOSWITCH_DEFAULT_PYTHON"
32@@ -237,6 +239,7 @@ function install_requirements() {
33     fi
34 
35     setopt nullglob
36+    local requirements
37     for requirements in **/*requirements.txt
38     do
39         printf "Found a ${PURPLE}%s${NORMAL} file. Install? [y/N]: " "$requirements"