Skip to content

Commit 02a1d31

Browse files
committed
shuf-2.2
Fix compatability with GNU shuf: don't print extra newline if input file is of length 0. Start buffer at 8K instead of 1K.
1 parent 791a243 commit 02a1d31

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

shuf.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static void
196196
version(void)
197197
{
198198

199-
fputs("shuf 2.1\n"
199+
fputs("shuf 2.2\n"
200200
"Copyright (c) 2017-2019 Brian Callahan <[email protected]>\n"
201201
"\nPermission to use, copy, modify, and distribute this software"
202202
" for any\npurpose with or without fee is hereby granted, "
@@ -222,7 +222,7 @@ main(int argc, char *argv[])
222222
char *argp, *buf, *nbuf;
223223
int argn = 1, ch, hi = 0, lo = 0, prev = 1;
224224
int eflag = 0, iflag = 0, oflag = 0;
225-
size_t buflen = 0, bufsize = 1024, nbufsize;
225+
size_t buflen = 0, bufsize = 8192, nbufsize;
226226

227227
#ifdef HAVE_PLEDGE
228228
if (pledge("stdio rpath wpath cpath", NULL) == -1)
@@ -345,7 +345,8 @@ main(int argc, char *argv[])
345345
if (ifile != stdin)
346346
fclose(ifile);
347347

348-
shuffile(buf, argn, buflen);
348+
if (buflen > 0)
349+
shuffile(buf, argn, buflen);
349350

350351
free(buf);
351352
buf = NULL;

0 commit comments

Comments
 (0)