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

export.sh cannot run correctly on zsh (GIT8266O-849) #1272

Open
Hanzo-Huang opened this issue Apr 1, 2024 · 0 comments
Open

export.sh cannot run correctly on zsh (GIT8266O-849) #1272

Hanzo-Huang opened this issue Apr 1, 2024 · 0 comments

Comments

@Hanzo-Huang
Copy link

Problem

Recently I change my shell to zsh. When I run export.sh as usual, it promote

IDF_PATH must be set before sourcing this script

but it worked correctly when I used bash.

Solution

I find the code in export.sh(line 24 to 40)

    if [[ -z "${IDF_PATH}" ]]
    then
        # If using bash, try to guess IDF_PATH from script location
        if [[ -n "${BASH_SOURCE}" ]]
        then
            if [[ "$OSTYPE" == "darwin"* ]]; then
                script_dir="$(realpath_int $BASH_SOURCE)"
            else
                script_name="$(readlink -f $BASH_SOURCE)"
                script_dir="$(dirname $script_name)"
            fi
            export IDF_PATH="${script_dir}"
        else
            echo "IDF_PATH must be set before sourcing this script"
            return 1
        fi
    fi

it seems it works with bash.
I change it so it can work with zsh

    if [[ -z "${IDF_PATH}" ]]
    then
        # If using bash, try to guess IDF_PATH from script location
        if [[ -n "${BASH_SOURCE}" ]] || [[ -n "$ZSH_EVAL_CONTEXT" ]]
        then
            if [[ "$OSTYPE" == "darwin"* ]]; then
                script_dir="$(realpath_int $BASH_SOURCE)"
            else
                if [[ -n "${BASH_SOURCE}" ]]; then
                    script_name="$(readlink -f $BASH_SOURCE)"
                else
                    script_name="$(readlink -f \$0)"
                fi
                script_dir="$(dirname $script_name)"
            fi
            export IDF_PATH="${script_dir}"
        else
            echo "IDF_PATH must be set before sourcing this script"
            return 1
        fi
    fi
@github-actions github-actions bot changed the title export.sh cannot run correctly on zsh export.sh cannot run correctly on zsh (GIT8266O-849) Apr 1, 2024
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

1 participant