Is there a way to preprocess input to bash?

I would like to be able to define arbitrary modifications to command lines that happen before bash sees them at all, ie, before expansion of any kind. Is this possible?

I'm not trying to solve one particular problem, I'm really just curious if it is possible to obtain exactly this functionality without writing my own shell.


I would suggest that you investigate the possibility of binding the readline function accept-line (Ctrl-m) into the Bash completion facility (readline complete) where you would be able to process the line and should be able to execute it from there.