On 06/10/14 13:51, Andy wrote:
On 12/05/14 21:11, Alexander Hall wrote:
On 05/12/14 13:11, andy wrote:

NB; My 'patches' are not really patches as they are not code diff's.
They
are just suggested changes i've posted on the lists. When I get more
time
(I'm a one man band at the mo for my company!) I want to get more
familiar
with the code base etc and contribute diffs to OBSD..

     if [ `ifconfig | grep "status: master" | wc -l` > 0 ]; then
ipsecctl
-d -f /etc/ipsec.conf; fi
     sleep 1
     if [ `ifconfig | grep "status: master" | wc -l` > 0 ]; then
ipsecctl
-d -f /etc/ipsec.conf; fi
     if [ `ifconfig | grep "status: master" | wc -l` > 0 ]; then
ipsecctl
-F -f /etc/ipsec.conf; fi

Now my eyes hurt a bit and I cannot let this pass uncontradicted.
AFAICT, the above chunk would always perform all of the ipsecctl's,
and as a bonus leave a '0' file wherever it is run from.

While it could be fixed in the intended style, instead I'll overdo it
and leave it to the reader to find a nice suitable middle ground. :-)

    local f
    for f in d d F; do
        ifconfig | grep -q "status: master" || break
        ipsecctl -$f -f /etc/ipsec.conf
    done

Totally untested, but the idea should be clear.

/Alexander

Hi,

Yea thats a cleaner way to do it, but it doesn't leave '0' files as the
'> 0' is a test condition for the if statement, not a redirect.. :)

There is no such thing as a "test condition for the if statement". The expression(s) within (here, "[ ...", aka "test ...") either returns zero ("true") or nonzero ("false").


Andy

Reply via email to