diff options
author | Bernhard Voelker <mail@bernhard-voelker.de> | 2016-04-14 12:38:09 +0200 |
---|---|---|
committer | Bernhard Voelker <mail@bernhard-voelker.de> | 2016-04-14 12:38:09 +0200 |
commit | 81e589021d9c47e4fbc4284e82881a9703246476 (patch) | |
tree | 2258556550b9c8155e54cfcf3e50bc2745a52574 /src | |
parent | 8faf269250e8eff5f5dd164dfa1d661c34f52ade (diff) | |
download | coreutils-81e589021d9c47e4fbc4284e82881a9703246476.tar.xz |
seq: do not allow 0 as increment value
* src/seq.c (main): Exit with an error diagnostic when the given
step value is Zero.
(usage): Document it.
* doc/coreutils.texi (seq invocation): Likewise.
* tests/misc/seq.pl: Add tests.
* NEWS (Changes in behavior): Mention the change.
Reported by Маренков Евгений in:
http://bugs.gnu.org/23110
Diffstat (limited to 'src')
-rw-r--r-- | src/seq.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -92,6 +92,7 @@ INCREMENT would become greater than LAST.\n\ 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\ @@ -635,6 +636,13 @@ main (int argc, char **argv) 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++]); } } |