Unable to load hook properly
I tried multiple operating systems, most of which were available, but on the Euler system, it didn't work and the environment variable PROMPT-COMMAND was still ‘history - a‘,I loaded it according to the document instructions and also manually sourced it. What could be the reason for this
it didn't work and the environment variable PROMPT-COMMAND was still ‘history - a‘,
PROMPT_COMMAND is not an environment variable, but a Bash array. How did you check the value of PROMPT_COMMAND? If you used something like echo "$PROMPT_COMMAND", it only prints the first element of the array. Could you check the state of PROMPT_COMMAND with the following command?
declare -p PROMPT_COMMAND
What is the result of the above command?
it didn't work and the environment variable PROMPT-COMMAND was still ‘history - a‘,
PROMPT_COMMANDis not an environment variable, but a Bash array. How did you check the value ofPROMPT_COMMAND? If you used something likeecho "$PROMPT_COMMAND", it only prints the first element of the array. Could you check the state ofPROMPT_COMMANDwith the following command?declare -p PROMPT_COMMAND What is the result of the above command?
I confirm that PROMPT_CMMAND is incorrect, and I have also read according to the instructions you provided
declare -- PROMPT_CMMAND=" history - a "
Thanks. What is the Bash version in your Euler system? Could you provide the result of the following command?
$ declare -p BASH_VERSION BASH_VERSINFO
Also, what is the result of the following command? Maybe the include guard of a parent session is leaked.
$ declare -p bash_preexec_imported __bp_imported
Thanks. What is the Bash version in your Euler system? Could you provide the result of the following command?
$ declare -p BASH_VERSION BASH_VERSINFO Also, what is the result of the following command? Maybe the include guard of a parent session is leaked.
$ declare -p bash_preexec_imported __bp_imported
Thank you. After executing the command, I returned the following result
[root@localhost ~]# source /etc/edrAgentGoConf/bash-preexec.sh
[root@localhost ~]# declare -p BASH_VERSION BASH_VERSINFO
declare -- BASH_VERSION="5.1.9(1)-release"
declare -ar BASH_VERSINFO=([0]="5" [1]="1" [2]="9" [3]="1" [4]="release" [5]="aarch64-openEuler-linux-gnu")
[root@localhost ~]# declare -p bash_preexec_imported __bp_imported
-bash: declare: bash_preexec_imported:not found
declare -- __bp_imported="defined"
[root@localhost ~]# declare -p bash_preexec_imported __bp_imported -bash: declare: bash_preexec_imported:not found declare -- __bp_imported="defined"
Thanks. This implies that an older version of bash-preexec is loaded. If /etc/edrAgentGoConf/bash-preexec.sh is the latest version of bash-preexec, it means that another instance of bash-preexec is loaded elsewhere.
- Q: What is the result of the following command?
$ (shopt -s extdebug; declare -F __bp_preexec_invoke_exec)
Also, I would like to know the results of declare -p __bp_imported before attempting to load bash-preexec.
-
Q: Could you put the following line at the top of
~/.bashrc, start a new Bash session, and see the output? What is the output?
# at the top of bashrc
declare -p __bp_imported >&2
-
Q: If you set
PROMPT_COMMAND='history -a'in your~/.bashrcor any other configuration files, could you put the following immediately beforePROMPT_COMMAND='history -a'and start a new Bash session? What is the output?
# immediately before setting PROMPT_COMMAND
declare -p PROMPT_COMMAND >&2
After testing, you can revert the above changes to your Bash settings.