diff --git a/export.sh b/export.sh index c3d4617ba0..21b9250d25 100644 --- a/export.sh +++ b/export.sh @@ -1,6 +1,6 @@ # This script should be sourced, not executed. -realpath_int() { +__realpath() { wdir="$PWD"; [ "$PWD" = "/" ] && wdir="" arg=$1 case "$arg" in @@ -12,7 +12,12 @@ realpath_int() { } -idf_export_main() { +__verbose() { + [[ -n ${IDF_QUIET} ]] && return + echo "$@" +} + +__main() { # The file doesn't have executable permissions, so this shouldn't really happen. # Doing this in case someone tries to chmod +x it and execute... @@ -82,15 +87,15 @@ idf_export_main() { echo "Detecting the Python interpreter" . "${IDF_PATH}/tools/detect_python.sh" - echo "Adding ESP-IDF tools to PATH..." + __verbose "Adding ESP-IDF tools to PATH..." # Call idf_tools.py to export tool paths export IDF_TOOLS_EXPORT_CMD=${IDF_PATH}/export.sh export IDF_TOOLS_INSTALL_CMD=${IDF_PATH}/install.sh idf_exports=$("$ESP_PYTHON" "${IDF_PATH}/tools/idf_tools.py" export) || return 1 eval "${idf_exports}" - echo "Using Python interpreter in $(which python)" - echo "Checking if Python packages are up to date..." + __verbose "Using Python interpreter in $(which python)" + __verbose "Checking if Python packages are up to date..." python "${IDF_PATH}/tools/check_python_dependencies.py" || return 1 @@ -108,17 +113,17 @@ idf_export_main() { # shellcheck disable=SC2169,SC2039 # unreachable with 'dash' paths="${path_prefix//:/ }" if [ -n "${paths}" ]; then - echo "Added the following directories to PATH:" + __verbose "Added the following directories to PATH:" else - echo "All paths are already set." + __verbose "All paths are already set." fi for path_entry in ${paths} do - echo " ${path_entry}" + __verbose " ${path_entry}" done else - echo "Updated PATH variable:" - echo " ${PATH}" + __verbose "Updated PATH variable:" + __verbose " ${PATH}" fi # Clean up @@ -133,11 +138,11 @@ idf_export_main() { # Not unsetting IDF_PYTHON_ENV_PATH, it can be used by IDF build system # to check whether we are using a private Python environment - echo "Done! You can now compile ESP-IDF projects." - echo "Go to the project directory and run:" - echo "" - echo " idf.py build" - echo "" + __verbose "Done! You can now compile ESP-IDF projects." + __verbose "Go to the project directory and run:" + __verbose "" + __verbose " idf.py build" + __verbose "" } enable_autocomplete() { @@ -164,9 +169,10 @@ enable_autocomplete() { } -idf_export_main +__main enable_autocomplete -unset realpath_int -unset idf_export_main +unset __realpath +unset __main +unset __verbose unset enable_autocomplete