ast_cli(fd, "%25.25s %s\n", e->_full_cmd, S_OR(e->summary, ""));
found++;
}
- AST_LIST_UNLOCK(&helpers);
+ if (!locked)
+ AST_LIST_UNLOCK(&helpers);
if (!locked && !found && matchstr[0])
ast_cli(fd, "No such command '%s'.\n", matchstr);
- return 0;
+ return RESULT_SUCCESS;
}
static int help_workhorse(int fd, char *match[])
{
char fullcmd[80];
struct ast_cli_entry *e;
+ int res = RESULT_SUCCESS;
if (argc < 1)
return RESULT_SHOWUSAGE;
AST_LIST_LOCK(&helpers);
e = find_cli(argv + 1, 1); /* try exact match first */
- if (!e)
- return help1(fd, argv + 1, 1 /* locked */);
+ if (!e) {
+ res = help1(fd, argv + 1, 1 /* locked */);
+ AST_LIST_UNLOCK(&helpers);
+ return res;
+ }
if (e->usage)
ast_cli(fd, "%s", e->usage);
else {
ast_cli(fd, "No help text available for '%s'.\n", fullcmd);
}
AST_LIST_UNLOCK(&helpers);
- return RESULT_SUCCESS;
+ return res;
}
static char *parse_args(const char *s, int *argc, char *argv[], int max, int *trailingwhitespace)