zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Subject: Re: POSIX conformance in coreutils
Date: Wed, 12 Jan 2005 15:58:41 +0000	[thread overview]
Message-ID: <200501121558.j0CFwgeq026991@news01.csr.com> (raw)
In-Reply-To: <m33bx6wwzx.fsf@zion.rcn.com>

Vin Shelton wrote:
> I checked and I do not have POSIXLY_CORRECT set.  Here's what the
> 'Standards conformance' section of the coreutils info says:

It doesn't look like we can expect much sense, then.

Here is a more heavyweight change.

Index: Test/ztst.zsh
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/ztst.zsh,v
retrieving revision 1.20
diff -u -r1.20 ztst.zsh
--- Test/ztst.zsh	12 Jan 2005 10:32:20 -0000	1.20
+++ Test/ztst.zsh	12 Jan 2005 15:56:50 -0000
@@ -28,9 +28,6 @@
 [[ -n $LC_COLLATE ]] && LC_COLLATE=C
 [[ -n $LANG ]] && LANG=C
 
-# POSIXLY_CORRECT can cause spurious error messages with "tail -<num>".
-unset POSIXLY_CORRECT
-
 # Set the module load path to correspond to this build of zsh.
 # This Modules directory should have been created by "make check".
 [[ -d Modules/zsh ]] && module_path=( $PWD/Modules )
@@ -60,6 +57,33 @@
 
 integer ZTST_testfailed
 
+# This is POSIX nonsense.  Because of the vague feeling someone, somewhere
+# may one day need to examine the arguments of "tail" using a standard
+# option parser, every Unix user in the world is expected to switch
+# to using "tail -n NUM" instead of "tail -NUM".  Older versions of
+# tail don't support this.
+tail() {
+  emulate -L zsh
+
+  if [[ -z $TAIL_SUPPORTS_MINUS_N ]]; then
+    local test
+    test=$(echo "foo\nbar" | command tail -n 1 2>/dev/null)
+    if [[ $test = bar ]]; then
+      TAIL_SUPPORTS_MINUS_N=1
+    else
+      TAIL_SUPPORTS_MINUS_N=0
+    fi
+  fi
+
+  integer argi=${argv[(i)-<->]}
+
+  if [[ $argi -le $# && $TAIL_SUPPORTS_MINUS_N = 1 ]]; then
+    argv[$argi]=(-n ${argv[$argi][2,-1]})
+  fi
+
+  command tail "$argv[@]"
+}
+
 # The source directory is not necessarily the current directory,
 # but if $0 doesn't contain a `/' assume it is.
 if [[ $0 = */* ]]; then


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


  reply	other threads:[~2005-01-12 16:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-12  1:01 Vin Shelton
2005-01-12  9:18 ` Stephane Chazelas
2005-01-12 16:12   ` POSIX conformance in Solaris Danek Duvall
2005-01-12 10:27 ` POSIX conformance in coreutils Peter Stephenson
2005-01-12 10:42   ` Stephane Chazelas
2005-01-12 14:19   ` Vin Shelton
2005-01-12 15:58     ` Peter Stephenson [this message]
2005-02-23 16:36       ` Oliver Kiddle
     [not found]         ` <okiddle@yahoo.co.uk>
2005-02-23 18:24           ` Peter Stephenson
2005-01-12 16:18     ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200501121558.j0CFwgeq026991@news01.csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).