When running "emerge --list-sets" or "emerge --sync" without sufficient privileges, the contents of $PROMPT_COMMAND are executed. The same happens when autocompleting e.g. "emerge -uNDa @..." using app-shells/bash-completion-2.11, but only when pressing <tab> after entering at least "@", due to it runnging "emerge --list-sets". This was how I discovered it. If one has set $PROMPT_COMMAND to point to a function defined in /etc/bash/bashrc.d/examplefile it won't be found when $PROMPT_COMMAND is ran by emerge. This breaks autocompletion for sets when $PROMPT_COMMAND is set to a bash function. Reproducible: Always Steps to Reproduce: 1. run "emerge --list-sets" Actual Results: changed-deps changed-subslot deprecated-live-rebuild downgrade golang-rebuild installed live-rebuild module-rebuild preserved-rebuild profile rebuilt-binaries rust-rebuild security selected selected-packages selected-sets system unavailable unavailable-binaries world x11-module-rebuild bash: line 1: promtColor: command not found Expected Results: changed-deps changed-subslot deprecated-live-rebuild downgrade golang-rebuild installed live-rebuild module-rebuild preserved-rebuild profile rebuilt-binaries rust-rebuild security selected selected-packages selected-sets system unavailable unavailable-binaries world x11-module-rebuild
This suggests the shall you're calling emerge from a shell that has PROMPT_COMMAND exported but does not have promtColor exported from /etc/bash/bashrc.d/examplefile. Does the file export the function or not? If not then it's not really valid to use in an exported PROMPT_COMMAND.
$PROMPT_COMMAND is set in and the function it is set to are in /etc/bash/bashrc.d/examplefile. I suspected a bug in portage, since the issue only occurs on some emerge commands, but not on all.
Portage only runs PROMPT_COMMAND when it calls xtermTitle and xtermTitleReset functions for some commands, not all commands, so we don't expect to see the error for every emerge command. Can you attach your /etc/bash/bashrc.d/examplefile file? You need something like this in there: export -f promtColor
Created attachment 885160 [details] bash script defining $PROMPT_COMMAND and promtColor
(In reply to Paul Sopka from comment #4) > Created attachment 885160 [details] > bash script defining $PROMPT_COMMAND and promtColor It looks like you just need to add this: export -f promtColor
Thank you very much, it works! I am sorry to have bothered you with my unsuficcient understanding of bash. Thank you for working on Portage, it is truly amazing. Have a nice weekend Paul