mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
cut: support -O as an alias for --output-delimiter
To improve compatibility with toybox/busybox scripts. * doc/coreutils.texi (cut invocation): Add -O description. * src/cut.c: Support -O as well as --output-delimiter * tests/cut/cut.pl: Adjust one case to use -O.
This commit is contained in:
1 parent
0ae17ffd99
commit
77ccacb9a7
3 files changed
+12
-13
No files matched your search
+2
-1
@@ -6224,7 +6224,8 @@ for it to be selected.
|
||||
For @option{-f}, do not print lines that do not contain the field separator
|
||||
character. Normally, any line without a field separator is printed verbatim.
|
||||
|
||||
@optItem{cut,--output-delimiter,=@var{string}}
|
||||
@optItem{cut,-O,@w{ }@var{string}}
|
||||
@optItemx{cut,--output-delimiter,=@var{string}}
|
||||
With @option{-f}, output fields are separated by @var{string}.
|
||||
The default with @option{-f} is to use the input delimiter.
|
||||
When using @option{-b} or @option{-c} to select ranges of byte or
|
||||
|
||||
@@ -128,8 +128,7 @@ static enum
|
||||
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
|
||||
enum
|
||||
{
|
||||
OUTPUT_DELIMITER_OPTION = CHAR_MAX + 1,
|
||||
COMPLEMENT_OPTION
|
||||
COMPLEMENT_OPTION = CHAR_MAX + 1
|
||||
};
|
||||
|
||||
static struct option const longopts[] =
|
||||
@@ -141,7 +140,7 @@ static struct option const longopts[] =
|
||||
{"no-partial", no_argument, NULL, 'n'},
|
||||
{"whitespace-delimited", no_argument, NULL, 'w'},
|
||||
{"only-delimited", no_argument, NULL, 's'},
|
||||
{"output-delimiter", required_argument, NULL, OUTPUT_DELIMITER_OPTION},
|
||||
{"output-delimiter", required_argument, NULL, 'O'},
|
||||
{"complement", no_argument, NULL, COMPLEMENT_OPTION},
|
||||
{"zero-terminated", no_argument, NULL, 'z'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
@@ -193,13 +192,13 @@ Print selected parts of lines from each FILE to standard output.\n\
|
||||
with -b, don't output partial multi-byte characters\n\
|
||||
"));
|
||||
oputs (_("\
|
||||
-s, --only-delimited\n\
|
||||
do not print lines not containing delimiters\n\
|
||||
"));
|
||||
oputs (_("\
|
||||
--output-delimiter=STRING\n\
|
||||
-O, --output-delimiter=STRING\n\
|
||||
use STRING as the output delimiter;\n\
|
||||
the default is to use the input delimiter\n\
|
||||
"));
|
||||
oputs (_("\
|
||||
-s, --only-delimited\n\
|
||||
do not print lines not containing delimiters\n\
|
||||
"));
|
||||
oputs (_("\
|
||||
-w, --whitespace-delimited\n\
|
||||
@@ -896,7 +895,7 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "b:c:d:f:nszw", longopts, NULL))
|
||||
while ((optc = getopt_long (argc, argv, "b:c:d:f:nO:szw", longopts, NULL))
|
||||
!= -1)
|
||||
{
|
||||
switch (optc)
|
||||
@@ -951,7 +950,7 @@ main (int argc, char **argv)
|
||||
whitespace_delimited = true;
|
||||
break;
|
||||
|
||||
case OUTPUT_DELIMITER_OPTION:
|
||||
case 'O':
|
||||
/* Interpret --output-delimiter='' to mean
|
||||
'use the NUL byte as the delimiter.' */
|
||||
output_delimiter_length = (optarg[0] == '\0'
|
||||
|
||||
+1
-2
@@ -123,8 +123,7 @@ my @Tests =
|
||||
['o-delim', qw(-d: --out=_), '-f2,3', {IN=>"a:b:c\n"}, {OUT=>"b_c\n"}],
|
||||
['nul-idelim', qw(-d '' --out=_), '-f2,3', {IN=>"a\0b\0c\n"}, {OUT=>"b_c\n"}],
|
||||
['nul-odelim', qw(-d: --out=), '-f2,3', {IN=>"a:b:c\n"}, {OUT=>"b\0c\n"}],
|
||||
['multichar-od', qw(-d: --out=_._), '-f2,3', {IN=>"a:b:c\n"},
|
||||
{OUT=>"b_._c\n"}],
|
||||
['multichar-od', qw(-d: -O _._), '-f2,3', {IN=>"a:b:c\n"}, {OUT=>"b_._c\n"}],
|
||||
|
||||
# Ensure delim is not allowed without a field
|
||||
# Prior to 8.21, a NUL delim was allowed without a field
|
||||
|
||||
Reference in new issue
Block a user