Tcsh precmd weird question

I encountered a weird question while using tcsh. I wrote a test script trying to control 'history' behavior as below,

set history=(1000 "%h\t%Y-%W-%D %P %R\n")
set savehist=(1000 merge)
alias precmd 'history -S;history -M'

I was hoping all the user's commands input in multiple terminals can be recorded to the history file without lose.
My script can worked well in RHEL 6 ( the default tcsh version is 6.17).
However, when I tested my script in RHEL 4/5 (tcsh version 6.13 / 6.14), the precmd alias resulted in command line in malfunction.
Whatever I input on the command line after running my script, it was just jumping to the newline, nothing happened.

I have no idea what went wrong. Does anybody have idea? Thanks.

What does 'jumping to the newline' mean?

Sorry, I didn't describe it clearly.
I mean after running my script, I input any coomands and then press enter, it shows nothing. I can't even use exit command to close the terminal.

I can reproduce this with tcsh 6.12. After

alias precmd 'history -S;history -M'

it only echos the typed commands, without running them.
Looks like a bug.
Try

alias postcmd 'history -S;history -M'

Doesn't this even make more sense?

1 Like

Thank you for confirming this.
It seems like no workaround, does it?

I haven't tried postcmd, I �ll try this to see what happen. Thanks.

I've tried postcmd, it works well. Thank you.

Just report my experiences using precmd and postcmd. Actually, I've had enough coping with tcsh bugs.
I'm now using tcsh 6.17.00 (Astron).
On account of precmd's bug, I used postcmd to do an alias command as below

It looked worked, but actually this alias caused while loop in a shell script worked erratically.
While I did a simple increment by 1 to a variable, it only looped once and finished.
It can be easily reproduced this bug.

My suggestion is using this two functions in precaution if you don't want to mess up with other built-in commands.
I've given up on the "history stuff" unless someone has a better solution.