1

If I place this on the top the Bash script, Control+C doesn't work.

exit-function() {
  echo "Hey hey!"
}    
trap exit-function INT

But if I put it few lines after, then Control+C is trapped.

UPDATE:

If it's placed after source "$HOME/.rvm/scripts/rvm", then it works.

So if you source another file, trap INT defined before won't work?

Jolta
  • 2,620
  • 1
  • 29
  • 42
Cheng
  • 4,816
  • 4
  • 41
  • 44

1 Answers1

1

One of the scripts that's sourced by the rvm script sets a trap which replaces the trap you set earlier. By setting one after the rvm script you're replacing the one it sets.

Dennis Williamson
  • 346,391
  • 90
  • 374
  • 439