The sequence of numbers ends when the sum of the current number and
@var{increment} would become greater than @var{last},
so @code{seq 1 10 10} only produces @samp{1}.
+@var{increment} must not be @samp{0}; use @command{yes} to get
+repeated output of a constant number.
Floating-point numbers may be specified. @xref{Floating point}.
The program accepts the following options. Also see @ref{Common options}.
FIRST, INCREMENT, and LAST are interpreted as floating point values.\n\
INCREMENT is usually positive if FIRST is smaller than LAST, and\n\
INCREMENT is usually negative if FIRST is greater than LAST.\n\
+INCREMENT must not be 0.\n\
"), stdout);
fputs (_("\
FORMAT must be suitable for printing one argument of type 'double';\n\
if (optind < argc)
{
step = last;
+ if (step.value == 0)
+ {
+ error (0, 0, _("invalid Zero increment value: %s"),
+ quote (argv[optind-1]));
+ usage (EXIT_FAILURE);
+ }
+
last = scan_arg (argv[optind++]);
}
}
my $prog = 'seq';
my $try_help = "Try '$prog --help' for more information.\n";
+my $err_inc_zero = "seq: invalid Zero increment value: '0'\n".$try_help;
my $locale = $ENV{LOCALE_FR_UTF8};
! defined $locale || $locale eq 'none'
['fast-1', qw(4), {OUT => [qw(1 2 3 4)]}],
['fast-2', qw(1 4), {OUT => [qw(1 2 3 4)]}],
['fast-3', qw(1 1 4), {OUT => [qw(1 2 3 4)]}],
+
+ # Ensure an INCREMENT of Zero is rejected.
+ ['inc-zero-1', qw(1 0 10), {EXIT => 1}, {ERR => $err_inc_zero}],
+ ['inc-zero-2', qw(0 -0 0), {EXIT => 1}, {ERR => $err_inc_zero},
+ {ERR_SUBST => 's/-0/0/'}],
+ ['inc-zero-3', qw(1 0.0 10), {EXIT => 1},{ERR => $err_inc_zero},
+ {ERR_SUBST => 's/0.0/0/'}],
+ ['inc-zero-4', qw(1 -0.0e-10 10), {EXIT => 1},{ERR => $err_inc_zero},
+ {ERR_SUBST => 's/-0\.0e-10/0/'}],
);
# Append a newline to each entry in the OUT array.