Signed-off-by: Bartosz Golaszewski <[email protected]>
---
 coreutils/shuf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/coreutils/shuf.c b/coreutils/shuf.c
index f213d67..eff0d36 100644
--- a/coreutils/shuf.c
+++ b/coreutils/shuf.c
@@ -126,7 +126,9 @@ int shuf_main(int argc, char **argv)
                fclose_if_not_stdin(fp);
        }
 
-       shuffle_lines(lines, numlines);
+       /* Skip shuffle_lines() for one or zero lines. */
+       if (numlines > 1)
+               shuffle_lines(lines, numlines);
 
        if (opts & OPT_o)
                xmove_fd(xopen(opt_o_str, O_WRONLY|O_CREAT|O_TRUNC), 
STDOUT_FILENO);
-- 
1.8.4.5

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to