coreutils
coreutils copied to clipboard
uu-tail -<number> does not work
While tail -1 (which is equal to tail -n-1) works, uu-tail -1 (show the last line of input) does not work (but uu-tail -n-1 works).
Indeed! Thanks! I've made a PR to address this.
The fix in #2747 implements this obsolete usage partially but it differs from GNU coreutils. The parsing of suffixes is different, for example:
$ ./target/release/tail -3f README.md
./target/release/tail: bad argument format: '-10f'
$ /usr/bin/tail -3f README.md
uutils is licensed under the MIT License - see the `LICENSE` file for details
GNU Coreutils is licensed under the GPL 3.0 or later.
^C
Quoting the relevant part from GNU tail docs:
For compatibility tail also supports an obsolete usage ‘tail -[num][bcl][f] [file]’, which is recognized only if it does not conflict with the usage described above. This obsolete form uses exactly one option and at most one file. In the option, num is an optional decimal number optionally followed by a size letter (‘b’, ‘c’, ‘l’) to mean count by 512-byte blocks, bytes, or lines, optionally followed by ‘f’ which has the same meaning as -f.
The + prefix usage eg. tail +10 is not implemented currently in uutils.
Also, GNU docs advises against using obsolete syntax if standard syntax is supported.
Scripts intended for use on standard hosts should avoid traditional syntax and should use -c num[b], -n num, and/or -f instead. If your script must also run on hosts that support only the traditional syntax, you can often rewrite it to avoid problematic usages, e.g., by using ‘sed -n '$p'’ rather than ‘tail -1’. If that’s not possible, the script can use a test like ‘if tail -c +1 </dev/null >/dev/null 2>&1; then …’ to decide which syntax to use.
Supporting this syntax in uutils needs non-trivial workarounds since clap does not support it. Probably would be better to not support this syntax in uutils.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.