Strip newline ('\n') characters from safe_run output in detect_version()

The last commit changed the way how we process the output of safe_run()
commands. Now we need to strip newline characters where we don't need them.

Signed-off-by: Jan Blunck <jblunck@infradead.org>