** New features
- cut, head, tail now have -z, --zero-terminated options to work with
- NUL delimited items.
+ cut, head, tail now have the -z,--zero-terminated option, and
+ tac --separator accepts an empty argument, to work with NUL delimited items.
dd now summarizes sizes in --human-readable format too, not just --si.
E.g., "3441325000 bytes (3.4 GB, 3.2 GiB) copied". It omits the summaries
@opindex -s
@opindex --separator
Use @var{separator} as the record separator, instead of newline.
+Note an empty @var{separator} is treated as a zero byte.
+I.e., input and output items are delimited with ASCII NUL.
@end table
break;
case 's':
separator = optarg;
- if (*separator == 0)
- error (EXIT_FAILURE, 0, _("separator cannot be empty"));
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
if (sentinel_length == 0)
{
+ if (*separator == 0)
+ error (EXIT_FAILURE, 0, _("separator cannot be empty"));
+
compiled_separator.buffer = NULL;
compiled_separator.allocated = 0;
compiled_separator.fastmap = compiled_separator_fastmap;
error (EXIT_FAILURE, 0, "%s", (error_message));
}
else
- match_length = sentinel_length = strlen (separator);
+ match_length = sentinel_length = *separator ? strlen (separator) : 1;
read_size = INITIAL_READSIZE;
while (sentinel_length >= read_size / 2)
['basic-j', '', {IN=>"1234\n8\n"}, {OUT=>"8\n1234\n"}],
['basic-k', '', {IN=>"123\n8\n"}, {OUT=>"8\n123\n"}],
+ ['nul-0', '-s ""', {IN=>""}, {OUT=>""}],
+ ['nul-a', '-s ""', {IN=>"a"}, {OUT=>"a"}],
+ ['nul-b', '-s ""', {IN=>"\0"}, {OUT=>"\0"}],
+ ['nul-c', '-s ""', {IN=>"a\0"}, {OUT=>"a\0"}],
+ ['nul-d', '-s ""', {IN=>"a\0b"}, {OUT=>"ba\0"}],
+ ['nul-e', '-s ""', {IN=>"a\0b\0"}, {OUT=>"b\0a\0"}],
+
['opt-b', '-b', {IN=>"\na\nb\nc"}, {OUT=>"\nc\nb\na"}],
['opt-s', '-s:', {IN=>"a:b:c:"}, {OUT=>"c:b:a:"}],
['opt-sb', qw(-s : -b), {IN=>":a:b:c"}, {OUT=>":c:b:a"}],