diff --git a/src/builtin_wait.cpp b/src/builtin_wait.cpp index 861c92788..25a4b2328 100644 --- a/src/builtin_wait.cpp +++ b/src/builtin_wait.cpp @@ -178,9 +178,11 @@ int builtin_wait(parser_t &parser, io_streams_t &streams, wchar_t **argv) { const wchar_t *cmd = argv[0]; int argc = builtin_count_args(argv); bool any_flag = false; // flag for -n option + bool print_help = false; - static const wchar_t *const short_options = L":n"; + static const wchar_t *const short_options = L":nh"; static const struct woption long_options[] = {{L"any", no_argument, nullptr, 'n'}, + {L"help", no_argument, nullptr, 'h'}, {nullptr, 0, nullptr, 0}}; int opt; @@ -190,6 +192,9 @@ int builtin_wait(parser_t &parser, io_streams_t &streams, wchar_t **argv) { case 'n': any_flag = true; break; + case 'h': + print_help = true; + break; case ':': { builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]); return STATUS_INVALID_ARGS; @@ -205,6 +210,11 @@ int builtin_wait(parser_t &parser, io_streams_t &streams, wchar_t **argv) { } } + if (print_help) { + builtin_print_help(parser, streams, cmd); + return STATUS_CMD_OK; + } + if (w.woptind == argc) { // no jobs specified retval = wait_for_backgrounds(parser, any_flag);