bash: refactor searching for subcommands on the command line