Bug 129388

Summary: tail ignores options when -n or +n is specified, head demands a certain parameter order
Product: Red Hat Enterprise Linux 3 Reporter: Paul Moore <pmoore>
Component: coreutilsAssignee: Tim Waugh <twaugh>
Status: CLOSED NOTABUG QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: 3.0CC: pmoore, redhat-bugzilla, ronrotach
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-08-10 12:09:56 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Paul Moore 2004-08-07 15:03:34 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.2)
Gecko/20040301

Description of problem:
If tail is given a +n or -n (where n is a number), the other valid
options like -q, --quiet, -v, --verbose, do not work.

Tail appears to accept only one parameter is +n or -n is specified,
which makes it impossible for shell scripts to tail numerous files
without pretty details about the file the data came from.

Version-Release number of selected component (if applicable):
coreutils-4.5.3-26

How reproducible:
Always

Steps to Reproduce:
1. echo -e 'a\nb\nc' > /tmp/a ; echo -e 'd\ne\nf' > /tmp/b
2. tail -2 /tmp/a /tmp/b # WORKS
3. tail -2 -q /tmp/a /tmp/b # FAILS
    

Actual Results:  tail: -q: No such file or directory

Expected Results:  b
c
 
e
f


Additional info:

Also occurs when specifying the +n option.
Also occurs when using --quiet instead of -q
Also occurs when using -v and --verbose
Also occurs when changing order of [+-]n and -option.

Comment 1 Paul Moore 2004-08-07 15:14:39 UTC
head seems to have a similar problem:
head -2 -q /tmp/a /tmp/b
a
b
d
e
head -q -2 /tmp/a /tmp/b
head: invalid option -- 2
Try `head --help' for more information.

Options should be accepted in either order.

Severity changed to high because this has the potential to break
numerous shell scripts.

Comment 2 Tim Waugh 2004-08-10 12:09:56 UTC
The shell scripts should use "-n 2" instead of "-2".  This (POSIX) way
of specifying the option will work in both older and newer versions of
head/tail.

The documentation ('info coreutils head') documents the restriction
you note on option ordering:

   On older systems, `head' supports an obsolete option
 `-COUNTOPTIONS', which is recognized only if it is specified first.
 COUNT is a decimal number optionally followed by a size letter (`b',
 `k', `m') as in `-c', or `l' to mean count by lines, or other option
 letters (`cqv').  POSIX 1003.1-2001 (*note Standards conformance::)
 does not allow this; use `-c COUNT' or `-n COUNT' instead.

Comment 3 Tim Waugh 2004-09-30 08:33:52 UTC
*** Bug 134139 has been marked as a duplicate of this bug. ***