* src/shuf.c (write_permuted_output): Add EOLBYTE parameter and use
it rather than hard-coding "\n".
(main): Adjust sole caller.
* tests/misc/shuf: Add a test to exercise this bug fix.
* NEWS: Mention it.
md5sum now accepts the new option, --quiet, to suppress the printing of
'OK' messages. sha1sum, sha224sum, sha384sum, and sha512sum accept it, too.
md5sum now accepts the new option, --quiet, to suppress the printing of
'OK' messages. sha1sum, sha224sum, sha384sum, and sha512sum accept it, too.
+ shuf honors the --zero-terminated (-z) option, even with --input-range=LO-HI
+
sort accepts a new option, --files0-from=F, that specifies a file
containing a null-separated list of files to sort. This list is used
instead of filenames passed on the command-line to avoid problems with
sort accepts a new option, --files0-from=F, that specifies a file
containing a null-separated list of files to sort. This list is used
instead of filenames passed on the command-line to avoid problems with
static int
write_permuted_output (size_t n_lines, char * const *line, size_t lo_input,
static int
write_permuted_output (size_t n_lines, char * const *line, size_t lo_input,
- size_t const *permutation)
+ size_t const *permutation, char eolbyte)
for (i = 0; i < n_lines; i++)
{
unsigned long int n = lo_input + permutation[i];
for (i = 0; i < n_lines; i++)
{
unsigned long int n = lo_input + permutation[i];
- if (printf ("%lu\n", n) < 0)
+ if (printf ("%lu%c", n, eolbyte) < 0)
if (outfile && ! freopen (outfile, "w", stdout))
error (EXIT_FAILURE, errno, "%s", quotearg_colon (outfile));
if (outfile && ! freopen (outfile, "w", stdout))
error (EXIT_FAILURE, errno, "%s", quotearg_colon (outfile));
- if (write_permuted_output (head_lines, line, lo_input, permutation) != 0)
+ if (write_permuted_output (head_lines, line, lo_input, permutation, eolbyte)
+ != 0)
error (EXIT_FAILURE, errno, _("write error"));
#ifdef lint
error (EXIT_FAILURE, errno, _("write error"));
#ifdef lint
# "seq 1860" produces 8193 (8K + 1) bytes of output.
seq 1860 | shuf > /dev/null || fail=1
# "seq 1860" produces 8193 (8K + 1) bytes of output.
seq 1860 | shuf > /dev/null || fail=1
+# coreutils-6.12 and earlier would output a newline terminator, not \0.
+shuf --zero-terminated -i 1-1 > out || fail=1
+printf '1\0' > exp || framework_failure
+cmp out exp || { fail=1; echo "missing NUL terminator?" 1>&2; }
+