From e17650f930612c94a4c6259f46229ebc956acd05 Mon Sep 17 00:00:00 2001
From: Brandon Rodriguez <brodriguez8774@gmail.com>
Date: Sat, 31 Oct 2020 02:43:53 -0400
Subject: [PATCH] Correct minor bug if .venv folder exist but active file is
 not present

---
 helper_script.sh | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/helper_script.sh b/helper_script.sh
index d538588..8600294 100644
--- a/helper_script.sh
+++ b/helper_script.sh
@@ -1,11 +1,9 @@
 
 ###
- # Modified "cd" command to automatically load/unload Python ".venv" environments.
+ # Modified "cd" command to automatically load/unload local Python ".venv" environments.
  # :$1: The standard path to pass into the "cd" command.
  ##
 function cd() {
-
-  # Check if .venv folder exists in path to final location.
   local cd_string=$@
   local cd_path=""
   local checked_current=false
@@ -82,8 +80,12 @@ cd_venv_activate() {
   # First make sure no other environment is loaded.
   cd_venv_deactivate
 
-  # Load environment.
-  . "$1/bin/activate"
+  # Ensure that folder is a Python environment.
+  if [[ -f "$1/bin/activate" ]]
+  then
+    # Load environment.
+    . "$1/bin/activate"
+  fi
 }
 
 
-- 
GitLab