Fix exception when finding links in output from run commands

The script uses ruby’s ‘expand_path’ with the potential path found in the command output, but this command can throw an exception (on non-path arguments).