mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-04 13:14:32 +02:00
Correct export.sh failure exit code and cleanup
In failure cases, when idf_export_main() returns 1 (failure), the export.sh script returns 0 (success). This makes it very difficult to detect failure when writing scripts that use export.sh. Furthermore, idf_export_main() does not clean up all internal variables and functions in failure cases. Move all cleanup steps into a cleanup function and pass the return value from idf_export_main() to the cleanup function so it can return with that same return value. Signed-off-by: Marek Fiala <marek.fiala@espressif.com> Closes https://github.com/espressif/esp-idf/pull/5744
This commit is contained in:
29
export.sh
29
export.sh
@@ -126,7 +126,15 @@ __main() {
|
|||||||
__verbose " ${PATH}"
|
__verbose " ${PATH}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clean up
|
|
||||||
|
__verbose "Done! You can now compile ESP-IDF projects."
|
||||||
|
__verbose "Go to the project directory and run:"
|
||||||
|
__verbose ""
|
||||||
|
__verbose " idf.py build"
|
||||||
|
__verbose ""
|
||||||
|
}
|
||||||
|
|
||||||
|
__cleanup() {
|
||||||
unset old_path
|
unset old_path
|
||||||
unset paths
|
unset paths
|
||||||
unset path_prefix
|
unset path_prefix
|
||||||
@@ -135,16 +143,19 @@ __main() {
|
|||||||
unset idf_exports
|
unset idf_exports
|
||||||
unset ESP_PYTHON
|
unset ESP_PYTHON
|
||||||
|
|
||||||
|
unset __realpath
|
||||||
|
unset __main
|
||||||
|
unset __verbose
|
||||||
|
unset __enable_autocomplete
|
||||||
|
unset __cleanup
|
||||||
|
|
||||||
# Not unsetting IDF_PYTHON_ENV_PATH, it can be used by IDF build system
|
# Not unsetting IDF_PYTHON_ENV_PATH, it can be used by IDF build system
|
||||||
# to check whether we are using a private Python environment
|
# to check whether we are using a private Python environment
|
||||||
|
|
||||||
__verbose "Done! You can now compile ESP-IDF projects."
|
return $1
|
||||||
__verbose "Go to the project directory and run:"
|
|
||||||
__verbose ""
|
|
||||||
__verbose " idf.py build"
|
|
||||||
__verbose ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
__enable_autocomplete() {
|
__enable_autocomplete() {
|
||||||
click_version="$(python -c 'import click; print(click.__version__.split(".")[0])')"
|
click_version="$(python -c 'import click; print(click.__version__.split(".")[0])')"
|
||||||
if [[ click_version -lt 8 ]]
|
if [[ click_version -lt 8 ]]
|
||||||
@@ -171,8 +182,4 @@ __enable_autocomplete() {
|
|||||||
|
|
||||||
__main
|
__main
|
||||||
__enable_autocomplete
|
__enable_autocomplete
|
||||||
|
__cleanup $?
|
||||||
unset __realpath
|
|
||||||
unset __main
|
|
||||||
unset __verbose
|
|
||||||
unset __enable_autocomplete
|
|
||||||
|
Reference in New Issue
Block a user