Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup_env.sh cannot be sourced with zsh #48

Open
segabor opened this issue Sep 29, 2024 · 1 comment
Open

setup_env.sh cannot be sourced with zsh #48

segabor opened this issue Sep 29, 2024 · 1 comment

Comments

@segabor
Copy link

segabor commented Sep 29, 2024

If I try to source setup_env.sh in my RPi 5 using zsh, I get the following error,

➜  hailo-rpi5-examples git:(main) ✗ echo $ZSH_VERSION 
5.9
➜  hailo-rpi5-examples git:(main) ✗ . ./setup_env.sh          
is_sourced:2: no such option: sourced
This script needs to be sourced to correctly set up the environment. Please run '. setup_env.sh' instead of executing it.
➜  hailo-rpi5-examples git:(main) ✗ 

I fixed the script so I can now use it with zsh. See the patch below,

diff --git a/setup_env.sh b/setup_env.sh
index d19faa6..4b900c0 100755
--- a/setup_env.sh
+++ b/setup_env.sh
@@ -11,7 +11,7 @@ TAPPAS_REQUIRED_VERSION=("3.28.0" "3.28.1" "3.28.2" "3.29.0" "3.29.1")
 # Function to check if the script is being sourced
 is_sourced() {
     if [ -n "$ZSH_VERSION" ]; then
-        [[ -o sourced ]]
+        case $ZSH_EVAL_CONTEXT in *:file:*) return 0;; esac 
     elif [ -n "$BASH_VERSION" ]; then
         [[ "${BASH_SOURCE[0]}" != "$0" ]]
     else
@SamuelHudec
Copy link

can someone from Hailo merge 👆 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants