Skip site navigation (1) Skip section navigation (2)

Re: support for POSIX 1003.1-2001 hosts

From: Paul Eggert <eggert(at)twinsun(dot)com>
To: pgman(at)candle(dot)pha(dot)pa(dot)us
Cc: sauron(at)the-infinite(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: support for POSIX 1003.1-2001 hosts
Date: 2002-03-12 00:22:39
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-patches
> From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
> Date: Mon, 11 Mar 2002 19:04:24 -0500 (EST)
> The patch basically takes:
> 	sort +1 -0 and changes it to 
> and makes it:
> 	sort +1 -0 || sort -k 1,0
> or something like that.

Here is a bit more detail about what the patch does.

* It transforms `head -1 FOO' to `sed q FOO'.
  This is portable to all hosts that I know of.
  As it happens, `head -1' didn't work in Unix Version 7, but `sed q' did,
  so this transformation improves portability to some ancient hosts too.

* It transforms `sort +0n -1' to `(sort -k 1,1n 2>/dev/null || sort +0n -1)',
  and similarly for all other uses of `sort +FOO'.  The basic idea is
  to try POSIX standard syntax (standard since the first version of POSIX,
  anyway, more than a dozen years ago), and to fall back on the traditional
  Unix Version 7 syntax if the POSIX standard syntax is not supported.

The former transformation is perfectly safe.  The latter
transformation is a bit tricky, since the first `sort' can fail for
reasons other than "I don't know what -k is", and in that case the
second `sort' will be invoked even though it should not be.  I don't
think this will be a real problem in practice, but if you're worried
about it I could change the second transform to look like this:

  if sort -k 1,1n /dev/null >/dev/null 2>&1
  then sort -k 1,1n
  else sort +0n -1

I can submit a revised patch along those lines if you like.

In response to

pgsql-patches by date

Next:From: Tom LaneDate: 2002-03-12 01:15:46
Subject: Re: Adds the parsing of a CREATE SCHEMA statement
Previous:From: Peter EisentrautDate: 2002-03-12 00:22:01
Subject: Re: support for POSIX 1003.1-2001 hosts

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group