building LFS: my settings

Adrian Ho aho-lfs-discuss at 03s.net
Fri Jul 6 05:34:22 PDT 2001


On Fri, Jul 06, 2001 at 08:03:50AM -0400, Gerard Beekmans wrote:
> On Tue, Jul 03, 2001 at 08:55:04AM +0200, Thomas 'Balu' Walter wrote:
> >         sed -e 's,^,\\\(^,' -e 's, ,$\\\)\\\|\\\(^,g' -e 's,$,$\\\),'`
> 
> Yeah isn't it great? I have no idea what it does, but according to
> /usr/bin/updatedb (where I got the prunepath code from) it works and so
> far it has done an excellent job at whatever it is doing

It turns:

/usr/proc /src /random/path

into:

\\\(^/usr/proc$\\\)\\\|\\\(^/src$\\\)\\\|\\\(^/random/path$\\\)

which in turn gets unquoted when used as:

\(^/usr/proc$\)\|\(^/src$\)\|\(^/random/path$\)

Seems particular wasteful to me though.  The updatedb author must've been
utterly paranoid, largely ignorant about regexes when s/he wrote it, or
hadn't had enough sleep.  8-)

A better and shorter sed invocation (briefly tested, YMMV, disclaim all
responsibility etc.):

sed -e 's,^,^\\\(,' -e 's, ,\\\|,g' -e 's,$,\\\)$,'

which yields the (IMO more readable) unquoted regex:

^\(/usr/proc\|/src\|/random/path\)$

- Adrian
-- 
Unsubscribe: send email to lfs-discuss-request at linuxfromscratch.org
and put unsubscribe in the subject header of the message



More information about the lfs-dev mailing list