bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: errno --> errno name ?


From: Stefano Lattarini
Subject: Re: errno --> errno name ?
Date: Fri, 5 Aug 2011 15:48:35 +0200
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

Hi Bruce.

On Friday 05 August 2011, Bruce Korb wrote:
> On 08/04/11 17:39, Bruno Haible wrote:
> > Hi Bruce,
> >
> >> I fixed up the "mk" script to be more portable
> >
> > Indeed, that looks like most portability problems have been eliminated.
> >
> >> tho I haven't tried it on Solaris' /bin/sh.
> >> Probably won't work.  I don't have access.
> >
> > You can also test it with 'zsh', 'ksh', 'ash', and 'dash' on a glibc system.
> > If it works with these shells, it will likely also pass with /bin/sh on
> > various systems.
> 
> zsh stumbles on this:
> 
>      egrep -h "$grep_expr" $errno_list | \
>          sed "$sed_cmd" | \
>          awk '{ print $1 " " $2 }' | \
>          sort -u -n -k2 > ${tmpd}/sorted.txt
> 
> so it is not Bourne-enough to count.
>
It's not by default; you just have to tell it explicitly to behave more
bourne-like.  This is how it is done by the autoconf-generated configure
scripts (note that this code will also force bash and some Korn shells
to behave more "posixly"):

  # Be more Bourne compatible
  DUALCASE=1; export DUALCASE # for MKS sh
  if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
    emulate sh
    NULLCMD=:
    # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
    # is contrary to our usage.  Disable this feature.
    alias -g '${1+"$@"}'='"$@"'
    setopt NO_GLOB_SUBST
  else
    case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
  fi

> It tries to run awk with
> the $errno_list argument instead of just passing output through to it.
> Hopeless.
>
Huh?  What it the precise error message?

> ash:
>  > $ ash -x ./mk-err-names.sh
>  > ./mk-err-names.sh: 37: Syntax error: word unexpected (expecting ")")
>
Which version of ash?  It works ok on my Debian box with dash 0.5.5.1 and
dash 0.5.2.

>        1 #! /bin/sh
>        2
>        3 init() {
>        4     tmpd=`mktemp -d ${TMPDIR:-/tmp}/err-names-XXXXXX`
>        5     test -d "${tmpd}" || {
>        6         tmpd=${TMPDIR:-/tmp}/err-names-$$
>        7         rm -rf ${tmpd}
>        8         mkdir ${tmpd}
>        9     }
>       10     tmpf=${tmpd}/temp.c
>       11     trap "rm -rf ${tmpd}" EXIT
>       12     echo '#include <errno.h>' > ${tmpf}
>       13
>       14     test -z "$CC" && {
>       15         CC=`command -v gcc 2>/dev/null`
>       16         test -x "$CC" || CC=`command -v cc`
>       17     }
>       18
>       19     errno_list=`
>       20       $CC -E ${tmpf} | \
>       21         sed -n -e 's/\.h[^-_a-zA-Z0-9/].*/.h/' \
>       22             -e 
> 'address@hidden(/usr/include.*/errno\)@address@hidden' | \
>       23         sort -u `
>       24
>       25     grep_expr='^[       ]*#[    ]*define[       ]+E[A-Z_0-9]+[  
> ]*[0-9]'
>       26     sed_cmd='s/^[       ]*#[    ]*define[       ]*//'
>       27
>       28     egrep -h "$grep_expr" $errno_list | \
>       29         sed "$sed_cmd" | \
>       30         awk '{ print $1 " " $2 }' | \
>       31         sort -u -n -k2 > ${tmpd}/sorted.txt
>       32 }
>       33
>       34 compute_limits() {
>       35     max_val=`sed -n '$s/^[A-Z_0-9]*[    ]*//p' ${tmpd}/sorted.txt`
>       36     max_width=0
>       37     last_val=-1
>       38     offset=0
> 
> Not very Bourne-like either.  The others work.  It seems I have 'em all.
> Even Solaris' /bin/sh.  I still have access to one at U of Utah.  It works.
> 

Regards,
  Stefano



reply via email to

[Prev in Thread] Current Thread [Next in Thread]