bug-gnu-libiconv
[Top][All Lists]
Advanced

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

[bug-gnu-libiconv] Re: adding version identification to libiconv and lib


From: amores perros
Subject: [bug-gnu-libiconv] Re: adding version identification to libiconv and libintl
Date: Mon, 21 May 2007 23:58:48 +0000




We stick to POSIX 'sh' and tools. If you use bash3 syntax, I'll rewrite it
to use plain sh and 'sed'. The reference for POSIX sh is POSIX [1], combined with the chapter on "portable shell programming" in the GNU autoconf manual.[2]
[1] http://www.opengroup.org/susv3/mindex.html
[2] http://www.gnu.org/software/autoconf/manual/autoconf.html#Portable-Shell

I want to parse the version number, to match as many numbers at the front
as possible, eg,

== BEGIN QUOTE ==

if [[ $VERSION =~ ([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+) ]]
then
 then
   VERSION1=${BASH_REMATCH[1]}
   VERSION2=${BASH_REMATCH[2]}
   VERSION3=${BASH_REMATCH[3]}
   VERSION4=${BASH_REMATCH[4]}
   return
 fi
 if [[ $VERSION =~ ([0-9]+)\.([0-9]+)\.([0-9]+) ]]
 then
   VERSION1=${BASH_REMATCH[1]}
   VERSION2=${BASH_REMATCH[2]}
   VERSION3=${BASH_REMATCH[3]}
   VERSION4=0
   return
 fi
 if [[ $VERSION =~ ([0-9]+)\.([0-9]+) ]]
 then
   VERSION1=${BASH_REMATCH[1]}
   VERSION2=${BASH_REMATCH[2]}
   VERSION3=0
   VERSION4=0
   return
 fi

== END QUOTE ==

I haven't figured out any simple way to use
sed like this, b/c sed doesn't seem to report
whether or not it found matches.

Surely I could do a sed substitution and
write in a success note and then check for that
with grep, but that is getting kind of roundabout.

(It is ok to use temp files in current directory, I think,
because gettext does that, I believe.)

I'm included to try to see if I can figure out a way
to do this with awk instead -- b/c I don't think basic
sh allows regular expressions, and it looks like it would
maybe take some tricky hacking in sed.

I see awk listed here

http://www.opengroup.org/onlinepubs/009695399/utilities/contents.html

so I assume it is an acceptable tool?

_________________________________________________________________
PC Magazine’s 2007 editors’ choice for best Web mail—award-winning Windows Live Hotmail. http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_pcmag_0507





reply via email to

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