Problem in "functions" script library

I have a script on my 11.3 machine which is trying to use a function from file /etc/sysconfig/network/scripts/functions, namely the get ipv4 address. For some reason it does not like line 287 in the file, which is the line beginning with ‘done <’ in the snippet quoted below. Has my functions file become corrupted, and if so what should the line look like? Thanks

get_ipv4address () {
        test -z "$1" && return 1
        local a b c
        while read a b c; do
                if  "$a" = inet ] ; then
        done < <(LC_ALL=POSIX ip -4 address list "$1" 2>/dev/null)
        test -z "$b" && return 1
        echo ${b%%/*}

What argument does that function take? Can you give an example of $1?

  • OK. I see. Overlooked you were talking about /etc/sysconfig/network/scripts/functions.

Are you trying to source this file to use these functions in your own script?

Sorry, here is my context. I am trying to run a script to start and stop Zoneminder, but I cannot find a direct reference to the function in the startup script, so the reference must be indirect. The result, however, is (for example)

service zm stop

/etc/sysconfig/network/scripts/functions: line 287: syntax error near unexpected token <' /etc/sysconfig/network/scripts/functions: line 287: done < <(LC_ALL=POSIX ip -4 address list “$1” 2>/dev/null)’
Stopping ZoneMinder: /etc/init.d/zm: line 63: failure: command not found

I can post the full zm script if that is helpful.

That works for me:

#! /bin/bash

. /etc/sysconfig/network/scripts/functions

get_ipv4address eth0
get_ipv4address eth1

Loog at line 63 of /etc/init.d/zm.

Yes, you are right, that snippet works fine. Must be in the zm script somewhere or my installation was faulty.
Thanks for pointing me in a useful direction.