mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-29 13:23:53 +08:00
14d2a6d8ff
Let's hope this doesn't causes build failures for e.g. musl: I just know it's good on macOS and our Linux CI. It's been a long time. One fix this brings, is I discovered we #include assert.h or cassert in a lot of places. If those ever happen to be in a file that doesn't include common.h, or we are before common.h gets included, we're unawaringly working with the system 'assert' macro again, which may get disabled for debug builds or at least has different behavior on crash. We undef 'assert' and redefine it in common.h. Those were all eliminated, except in one catch-22 spot for maybe.h: it can't include common.h. A fix might be to make a fish_assert.h that *usually* common.h exports.
41 lines
1.2 KiB
C++
41 lines
1.2 KiB
C++
// Implementation of the emit builtin.
|
|
#include "config.h" // IWYU pragma: keep
|
|
|
|
#include "emit.h"
|
|
|
|
#include <utility>
|
|
|
|
#include "../builtin.h"
|
|
#include "../common.h"
|
|
#include "../event.h"
|
|
#include "../fallback.h" // IWYU pragma: keep
|
|
#include "../io.h"
|
|
#include "../maybe.h"
|
|
#include "../wutil.h" // IWYU pragma: keep
|
|
|
|
/// Implementation of the builtin emit command, used to create events.
|
|
maybe_t<int> builtin_emit(parser_t &parser, io_streams_t &streams, const wchar_t **argv) {
|
|
const wchar_t *cmd = argv[0];
|
|
int argc = builtin_count_args(argv);
|
|
help_only_cmd_opts_t opts;
|
|
|
|
int optind;
|
|
int retval = parse_help_only_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
|
if (retval != STATUS_CMD_OK) return retval;
|
|
|
|
if (opts.print_help) {
|
|
builtin_print_help(parser, streams, cmd);
|
|
return STATUS_CMD_OK;
|
|
}
|
|
|
|
if (!argv[optind]) {
|
|
streams.err.append_format(L"%ls: expected event name\n", cmd);
|
|
return STATUS_INVALID_ARGS;
|
|
}
|
|
|
|
const wchar_t *eventname = argv[optind];
|
|
wcstring_list_t args(argv + optind + 1, argv + argc);
|
|
event_fire_generic(parser, eventname, std::move(args));
|
|
return STATUS_CMD_OK;
|
|
}
|