Prevent lock and temp-File to remain after forced exit.

Added trap to remove those temporary files if the script gets stopped
unexpectedly (e.g. when vim is exited before the tag-file is fully
generated.)

Also changed /bin/sh to /bin/bash, because [[ ]] doesn't work with an
standard shell. You need at least bash.
Use more proper `sh` syntax.
Merge changes.