Add -h flag to builtin wait

This commit is contained in:
Johannes Altmanninger 2020-03-31 21:16:42 +02:00
parent 7206be3e47
commit 66ae1a1edb

View File

@ -178,9 +178,11 @@ int builtin_wait(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
const wchar_t *cmd = argv[0]; const wchar_t *cmd = argv[0];
int argc = builtin_count_args(argv); int argc = builtin_count_args(argv);
bool any_flag = false; // flag for -n option 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'}, static const struct woption long_options[] = {{L"any", no_argument, nullptr, 'n'},
{L"help", no_argument, nullptr, 'h'},
{nullptr, 0, nullptr, 0}}; {nullptr, 0, nullptr, 0}};
int opt; int opt;
@ -190,6 +192,9 @@ int builtin_wait(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
case 'n': case 'n':
any_flag = true; any_flag = true;
break; break;
case 'h':
print_help = true;
break;
case ':': { case ':': {
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]); builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
return STATUS_INVALID_ARGS; 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) { if (w.woptind == argc) {
// no jobs specified // no jobs specified
retval = wait_for_backgrounds(parser, any_flag); retval = wait_for_backgrounds(parser, any_flag);