|
From: | Bruce Korb |
Subject: | Re: errno --> errno name ? |
Date: | Fri, 05 Aug 2011 06:19:03 -0700 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110616 SUSE/3.1.11 Thunderbird/3.1.11 |
On 08/04/11 17:39, Bruno Haible wrote:
Hi Bruce,I fixed up the "mk" script to be more portableIndeed, 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 tries to run awk with the $errno_list argument instead of just passing output through to it. Hopeless. ash: > $ ash -x ./mk-err-names.sh > ./mk-err-names.sh: 37: Syntax error: word unexpected (expecting ")") 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.
[Prev in Thread] | Current Thread | [Next in Thread] |