Enable add-apt-repository to work in automation scripts

The old version of the code silently exits when no tty is attached.
It also fails to pass the final exit status back to the caller.
Merge pull request #38 from WolverineFan/bug/master/fix_silent_notty_failure

Enable add-apt-repository to work in automation scripts