bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8231: Bug in the linux command: tail


From: Eric Blake
Subject: bug#8231: Bug in the linux command: tail
Date: Fri, 11 Mar 2011 11:06:21 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7

On 03/11/2011 10:03 AM, Roger N. Clark wrote:
> Tail with a line count option with multiple files fails.
> 
> For example:
> 
> tail -3 foo.txt
> f
> d
> s
> 
> works, but
> 
> tail -3 foo.txt  csh.cshrc
> tail: option used in invalid context -- 3

Thanks for the report.  At first, I was about to claim that this is not
a bug in GNU coreutils, but a difference in levels of POSIX compliance.

But digging further shows this in the NEWS file:  Back in coreutils 5.90:

** Bring back support for `head -NUM', `tail -NUM', etc. even when
  conforming to POSIX 1003.1-2001.  The following changes apply only
  when conforming to POSIX 1003.1-2001; there is no effect when
  conforming to older POSIX versions.
    tail -[NUM][bcl][f] [FILE]

Basically, POSIX 2001 and newer does _not_ require -3 to be parsed as a
valid option (rather, the POSIX spelling is -n -3), so GNU coreutils is
supporting -3 as an extension.

Then I looked at the actual POSIX 2008 wording:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/tail.html

    tail [-f] [-c number|-n number] [file]

That is, POSIX states that it is only portable to supply at most one
filename, so the fact that GNU tail can support multiple files is
already an extension, whether or not you also mix in the GNU extension
of supporting -3 as an option.

You can work around it by using: 'tail -n -3 file1 file2'

>
> This works on HP-UX.

Since we're already dealing with two GNU extensions, I don't see why we
can't be nice and make the shorter syntax work the way HP-UX is doing
things.  Patches welcome!

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]