311197a5e2df60cf5d24573cd96c810cb068783a

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

Message

Use printf instead of echo because its more portable

Diff

 1diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
 2index 6482d4a96ea9a5a6d493ff5cf2af134627515ba7..dd2b0389e6334c0ab73b34f76d292b95154bca82 100644
 3--- a/autoswitch_virtualenv.plugin.zsh
 4+++ b/autoswitch_virtualenv.plugin.zsh
 5@@ -20,7 +20,7 @@ function _check_venv_path()
 6     local check_dir=$1
 7 
 8     if [[ -f "${check_dir}/.venv" ]]; then
 9-        echo "${check_dir}/.venv"
10+        printf "${check_dir}/.venv"
11         return
12     else
13         if [ "$check_dir" = "/" ]; then
14@@ -53,15 +53,13 @@ function check_venv()
15           fi
16 
17           if [[ "$file_owner" != "$(id -u)" ]]; then
18-            echo "AUTOSWITCH WARNING: Virtualenv will not be activated"
19-            echo ""
20-            echo "Reason: Found a .venv file but it is not owned by the current user"
21-            echo "Change ownership of $venv_path to '$USER' to fix this"
22+            printf "AUTOSWITCH WARNING: Virtualenv will not be activated\n\n"
23+            printf "Reason: Found a .venv file but it is not owned by the current user\n"
24+            printf "Change ownership of $venv_path to '$USER' to fix this\n"
25           elif [[ "$file_permissions" != "600" ]]; then
26-            echo "AUTOSWITCH WARNING: Virtualenv will not be activated"
27-            echo ""
28-            echo "Reason: Found a .venv file with weak permission settings ($file_permissions)."
29-            echo "Run the following command to fix this: \"chmod 600 $venv_path\""
30+            printf "AUTOSWITCH WARNING: Virtualenv will not be activated\n\n"
31+            printf "Reason: Found a .venv file with weak permission settings ($file_permissions).\n"
32+            printf "Run the following command to fix this: \"chmod 600 $venv_path\"\n"
33           else
34             SWITCH_TO="$(<"$venv_path")"
35           fi
36@@ -98,7 +96,7 @@ function rmvenv()
37     rmvirtualenv "$venv_name"
38     rm ".venv"
39   else
40-    echo "No .venv file in the current directory!"
41+    printf "No .venv file in the current directory!\n"
42   fi
43 }
44 
45@@ -107,7 +105,7 @@ function rmvenv()
46 function mkvenv()
47 {
48   if [[ -f ".venv" ]]; then
49-    echo ".venv file already exists. If this is a mistake use the rmvenv command"
50+    printf ".venv file already exists. If this is a mistake use the rmvenv command\n"
51   else
52     venv_name="$(basename $PWD)"
53     mkvirtualenv "$venv_name" $@
54@@ -122,7 +120,7 @@ function mkvenv()
55         pip install -r "$requirements"
56       fi
57     done
58-    echo "$venv_name" > ".venv"
59+    printf "$venv_name\n" > ".venv"
60     chmod 600 .venv
61     AUTOSWITCH_PROJECT="$PWD"
62   fi