How to use history commands with readonly PROMPT_COMMAND?

view story

http://unix.stackexchange.com – I'm sometimes logged in on a host which I do not control and where PROMPT_COMMAND is readonly. Is there some way to work around this to run history commands anyway, for example using PS1? I've tried PS1='$(history -a; history -c; history -r; echo finished)' - It prints finished at each prompt, but it doesn't seem to work: Open two terminals A and B on the same host. In terminal A, run a command a. In terminal B, run a command b. It terminal B, press ↑ twice. On a host where PROMPT_COMMAND='history -a; history -c; history -r;', this will result in terminal B showing a. On a host where PS1 (HowTos)