summaryrefslogtreecommitdiff
path: root/src/shuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shuf.c')
-rw-r--r--src/shuf.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/shuf.c b/src/shuf.c
index d4641fe19..2a910728e 100644
--- a/src/shuf.c
+++ b/src/shuf.c
@@ -576,11 +576,18 @@ main (int argc, char **argv)
/* Generate output according to requested method */
if (repeat)
{
- if (input_range)
- i = write_random_numbers (randint_source, head_lines,
- lo_input, hi_input, eolbyte);
+ if (head_lines == 0)
+ i = 0;
else
- i = write_random_lines (randint_source, head_lines, line, n_lines);
+ {
+ if (n_lines == 0)
+ error (EXIT_FAILURE, 0, _("No lines to repeat"));
+ if (input_range)
+ i = write_random_numbers (randint_source, head_lines,
+ lo_input, hi_input, eolbyte);
+ else
+ i = write_random_lines (randint_source, head_lines, line, n_lines);
+ }
}
else
{