Bug 129388 - tail ignores options when -n or +n is specified, head demands a certain parameter order
Summary: tail ignores options when -n or +n is specified, head demands a certain param...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: coreutils
Version: 3.0
Hardware: i386
OS: Linux
medium
high
Target Milestone: ---
Assignee: Tim Waugh
QA Contact:
URL:
Whiteboard:
: 134139 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-08-07 15:03 UTC by Paul Moore
Modified: 2007-11-30 22:07 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-08-10 12:09:56 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

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


Note You need to log in before you can comment on or make changes to this bug.