bash script, error handling, path fixes