From c729a97c431d9e3d95703568f50fc3019d0b7752 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Tue, 20 Nov 2018 16:56:15 +0100 Subject: [PATCH] builtin_read: Remove --all-lines This was unused and needed to be warned about in the docs. Remove it so nobody stumbles over it. Fixes #5332. --- doc_src/read.txt | 2 -- src/builtin_read.cpp | 25 ++----------------------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/doc_src/read.txt b/doc_src/read.txt index 8cc848eab..c898cca59 100644 --- a/doc_src/read.txt +++ b/doc_src/read.txt @@ -45,8 +45,6 @@ The following options are available: - `-L` or `--line` reads each line into successive variables, and stops after each variable has been filled. This cannot be combined with the `--delimiter` option. -- `-A` or `--all-lines` splits input into the given variables, separated by line breaks. The entire input stream is consumed and interactive mode is disabled. Probably only useful with `-a` to read all lines into a single array variable. Where possible, ` | while read --line` should be preferred over ` | read --all-lines` as the latter will block until the input stream has been consumed, leading to latency and decreased responsiveness. - Without the `--line` option, `read` reads a single line of input from standard input, breaks it into tokens, and then assigns one token to each variable specified in `VARIABLES`. If there are more tokens than variables, the complete remainder is assigned to the last variable. If the `--delimiter` argument is not given, the variable `IFS` is used as a list of characters to split on. Relying on the use of `IFS` is deprecated and this behaviour will be removed in future versions. The default value of `IFS` contains space, tab and newline characters. As a special case, if `IFS` is set to the empty string, each character of the input is considered a separate token. diff --git a/src/builtin_read.cpp b/src/builtin_read.cpp index a6e283cee..0ce1e3be0 100644 --- a/src/builtin_read.cpp +++ b/src/builtin_read.cpp @@ -50,14 +50,12 @@ struct read_cmd_opts_t { bool split_null = false; bool to_stdout = false; int nchars = 0; - bool all_lines = false; bool one_line = false; }; -static const wchar_t *const short_options = L":Aac:d:ghiLlm:n:p:suxzP:UR:LB"; +static const wchar_t *const short_options = L":ac:d:ghiLlm:n:p:suxzP:UR:LB"; static const struct woption long_options[] = { {L"array", no_argument, NULL, 'a'}, - {L"all-lines", no_argument, NULL, 'A'}, {L"command", required_argument, NULL, 'c'}, {L"delimiter", required_argument, NULL, 'd'}, {L"export", no_argument, NULL, 'x'}, @@ -89,10 +87,6 @@ static int parse_cmd_opts(read_cmd_opts_t &opts, int *optind, //!OCLINT(high nc opts.array = true; break; } - case L'A': { - opts.all_lines = true; - break; - } case L'c': { opts.commandline = w.woptarg; break; @@ -361,18 +355,10 @@ static int validate_read_args(const wchar_t *cmd, read_cmd_opts_t &opts, int arg return STATUS_INVALID_ARGS; } - if (opts.have_delimiter && opts.all_lines) { - streams.err.append_format(_(L"%ls: Options %ls and %ls cannot be used together\n"), cmd, L"--delimiter", L"--all-lines"); - return STATUS_INVALID_ARGS; - } if (opts.have_delimiter && opts.one_line) { streams.err.append_format(_(L"%ls: Options %ls and %ls cannot be used together\n"), cmd, L"--delimiter", L"--line"); return STATUS_INVALID_ARGS; } - if (opts.one_line && opts.all_lines) { - streams.err.append_format(_(L"%ls: Options %ls and %ls cannot be used together\n"), cmd, L"--all-lines", L"--line"); - return STATUS_INVALID_ARGS; - } if (opts.one_line && opts.split_null) { streams.err.append_format(_(L"%ls: Options %ls and %ls cannot be used together\n"), cmd, L"-z", L"--line"); return STATUS_INVALID_ARGS; @@ -454,14 +440,7 @@ int builtin_read(parser_t &parser, io_streams_t &streams, wchar_t **argv) { retval = validate_read_args(cmd, opts, argc, argv, parser, streams); if (retval != STATUS_CMD_OK) return retval; - if (opts.all_lines) { - // --all-lines is the same as read -d \n -z - opts.have_delimiter = true; - opts.delimiter = L"\n"; - opts.split_null = true; - opts.shell = false; - } - else if (opts.one_line) { + if (opts.one_line) { // --line is the same as read -d \n repeated N times opts.have_delimiter = true; opts.delimiter = L"\n";