Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: POSIX conformance in coreutils
- X-seq: zsh-workers 20691
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: POSIX conformance in coreutils
- Date: Wed, 12 Jan 2005 09:18:00 +0000
- In-reply-to: <m3r7kr31g9.fsf@xxxxxxxxxxxx>
- Mail-followup-to: zsh-workers@xxxxxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <m3r7kr31g9.fsf@xxxxxxxxxxxx>
On Tue, Jan 11, 2005 at 08:01:26PM -0500, Vin Shelton wrote:
> GNU coreutils (at least versions 5.2.1 and 5.3.0) enforce POSIX
> conformance, so they don't like 'tail -1', instead they require
> 'tail -n 1'.
>
> This causes problems in E01options.tst:
>
> # Count the number of directories on the stack. Don't care what they are.
> dircount() { dirs -v | tail -1 | awk '{ print $1 + 1}'; }
>
> tail: `-1' option is obsolete; use `-n 1'
> Try `tail --help' for more information.
[...]
YMMV.
~$ tail --version
tail (coreutils) 5.2.1
[...]
~$ tail -1 /dev/null
~$
tail -n 1, even if POSIX, is not portable. I think I've come
across a system where it was not supported recently (maybe
Solaris).
> dircount() { dirs -v | tail -1 | awk '{ print $1 + 1}'; }
Maybe:
dircount() { print $((${${(z)${(f)"$(dirs -v)"}[-1]}[1]} + 1)); }
Or:
dircount() { dirs -v | awk '{n=$1}END{print n+1}'; }
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author