mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 20:33:08 +00:00
style cleanups (make style-all)
This commit is contained in:
parent
d22743dad0
commit
af22bf3501
8 changed files with 51 additions and 54 deletions
|
@ -74,7 +74,8 @@ function __fish_print_hostnames -d "Print a list of known hostnames"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if test -n "$new_paths";
|
if test -n "$new_paths"
|
||||||
|
|
||||||
_recursive $new_paths
|
_recursive $new_paths
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -241,8 +241,8 @@ static bool builtin_bind_insert(bind_cmd_opts_t &opts, int optind, int argc, wch
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (builtin_bind_add(argv[optind], argv + (optind + 1), argc - (optind + 1),
|
if (builtin_bind_add(argv[optind], argv + (optind + 1), argc - (optind + 1), opts.bind_mode,
|
||||||
opts.bind_mode, opts.sets_bind_mode, opts.use_terminfo, streams)) {
|
opts.sets_bind_mode, opts.use_terminfo, streams)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ int builtin_block(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
||||||
}
|
}
|
||||||
case UNSET: {
|
case UNSET: {
|
||||||
while (block != NULL && block->type() != FUNCTION_CALL &&
|
while (block != NULL && block->type() != FUNCTION_CALL &&
|
||||||
block->type() != FUNCTION_CALL_NO_SHADOW) {
|
block->type() != FUNCTION_CALL_NO_SHADOW) {
|
||||||
// Set it in function scope
|
// Set it in function scope
|
||||||
block = parser.block_at_index(++block_idx);
|
block = parser.block_at_index(++block_idx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "proc.h"
|
#include "proc.h"
|
||||||
#include "reader.h"
|
#include "reader.h"
|
||||||
#include "tokenizer.h"
|
#include "tokenizer.h"
|
||||||
#include "wutil.h" // IWYU pragma: keep
|
#include "wutil.h" // IWYU pragma: keep
|
||||||
|
|
||||||
/// Builtin for putting a job in the foreground.
|
/// Builtin for putting a job in the foreground.
|
||||||
int builtin_fg(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
int builtin_fg(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
||||||
|
|
|
@ -37,19 +37,18 @@ struct function_cmd_opts_t {
|
||||||
// This command is atypical in using the "+" (REQUIRE_ORDER) option for flag parsing.
|
// This command is atypical in using the "+" (REQUIRE_ORDER) option for flag parsing.
|
||||||
// This is needed due to the semantics of the -a/--argument-names flag.
|
// This is needed due to the semantics of the -a/--argument-names flag.
|
||||||
static const wchar_t *short_options = L"+:a:d:e:hj:p:s:v:w:SV:";
|
static const wchar_t *short_options = L"+:a:d:e:hj:p:s:v:w:SV:";
|
||||||
static const struct woption long_options[] = {
|
static const struct woption long_options[] = {{L"description", required_argument, NULL, 'd'},
|
||||||
{L"description", required_argument, NULL, 'd'},
|
{L"on-signal", required_argument, NULL, 's'},
|
||||||
{L"on-signal", required_argument, NULL, 's'},
|
{L"on-job-exit", required_argument, NULL, 'j'},
|
||||||
{L"on-job-exit", required_argument, NULL, 'j'},
|
{L"on-process-exit", required_argument, NULL, 'p'},
|
||||||
{L"on-process-exit", required_argument, NULL, 'p'},
|
{L"on-variable", required_argument, NULL, 'v'},
|
||||||
{L"on-variable", required_argument, NULL, 'v'},
|
{L"on-event", required_argument, NULL, 'e'},
|
||||||
{L"on-event", required_argument, NULL, 'e'},
|
{L"wraps", required_argument, NULL, 'w'},
|
||||||
{L"wraps", required_argument, NULL, 'w'},
|
{L"help", no_argument, NULL, 'h'},
|
||||||
{L"help", no_argument, NULL, 'h'},
|
{L"argument-names", required_argument, NULL, 'a'},
|
||||||
{L"argument-names", required_argument, NULL, 'a'},
|
{L"no-scope-shadowing", no_argument, NULL, 'S'},
|
||||||
{L"no-scope-shadowing", no_argument, NULL, 'S'},
|
{L"inherit-variable", required_argument, NULL, 'V'},
|
||||||
{L"inherit-variable", required_argument, NULL, 'V'},
|
{NULL, 0, NULL, 0}};
|
||||||
{NULL, 0, NULL, 0}};
|
|
||||||
|
|
||||||
static int parse_cmd_opts(function_cmd_opts_t &opts, int *optind, //!OCLINT(high ncss method)
|
static int parse_cmd_opts(function_cmd_opts_t &opts, int *optind, //!OCLINT(high ncss method)
|
||||||
int argc, wchar_t **argv, parser_t &parser, io_streams_t &streams,
|
int argc, wchar_t **argv, parser_t &parser, io_streams_t &streams,
|
||||||
|
@ -250,7 +249,7 @@ int builtin_function(parser_t &parser, io_streams_t &streams, const wcstring_lis
|
||||||
function_data_t d;
|
function_data_t d;
|
||||||
d.name = function_name;
|
d.name = function_name;
|
||||||
if (!opts.description.empty()) d.description = opts.description;
|
if (!opts.description.empty()) d.description = opts.description;
|
||||||
//d.description = opts.description;
|
// d.description = opts.description;
|
||||||
d.events.swap(opts.events);
|
d.events.swap(opts.events);
|
||||||
d.shadow_scope = opts.shadow_scope;
|
d.shadow_scope = opts.shadow_scope;
|
||||||
d.named_arguments.swap(opts.named_arguments);
|
d.named_arguments.swap(opts.named_arguments);
|
||||||
|
|
|
@ -127,8 +127,7 @@ static int parse_cmd_opts(status_cmd_opts_t &opts, int *optind, //!OCLINT(high
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
if (!set_status_cmd(cmd, opts, STATUS_IS_INTERACTIVE_JOB_CTRL,
|
if (!set_status_cmd(cmd, opts, STATUS_IS_INTERACTIVE_JOB_CTRL, streams)) {
|
||||||
streams)) {
|
|
||||||
return STATUS_CMD_ERROR;
|
return STATUS_CMD_ERROR;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -355,8 +355,7 @@ static std::map<char, decltype(*handle_flag_N)> flag_to_function = {
|
||||||
{'N', handle_flag_N}, {'a', handle_flag_a}, {'c', handle_flag_c}, {'e', handle_flag_e},
|
{'N', handle_flag_N}, {'a', handle_flag_a}, {'c', handle_flag_c}, {'e', handle_flag_e},
|
||||||
{'f', handle_flag_f}, {'i', handle_flag_i}, {'l', handle_flag_l}, {'m', handle_flag_m},
|
{'f', handle_flag_f}, {'i', handle_flag_i}, {'l', handle_flag_l}, {'m', handle_flag_m},
|
||||||
{'n', handle_flag_n}, {'q', handle_flag_q}, {'r', handle_flag_r}, {'s', handle_flag_s},
|
{'n', handle_flag_n}, {'q', handle_flag_q}, {'r', handle_flag_r}, {'s', handle_flag_s},
|
||||||
{'v', handle_flag_v}
|
{'v', handle_flag_v}};
|
||||||
};
|
|
||||||
|
|
||||||
/// Parse the arguments for flags recognized by a specific string subcommand.
|
/// Parse the arguments for flags recognized by a specific string subcommand.
|
||||||
static int parse_opts(options_t *opts, int *optind, int n_req_args, int argc, wchar_t **argv,
|
static int parse_opts(options_t *opts, int *optind, int n_req_args, int argc, wchar_t **argv,
|
||||||
|
@ -514,38 +513,38 @@ class wildcard_matcher_t : public string_matcher_t {
|
||||||
if (wcpattern.front() != ANY_STRING) wcpattern.insert(0, 1, ANY_STRING);
|
if (wcpattern.front() != ANY_STRING) wcpattern.insert(0, 1, ANY_STRING);
|
||||||
if (wcpattern.back() != ANY_STRING) wcpattern.push_back(ANY_STRING);
|
if (wcpattern.back() != ANY_STRING) wcpattern.push_back(ANY_STRING);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~wildcard_matcher_t() {}
|
||||||
|
|
||||||
|
bool report_matches(const wchar_t *arg) {
|
||||||
|
// Note: --all is a no-op for glob matching since the pattern is always matched
|
||||||
|
// against the entire argument.
|
||||||
|
bool match;
|
||||||
|
|
||||||
|
if (opts.ignore_case) {
|
||||||
|
wcstring s = arg;
|
||||||
|
for (size_t i = 0; i < s.length(); i++) {
|
||||||
|
s[i] = towlower(s[i]);
|
||||||
}
|
}
|
||||||
|
match = wildcard_match(s, wcpattern, false);
|
||||||
virtual ~wildcard_matcher_t() {}
|
} else {
|
||||||
|
match = wildcard_match(arg, wcpattern, false);
|
||||||
bool report_matches(const wchar_t *arg) {
|
|
||||||
// Note: --all is a no-op for glob matching since the pattern is always matched
|
|
||||||
// against the entire argument.
|
|
||||||
bool match;
|
|
||||||
|
|
||||||
if (opts.ignore_case) {
|
|
||||||
wcstring s = arg;
|
|
||||||
for (size_t i = 0; i < s.length(); i++) {
|
|
||||||
s[i] = towlower(s[i]);
|
|
||||||
}
|
|
||||||
match = wildcard_match(s, wcpattern, false);
|
|
||||||
} else {
|
|
||||||
match = wildcard_match(arg, wcpattern, false);
|
|
||||||
}
|
|
||||||
if (match ^ opts.invert_match) {
|
|
||||||
total_matched++;
|
|
||||||
|
|
||||||
if (!opts.quiet) {
|
|
||||||
if (opts.index) {
|
|
||||||
streams.out.append_format(L"1 %lu\n", wcslen(arg));
|
|
||||||
} else {
|
|
||||||
streams.out.append(arg);
|
|
||||||
streams.out.append(L'\n');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
if (match ^ opts.invert_match) {
|
||||||
|
total_matched++;
|
||||||
|
|
||||||
|
if (!opts.quiet) {
|
||||||
|
if (opts.index) {
|
||||||
|
streams.out.append_format(L"1 %lu\n", wcslen(arg));
|
||||||
|
} else {
|
||||||
|
streams.out.append(arg);
|
||||||
|
streams.out.append(L'\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static wcstring pcre2_strerror(int err_code) {
|
static wcstring pcre2_strerror(int err_code) {
|
||||||
|
|
|
@ -133,7 +133,6 @@ class wgetopter_t {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// Describe the long-named options requested by the application. The LONG_OPTIONS argument to
|
/// Describe the long-named options requested by the application. The LONG_OPTIONS argument to
|
||||||
/// getopt_long or getopt_long_only is a vector of `struct option' terminated by an element
|
/// getopt_long or getopt_long_only is a vector of `struct option' terminated by an element
|
||||||
/// containing a name which is zero.
|
/// containing a name which is zero.
|
||||||
|
|
Loading…
Reference in a new issue