Prevent empty and immediate duplicate lines being added to the history.

It is not very useful to have a command history containing all the same
command if it is run consecutively, additionally lines containing only
spaces or tabs are generally not useful, so this change prevents these
types of lines from being added to the history.