93776cf5f6522ef7d7f4331eda657d70bdf91681

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

Message

Merge pull request #121 from MichaelAquilina/fix/stat_path

Use fixed stat path to work round other possible stat binaries in $PATH

Diff

 1diff --git a/CHANGELOG.rst b/CHANGELOG.rst
 2index 51ae34eac38200d2c399cf51f1a0a35612898c3d..f7b53afccbcc9557abd4f7c50cab49a5ffad87ca 100644
 3--- a/CHANGELOG.rst
 4+++ b/CHANGELOG.rst
 5@@ -1,6 +1,10 @@
 6 Changelog
 7 =========
 8 
 9+1.15.2
10+------
11+* Use absolute path for ``/usr/bin/stat`` to prevent conflicts with other ``stat`` binaries. Fixes #110
12+
13 1.15.1
14 ------
15 * Fix detection of pipenv projects from subdirectories
16diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
17index 116b303fe0dd6c6df54e113f4ac75fc73b788619..d3ce1f513c5521b760309308071b2350745b9851 100644
18--- a/autoswitch_virtualenv.plugin.zsh
19+++ b/autoswitch_virtualenv.plugin.zsh
20@@ -1,4 +1,4 @@
21-export AUTOSWITCH_VERSION="1.15.1"
22+export AUTOSWITCH_VERSION="1.15.2"
23 export AUTOSWITCH_FILE=".venv"
24 
25 RED="\e[31m"
26@@ -128,13 +128,13 @@ function check_venv()
27 
28     if [[ -n "$venv_path" ]]; then
29 
30-        stat --version &> /dev/null
31+        /usr/bin/stat --version &> /dev/null
32         if [[ $? -eq 0 ]]; then   # Linux, or GNU stat
33-            file_owner="$(stat -c %u "$venv_path")"
34-            file_permissions="$(stat -c %a "$venv_path")"
35+            file_owner="$(/usr/bin/stat -c %u "$venv_path")"
36+            file_permissions="$(/usr/bin/stat -c %a "$venv_path")"
37         else                      # macOS, or FreeBSD stat
38-            file_owner="$(stat -f %u "$venv_path")"
39-            file_permissions="$(stat -f %OLp "$venv_path")"
40+            file_owner="$(/usr/bin/stat -f %u "$venv_path")"
41+            file_permissions="$(/usr/bin/stat -f %OLp "$venv_path")"
42         fi
43 
44         if [[ "$file_owner" != "$(id -u)" ]]; then