change return type of match_device() to int so it can return a negative value on regex failure
add error check to match_device() call in run_list_command()
fix wrong check on match_device() in run_event_command()