diff --git a/src/shared/shell.c b/src/shared/shell.c
index e7f17e0..97d9157 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
size_t len;
char *man, *opt;
int flags = WRDE_NOCMD;
+ bool optargs = false;
if (!entry->arg || entry->arg[0] == '\0') {
if (argc > 1) {
goto optional;
}
man = strndup(opt, man - opt + 1);
+ optargs = true;
}
if (parse_args(man, &w, "<>", flags) < 0) {
free(opt);
/* Check if there are too many arguments */
- if ((unsigned) argc - 1 > w.we_wordc && !w.we_offs) {
+ if (!optargs && ((unsigned int) argc - 1 > w.we_wordc && !w.we_offs)) {
print_text(COLOR_HIGHLIGHT, "Too many arguments: %d > %zu",
argc - 1, w.we_wordc);
goto fail;