Skip to content

tail: obsolete syntax rejects -cf and accepts more than one f #15517

Open

Description

@emirmrkaljevic

tail's obsolete f suffix is handled differently from GNU in two ways:

  1. tail -cf FILE (last 10 bytes, then follow) is rejected. clap reads it as -c f, the count f fails to parse, and that error is returned before the obsolete-syntax parser is tried.
  2. More than one f is accepted (-5ff, -cff, +cff), while GNU accepts only one.
$ printf 'abcdefghijklmnop\n' > t.txt

$ tail -cf t.txt                  # GNU coreutils 9.12
hijklmnop
(keeps following)
$ ./target/debug/tail -cf t.txt   # uutils main (bf9513b16)
tail: invalid number of bytes: 'f'
$ echo $?
1

$ tail -5ff t.txt                 # GNU coreutils 9.12
tail: option used in invalid context -- 5
$ echo $?
1
$ ./target/debug/tail -5ff t.txt  # uutils main
abcdefghijklmnop
(keeps following)

The same happens with printf 'abcdefghijklmnop\n' | tail -cf on stdin. tail -c f (separate argument) should still be an invalid count, as in GNU.

Found with behave, which recorded GNU tail's behaviour and replayed it against uutils.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions