From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28748 invoked from network); 12 Jan 2005 09:17:14 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 12 Jan 2005 09:17:14 -0000 Received: (qmail 40197 invoked from network); 12 Jan 2005 09:17:04 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 12 Jan 2005 09:17:04 -0000 Received: (qmail 17554 invoked by alias); 12 Jan 2005 09:16:50 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20691 Received: (qmail 17540 invoked from network); 12 Jan 2005 09:16:48 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 12 Jan 2005 09:16:48 -0000 Received: (qmail 39851 invoked from network); 12 Jan 2005 09:16:48 -0000 Received: from smtp-out3.blueyonder.co.uk (195.188.213.6) by a.mx.sunsite.dk with SMTP; 12 Jan 2005 09:16:45 -0000 Received: from sc ([82.41.210.43]) by smtp-out3.blueyonder.co.uk with Microsoft SMTPSVC(5.0.2195.6713); Wed, 12 Jan 2005 09:17:14 +0000 Date: Wed, 12 Jan 2005 09:18:00 +0000 From: Stephane Chazelas To: zsh-workers@sunsite.dk Subject: Re: POSIX conformance in coreutils Message-ID: <20050112091800.GA4486@sc> Mail-Followup-To: zsh-workers@sunsite.dk References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.6i X-OriginalArrivalTime: 12 Jan 2005 09:17:14.0100 (UTC) FILETIME=[80F48B40:01C4F887] X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: * X-Spam-Status: No, hits=1.5 required=6.0 tests=RCVD_IN_SORBS autolearn=no version=2.63 X-Spam-Hits: 1.5 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