Re: Parsing package filenames (was: Re: New ftp method for dselect)
"brian (b.c.) white" <bcwhite@bnr.ca> said:
> If the extension can contain dashes, once again it could cause parsing
> problems. Eliminating dashes (or dots, for that matter) here would
> again make it fit into a regular expression.
Yup. Thanks for pointing that out. EXT should disallow dashes.
The following seems to (slowly) parse all packages in a fairly old
"available" file which I have handy as is apparently intended by the
debian package maintainer, with the exception of
gopher-client-"2.1.1"-"2".tar.gz (spurious quotes)
gopherd-"2.1.1"-"2".tar.gz (spurious quotes)
elisp-manual-19-2.4-1.tar.gz (is "-19" part of Name or Veraion?)
lrzsz-0.11.tar.gz (Revision? Should be lrzsz-0-11.tar.gz?)
bind-4.9.3-BETA24-1.tar.gz (change to bind-4.9.3_BETA24-1.tar.gz?)
for FILE in $*
do
TOKENS=`echo $FILE | \
sed -e 's/\(.*\)-\([^-]*\)-\([^.]*\)\.\([^-]*\)$/\1 \2 \3 \4/'`
PKG=`echo $TOKENS | cut -d' ' -f1`
VER=`echo $TOKENS | cut -d' ' -f2`
REV=`echo $TOKENS | cut -d' ' -f3`
EXT=`echo $TOKENS | cut -d' ' -f4`
echo "$PKG $VER $REV $EXT"
done
Reply to: