7

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.

Personman
  • 313
  • 2
  • 7
  • What kind of modifications? If you just want shortcuts to things, use `alias`. – jtbandes Jul 24 '10 at 21:13
  • 1
    >"before expansion of any kind." I would like to do complete rewriting of entire command lines. Aliases and shell functions are the limitation I am trying to overcome. – Personman Jul 24 '10 at 21:28
  • related: http://superuser.com/questions/175799/does-bash-have-a-hook-that-is-run-before-executing-a-command – poindexter Apr 30 '12 at 14:10

1 Answers1

2

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.

Dennis Williamson
  • 106,229
  • 19
  • 167
  • 187
  • Can you give an example of how one would do this? Are you suggesting using a bind command to change the behavior of C-m? Or are you suggesting that complete offers some way to intercept accept-line? – poindexter Apr 27 '12 at 18:03