pw_env_setup: Check for _pw_deactivate

Check whether function _pw_deactivate exists before calling it.

Change-Id: If2395788cb1cee1432dbce3d752efb52d7bc4058
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/23165
Reviewed-by: Joe Ethier <jethier@google.com>
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/pw_env_setup/util.sh b/pw_env_setup/util.sh
index c624c5c..dee793f 100644
--- a/pw_env_setup/util.sh
+++ b/pw_env_setup/util.sh
@@ -158,7 +158,9 @@
 
   # If there's a _pw_deactivate function run it. Redirect output to /dev/null
   # in case _pw_deactivate doesn't exist.
-  _pw_deactivate &> /dev/null
+  if [ -n "$(command -v _pw_deactivate)" ]; then
+    _pw_deactivate &> /dev/null
+  fi
 
   # Restore PW_ROOT.
   PW_ROOT="$_NEW_PW_ROOT"