1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

seq: improve error handling for invalid -f values

Improve the error message produced by `seq` when given invalid format
specifiers for the `-f` option. Before this commit:

    $ seq -f "%" 1
    seq: %: invalid conversion specification
    $ seq -f "%g%" 1
    seq: %: invalid conversion specification

After this commit:

    $ seq -f "%" 1
    seq: format '%' ends in %
    $ seq -f "%g%" 1
    seq: format '%g%' has too many % directives

This matches the behavior of GNU `seq`.
This commit is contained in:
Jeffrey Finkelstein 2024-12-30 12:23:36 -05:00
parent 00d1866060
commit cccab35337
2 changed files with 25 additions and 4 deletions

View file

@ -787,6 +787,16 @@ fn test_invalid_format() {
.fails()
.no_stdout()
.stderr_contains("format '%g%g' has too many % directives");
new_ucmd!()
.args(&["-f", "%g%", "1"])
.fails()
.no_stdout()
.stderr_contains("format '%g%' has too many % directives");
new_ucmd!()
.args(&["-f", "%", "1"])
.fails()
.no_stdout()
.stderr_contains("format '%' ends in %");
}
#[test]