mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-10 12:51:15 -03:00
Introduce $FISH_DEBUG and $FISH_DEBUG_OUTPUT variables
Same as the `--debug` and `--debug-output` options, can be enabled when the option can't be passed, e.g. in linux shebangs. Fixes #7359.
This commit is contained in:
13
src/fish.cpp
13
src/fish.cpp
@@ -419,10 +419,23 @@ int main(int argc, char **argv) {
|
||||
argv = const_cast<char **>(dummy_argv); //!OCLINT(parameter reassignment)
|
||||
argc = 1; //!OCLINT(parameter reassignment)
|
||||
}
|
||||
|
||||
// Enable debug categories set in FISH_DEBUG.
|
||||
// This is in *addition* to the ones given via --debug.
|
||||
if (const char *debug_categories = getenv("FISH_DEBUG")) {
|
||||
activate_flog_categories_by_pattern(str2wcstring(debug_categories));
|
||||
}
|
||||
|
||||
fish_cmd_opts_t opts{};
|
||||
my_optind = fish_parse_opt(argc, argv, &opts);
|
||||
|
||||
// Direct any debug output right away.
|
||||
// --debug-output takes precedence, otherwise $FISH_DEBUG_OUTPUT is used.
|
||||
if (opts.debug_output.empty()) {
|
||||
const char *var = getenv("FISH_DEBUG_OUTPUT");
|
||||
if (var) opts.debug_output = var;
|
||||
}
|
||||
|
||||
FILE *debug_output = nullptr;
|
||||
if (!opts.debug_output.empty()) {
|
||||
debug_output = fopen(opts.debug_output.c_str(), "w");
|
||||
|
||||
Reference in New Issue
Block a user