From: Jozsef Kadlecsik Date: Tue, 1 Feb 2011 19:35:33 +0000 (+0100) Subject: Allow "new" as a commad alias to "create" X-Git-Tag: v6.0~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8f9e25aea2bce144e037286357f9c4dc9f9b8bb;p=thirdparty%2Fipset.git Allow "new" as a commad alias to "create" It's too easy to mistype "n" to "new", so just allow it. --- diff --git a/src/ui.c b/src/ui.c index 176e1b2d..3601c65b 100644 --- a/src/ui.c +++ b/src/ui.c @@ -23,9 +23,9 @@ const struct ipset_commands ipset_commands[] = { /* Order is important */ - { /* c[reate], --create, n, -N */ + { /* c[reate], --create, n[ew], -N */ .cmd = IPSET_CMD_CREATE, - .name = { "create", "n" }, + .name = { "create", "new" }, .has_arg = IPSET_MANDATORY_ARG2, .help = "SETNAME TYPENAME [type-specific-options]\n" " Create a new set", @@ -143,14 +143,14 @@ ipset_match_cmd(const char *arg, const char * const name[]) if (len > strlen(name[0]) || !len) return false; - else if (strncmp(arg, name[0], len) == 0) + else if (len > 1 && + ((strncmp(arg, name[0], len) == 0) || + (name[1] != NULL && (strncmp(arg, name[1], len) == 0)))) return true; else if (len != 1) return false; - else if (name[1] == NULL) - return tolower(arg[0]) == name[0][0]; - else - return tolower(arg[0]) == name[1][0]; + else return tolower(arg[0]) == name[0][0] || + (name[1] != NULL && tolower(arg[0]) == name[1][0]); } const struct ipset_envopts ipset_envopts[] = {