Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uu-tail -<number> does not work #2507

Open
sedrubal opened this issue Jul 20, 2021 · 3 comments
Open

uu-tail -<number> does not work #2507

sedrubal opened this issue Jul 20, 2021 · 3 comments

Comments

@sedrubal
Copy link

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).

@tertsdiepraam
Copy link
Member

Indeed! Thanks! I've made a PR to address this.

@cbjadwani
Copy link
Contributor

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.

@stale
Copy link

stale bot commented Jan 20, 2023

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.

@stale stale bot added the wontfix label Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants