mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 12:23:09 +00:00
lint cleanup
This commit is contained in:
parent
a1744b5822
commit
175570b7ed
12 changed files with 42 additions and 38 deletions
|
@ -332,7 +332,7 @@ static int parse_cmd_opts(struct cmd_opts *opts, int *optind, //!OCLINT(high nc
|
|||
return STATUS_CMD_OK;
|
||||
}
|
||||
case L'?': {
|
||||
builtin_unknown_option(parser, streams, argv[0], argv[w.woptind - 1]);
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
// Implementation of the builtin builtin.
|
||||
#include "config.h" // IWYU pragma: keep
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
#include "builtin.h"
|
||||
#include "builtin_builtin.h"
|
||||
#include "common.h"
|
||||
#include "fallback.h" // IWYU pragma: keep
|
||||
#include "io.h"
|
||||
#include "path.h"
|
||||
#include "wgetopt.h"
|
||||
#include "wutil.h" // IWYU pragma: keep
|
||||
|
||||
|
@ -69,7 +71,7 @@ int builtin_builtin(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
|
||||
if (opts.list_names) {
|
||||
wcstring_list_t names = builtin_get_names();
|
||||
sort(names.begin(), names.end());
|
||||
std::sort(names.begin(), names.end());
|
||||
|
||||
for (size_t i = 0; i < names.size(); i++) {
|
||||
const wchar_t *el = names.at(i).c_str();
|
||||
|
|
|
@ -36,7 +36,7 @@ static int parse_cmd_opts(struct cmd_opts *opts, int *optind, int argc, wchar_t
|
|||
return STATUS_CMD_OK;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, argv[0], argv[w.woptind - 1]);
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
@ -64,7 +64,7 @@ int builtin_cd(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
|
||||
if (opts.print_help) {
|
||||
builtin_print_help(parser, streams, cmd, streams.out);
|
||||
return STATUS_INVALID_ARGS;
|
||||
return STATUS_CMD_OK;
|
||||
}
|
||||
|
||||
env_var_t dir_in;
|
||||
|
|
|
@ -167,6 +167,7 @@ static void write_part(const wchar_t *begin, const wchar_t *end, int cut_at_curs
|
|||
|
||||
/// The commandline builtin. It is used for specifying a new value for the commandline.
|
||||
int builtin_commandline(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
||||
wchar_t *cmd = argv[0];
|
||||
int buffer_part = 0;
|
||||
int cut_at_cursor = 0;
|
||||
|
||||
|
@ -205,7 +206,7 @@ int builtin_commandline(parser_t &parser, io_streams_t &streams, wchar_t **argv)
|
|||
|
||||
streams.err.append(argv[0]);
|
||||
streams.err.append(L": Can not set commandline in non-interactive mode\n");
|
||||
builtin_print_help(parser, streams, argv[0], streams.err);
|
||||
builtin_print_help(parser, streams, cmd, streams.err);
|
||||
return STATUS_CMD_ERROR;
|
||||
}
|
||||
|
||||
|
@ -299,11 +300,11 @@ int builtin_commandline(parser_t &parser, io_streams_t &streams, wchar_t **argv)
|
|||
break;
|
||||
}
|
||||
case 'h': {
|
||||
builtin_print_help(parser, streams, argv[0], streams.out);
|
||||
builtin_print_help(parser, streams, cmd, streams.out);
|
||||
return STATUS_CMD_OK;
|
||||
}
|
||||
case L'?': {
|
||||
builtin_unknown_option(parser, streams, argv[0], argv[w.woptind - 1]);
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
@ -320,13 +321,13 @@ int builtin_commandline(parser_t &parser, io_streams_t &streams, wchar_t **argv)
|
|||
if (buffer_part || cut_at_cursor || append_mode || tokenize || cursor_mode || line_mode ||
|
||||
search_mode || paging_mode) {
|
||||
streams.err.append_format(BUILTIN_ERR_COMBO, argv[0]);
|
||||
builtin_print_help(parser, streams, argv[0], streams.err);
|
||||
builtin_print_help(parser, streams, cmd, streams.err);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (argc == w.woptind) {
|
||||
streams.err.append_format(BUILTIN_ERR_MISSING, argv[0]);
|
||||
builtin_print_help(parser, streams, argv[0], streams.err);
|
||||
builtin_print_help(parser, streams, cmd, streams.err);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
|
@ -337,9 +338,8 @@ int builtin_commandline(parser_t &parser, io_streams_t &streams, wchar_t **argv)
|
|||
// the queue of unused keypresses.
|
||||
input_queue_ch(c);
|
||||
} else {
|
||||
streams.err.append_format(_(L"%ls: Unknown input function '%ls'"), argv[0],
|
||||
argv[i]);
|
||||
builtin_print_help(parser, streams, argv[0], streams.err);
|
||||
streams.err.append_format(_(L"%ls: Unknown input function '%ls'"), cmd, argv[i]);
|
||||
builtin_print_help(parser, streams, cmd, streams.err);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
}
|
||||
|
@ -359,30 +359,30 @@ int builtin_commandline(parser_t &parser, io_streams_t &streams, wchar_t **argv)
|
|||
// Check for invalid switch combinations.
|
||||
if ((search_mode || line_mode || cursor_mode || paging_mode) && (argc - w.woptind > 1)) {
|
||||
streams.err.append_format(L"%ls: Too many arguments", argv[0]);
|
||||
builtin_print_help(parser, streams, argv[0], streams.err);
|
||||
builtin_print_help(parser, streams, cmd, streams.err);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
if ((buffer_part || tokenize || cut_at_cursor) &&
|
||||
(cursor_mode || line_mode || search_mode || paging_mode)) {
|
||||
streams.err.append_format(BUILTIN_ERR_COMBO, argv[0]);
|
||||
builtin_print_help(parser, streams, argv[0], streams.err);
|
||||
builtin_print_help(parser, streams, cmd, streams.err);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
if ((tokenize || cut_at_cursor) && (argc - w.woptind)) {
|
||||
streams.err.append_format(
|
||||
BUILTIN_ERR_COMBO2, argv[0],
|
||||
BUILTIN_ERR_COMBO2, cmd,
|
||||
L"--cut-at-cursor and --tokenize can not be used when setting the commandline");
|
||||
builtin_print_help(parser, streams, argv[0], streams.err);
|
||||
builtin_print_help(parser, streams, cmd, streams.err);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (append_mode && !(argc - w.woptind)) {
|
||||
streams.err.append_format(
|
||||
BUILTIN_ERR_COMBO2, argv[0],
|
||||
BUILTIN_ERR_COMBO2, cmd,
|
||||
L"insertion mode switches can not be used when not in insertion mode");
|
||||
builtin_print_help(parser, streams, argv[0], streams.err);
|
||||
builtin_print_help(parser, streams, cmd, streams.err);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
|
@ -399,8 +399,8 @@ int builtin_commandline(parser_t &parser, io_streams_t &streams, wchar_t **argv)
|
|||
if (argc - w.woptind) {
|
||||
long new_pos = fish_wcstol(argv[w.woptind]);
|
||||
if (errno) {
|
||||
streams.err.append_format(BUILTIN_ERR_NOT_NUMBER, argv[0], argv[w.woptind]);
|
||||
builtin_print_help(parser, streams, argv[0], streams.err);
|
||||
streams.err.append_format(BUILTIN_ERR_NOT_NUMBER, cmd, argv[w.woptind]);
|
||||
builtin_print_help(parser, streams, cmd, streams.err);
|
||||
}
|
||||
|
||||
current_buffer = reader_get_buffer();
|
||||
|
|
|
@ -63,7 +63,7 @@ int builtin_contains(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
|
||||
if (opts.print_help) {
|
||||
builtin_print_help(parser, streams, cmd, streams.out);
|
||||
return STATUS_INVALID_ARGS;
|
||||
return STATUS_CMD_OK;
|
||||
}
|
||||
|
||||
wchar_t *needle = argv[optind];
|
||||
|
|
|
@ -31,7 +31,7 @@ static int parse_cmd_opts(struct cmd_opts *opts, int *optind, //!OCLINT(high nc
|
|||
return STATUS_CMD_OK;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, argv[0], argv[w.woptind - 1]);
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
@ -57,11 +57,11 @@ int builtin_emit(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
|
||||
if (opts.print_help) {
|
||||
builtin_print_help(parser, streams, cmd, streams.out);
|
||||
return STATUS_INVALID_ARGS;
|
||||
return STATUS_CMD_OK;
|
||||
}
|
||||
|
||||
if (!argv[optind]) {
|
||||
streams.err.append_format(L"%ls: expected event name\n", argv[0]);
|
||||
streams.err.append_format(L"%ls: expected event name\n", cmd);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <wchar.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <random>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "builtin.h"
|
||||
#include "builtin_function.h"
|
||||
|
@ -19,6 +19,8 @@
|
|||
#include "io.h"
|
||||
#include "parser.h"
|
||||
#include "parser_keywords.h"
|
||||
#include "proc.h"
|
||||
#include "signal.h"
|
||||
#include "wgetopt.h"
|
||||
#include "wutil.h" // IWYU pragma: keep
|
||||
|
||||
|
|
|
@ -109,6 +109,7 @@ static void builtin_jobs_print(const job_t *j, int mode, int header, io_streams_
|
|||
|
||||
/// The jobs builtin. Used fopr printing running jobs. Defined in builtin_jobs.c.
|
||||
int builtin_jobs(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
||||
wchar_t *cmd = argv[0];
|
||||
int argc = builtin_count_args(argv);
|
||||
int found = 0;
|
||||
int mode = JOBS_DEFAULT;
|
||||
|
@ -141,11 +142,11 @@ int builtin_jobs(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
break;
|
||||
}
|
||||
case 'h': {
|
||||
builtin_print_help(parser, streams, argv[0], streams.out);
|
||||
builtin_print_help(parser, streams, cmd, streams.out);
|
||||
return STATUS_CMD_OK;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, argv[0], argv[w.woptind - 1]);
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
@ -173,7 +174,7 @@ int builtin_jobs(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
for (i = w.woptind; i < argc; i++) {
|
||||
int pid = fish_wcstoi(argv[i]);
|
||||
if (errno || pid < 0) {
|
||||
streams.err.append_format(_(L"%ls: '%ls' is not a job\n"), argv[0], argv[i]);
|
||||
streams.err.append_format(_(L"%ls: '%ls' is not a job\n"), cmd, argv[i]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
|
@ -183,7 +184,7 @@ int builtin_jobs(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
builtin_jobs_print(j, mode, false, streams);
|
||||
found = 1;
|
||||
} else {
|
||||
streams.err.append_format(_(L"%ls: No suitable job: %d\n"), argv[0], pid);
|
||||
streams.err.append_format(_(L"%ls: No suitable job: %d\n"), cmd, pid);
|
||||
return STATUS_CMD_ERROR;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ static int parse_cmd_opts(struct cmd_opts *opts, int *optind, //!OCLINT(high nc
|
|||
return STATUS_CMD_OK;
|
||||
}
|
||||
case '?': {
|
||||
builtin_unknown_option(parser, streams, argv[0], argv[w.woptind - 1]);
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
|
|
@ -153,7 +153,7 @@ static int parse_cmd_opts(struct cmd_opts *opts, int *optind, //!OCLINT(high nc
|
|||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
case L'?': {
|
||||
builtin_unknown_option(parser, streams, argv[0], argv[w.woptind - 1]);
|
||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
default: {
|
||||
|
|
|
@ -65,7 +65,7 @@ int builtin_source(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
|
||||
if (opts.print_help) {
|
||||
builtin_print_help(parser, streams, cmd, streams.out);
|
||||
return STATUS_INVALID_ARGS;
|
||||
return STATUS_CMD_OK;
|
||||
}
|
||||
|
||||
int fd;
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include "builtin_bind.h"
|
||||
#include "common.h"
|
||||
#include "env.h"
|
||||
|
||||
#define FISH_BIND_MODE_VAR L"fish_bind_mode"
|
||||
|
||||
|
|
Loading…
Reference in a new issue