From d20a5c39da03f7b955c6de8438e405dee4cc0cb0 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 21 Feb 2021 06:09:30 +0100 Subject: [PATCH 1/2] Fix error when `ZSH_VERSION` is unset. Merges https://github.com/espressif/esp-idf/pull/6587 --- export.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/export.sh b/export.sh index 56ee1ff66a..a7ee837807 100644 --- a/export.sh +++ b/export.sh @@ -141,7 +141,7 @@ idf_export_main() { } enable_autocomplete() { - if [ -n "$ZSH_VERSION" ] + if [ -n "${ZSH_VERSION-}" ] then autoload -Uz compinit && compinit -u eval "$(env _IDF.PY_COMPLETE=source_zsh idf.py)" || echo "WARNING: Failed to load shell autocompletion!" From 16731833fb52df7f870b4ad73e304eb1efe9c36b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ga=C5=88o?= Date: Sun, 28 Feb 2021 23:26:06 +0100 Subject: [PATCH 2/2] add default value for unset env variables Closes IDFGH-4784 --- export.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/export.sh b/export.sh index a7ee837807..fe567bdac0 100644 --- a/export.sh +++ b/export.sh @@ -17,7 +17,7 @@ idf_export_main() { # Doing this in case someone tries to chmod +x it and execute... # shellcheck disable=SC2128,SC2169,SC2039 # ignore array expansion warning - if [ -n "${BASH_SOURCE}" ] && [ "${BASH_SOURCE[0]}" = "${0}" ] + if [ -n "${BASH_SOURCE-}" ] && [ "${BASH_SOURCE[0]}" = "${0}" ] then echo "This script should be sourced, not executed:" # shellcheck disable=SC2039 # reachable only with bash @@ -32,10 +32,10 @@ idf_export_main() { self_path="" # shellcheck disable=SC2128 # ignore array expansion warning - if [ -n "${BASH_SOURCE}" ] + if [ -n "${BASH_SOURCE-}" ] then self_path="${BASH_SOURCE}" - elif [ -n "${ZSH_VERSION}" ] + elif [ -n "${ZSH_VERSION-}" ] then self_path="${(%):-%x}" else @@ -145,7 +145,8 @@ enable_autocomplete() { then autoload -Uz compinit && compinit -u eval "$(env _IDF.PY_COMPLETE=source_zsh idf.py)" || echo "WARNING: Failed to load shell autocompletion!" - else + elif [ -n "${BASH_SOURCE-}" ] + then eval "$(env _IDF.PY_COMPLETE=source_bash idf.py)" || echo "WARNING: Failed to load shell autocompletion!" fi }