-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

with sed we have the same problem as with awk - it could be in /usr/bin, and 
then we fail again. Also could one link sed with the pcre library, that would 
surely reside in /usr/lib - but I'm not completely sure about that point, 
though. Here, grep is linked with pcre, that's why I'm guessing it might be 
the same with sed, too.

More generally spoken, in my opinion we should rely on external binaries as 
little as possible.

By the way, with your script you don't need a temporary file, just 
use 'sed -i' :-)

        Eric

- ------ Original Message ------
Sender: David Paleino <[EMAIL PROTECTED]>
Recipient: [email protected]
Date: Saturday 03 February 2007 23:45
Subject: Re: [Initng] [InitNG] #477: we fail again with /usr on a different 
partition

> Eric MSP Veith ha scritto:
> > David,
> >
> > you're totally right with your asumptions. Gosh, two years of writing
> > perl scripts and I cannot even say what a tiny AWK expression is going to
> > do, shame on me! :-(
>
> Lol, don't worry! :)
>
> > Well, we could easily replace that with a bash script. Bash supports
> > regular expressions since 3.0 (afaik), so it's easy to implement. It
> > could go like this:
> >
> >
> > if [[ -n "$DNSDOMAIN" ]] && [[ -f "/etc/resolv.conf" ]]
> > then
> >         touch /tmp/resolv.conf.tmp
> >         while read line
> >         do
> >                 if [[ "$line" =~ "domain.*" ]]
> >                 then
> >                         echo "domain $DNSDOMAIN" >> /tmp/resolv.conf.tmp
> >                 else
> >                         echo "$line" >> /tmp/resolv.conf.tmp
> >                 fi
> >         done < "/etc/resolv.conf"
> >     mv /tmp/resolv.conf.tmp /etc/resolv.conf
> > fi
> >
> >
> > I don't know whether mv is stored in /usr/bin or in /bin, here, it's in
> > /bin.
> >
> > Staying bash ver 2.05 conformant would be possible, too.
>
> I think that would be even easier using cat and sed:
>
> if [[ -n "$DNSDOMAIN" ]] && [[ -f "/etc/resolv.conf" ]]
> then
>     touch /tmp/resolv.conf.tmp
>     sed -e 's/^domain .*$/domain $DNSDOMAIN/g' /etc/resolv.conf >
> /tmp/resolv.conf.tmp
>     mv /tmp/resolv.conf.tmp /etc/resolv.conf
> fi;
>
> Haven't tried that though, it should print the right lines into the
> temporary file.
>
> On my Debian, here are the paths (you might need them, since you stated
> you don't know where mv is):
>
> /bin/mv
> /bin/sed
> /usr/bin/touch
>
> > HTH,
> >     Eric
>
> Cheers,
> David
>
> --
>          Linux Registered User #334216
> Get FireFox! >> http://snipurl.com/gofoxygo/ <<
> Blog         >>  http://www.hanskalabs.net/  <<
> Staff        >> http://www.debianizzati.org/ <<
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFFxRLKMpEdE19y46cRAiOMAKC0Avth6IRtMU/M4RVbmNdSBKeXeACdGNbK
iALg1QYRu4CftjCHVUAW4pE=
=YvBN
-----END PGP SIGNATURE-----
-- 
_______________________________________________
Initng mailing list
[email protected]
http://jw.dyndns.org/mailman/listinfo/initng

Reply via email to