Cannot source `export.sh` from another working directory (AUD-6560)
Is your feature request related to a problem? Please describe.
I am creating aliases for sourcing export.sh for each esp-idf and esp-adf versions. But sourcing esp-adf/export.sh only work when the terminal is inside esp-adf/.
From the code it uses dirname $0 to get the script path, but $0 only have the script path when executing it directly, when sourcing the $0 is just bash.
Describe the solution you'd like
It should copy the solution from esp-idf/export.sh. There it uses BASH_SOURCE env var, but I am not familiar with it.
Describe alternatives you've considered
I can make my alias do cd ~/esp/esp-adf/; . export.sh; cd -, but that pollutes $OLDPWD.
Additional context
Please check https://github.com/espressif/esp-adf/issues/1503