Explicitly set shell type in export.sh for bash and zsh
-Most of the issues reported with the updated export scripts are related
to shell detection. Since we already know the shell type for commonly
used ones like bash or zsh, we can pass the shell type directly to the
activate script. This should hopefully resolve the shell detection
problems for most users.
This update also modifies the shell type detection to rely solely on
psutil.Process().cmdline() rather than psutil.Process().exe(). This
change aims to resolve permission issues that may occur if, for example,
the Python binary has certain capabilities assigned.
Move shell completion to the init script
- Currently we are expanding the autocompletion in the activate script and
adding the expanded commands into the init script. To avoid
concerns about shell versions, move the entire expansion to the init
script.
The rc scripts should be included only when a new shell is started. At
present, for bash and zsh, we are also including them in the export
scripts, which is incorrect and may cause recursion.
Closes https://github.com/espressif/esp-idf/issues/14584
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
Currently, we are using psutil.Process().name(), which includes the
command as entered on the command line. This becomes an issue if the
export script is initiated within another script.
run.sh
#!/usr/bin/bash
. ./export.sh
In this case the activate script will see `run.sh` instead of bash.
/proc/<pid>/com vs /proc/<pid>/exe
Use exe(), which contains the full executable path to fix this.
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>