From: Zoran Dzelajlija Date: Sat, 30 Apr 2005 02:39:05 +0000 (+0000) Subject: r62: Konzistentno vracanje exit status 2 u slucaju not found greske. X-Git-Tag: debian/3.0.0~44 X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=commitdiff_plain;h=b302e2ad8e40fff725d00b3bcbb67324ebc08e7c;p=carnet-tools-cn.git r62: Konzistentno vracanje exit status 2 u slucaju not found greske. Kozmetika besmislenog koristenja rijeci "such" (?too much copy/paste error). --- diff --git a/functions.sh b/functions.sh index 2094e0a..19116f8 100644 --- a/functions.sh +++ b/functions.sh @@ -17,13 +17,13 @@ cp_get_ifaddr() { if ! ifconfig $interface 2> /dev/null >> /dev/null; then echo "cp_get_ifaddr: $interface: No such interface" 1>&2 CP_ECHO_RETURN="$echo_return" - return 1 + return 2 fi ifaddr="`/sbin/ifconfig $interface | awk '/inet/{ printf("%s\n",substr($2,index($2,":")+1)) }'`" if [ -z $ifaddr ]; then - echo "cp_get_ifaddr: $interface: No such ipaddress" 1>&2 + echo "cp_get_ifaddr: $interface: No ip address found" 1>&2 CP_ECHO_RETURN="$echo_return" return 1 fi @@ -58,7 +58,7 @@ cp_get_ifmask() { ifmask="`/sbin/ifconfig $interface | awk '/Mask/{if($3~/Mask/)a=$3;else if ($4~/Mask/)a=$4;printf ("%s\n", substr(a,index(a,":")+1))}'`" if [ -z "$ifmask" ]; then - echo "cp_get_ifmask: $interface: No such netmask" 1>&2 + echo "cp_get_ifmask: $interface: No netmask found" 1>&2 CP_ECHO_RETURN="$echo_return" return 1 fi @@ -114,14 +114,14 @@ cp_get_netaddr() { cp_get_ifaddr "$interface" ipaddress="$RET" if [ -z $ipaddress ]; then - echo "cp_get_netaddr: $interface: No such ipaddress" 1>&2 + echo "cp_get_netaddr: $interface: No IP address found" 1>&2 CP_ECHO_RETURN="$echo_return" return 1 fi cp_get_ifmask "$interface" netmask="$RET" if [ -z $netmask ]; then - echo "cp_get_netaddr: $interface: No such netmask" 1>&2 + echo "cp_get_netaddr: $interface: No netmask found" 1>&2 CP_ECHO_RETURN="$echo_return" return 1 fi @@ -155,7 +155,7 @@ cp_check_and_backup() { fi if [ ! -f "$1" ]; then echo "cp_backup_conffile: $1: No such file" 1>&2 - return 1 + return 2 fi if [ -z "$2" ]; then file_bak="/var/backups/`basename $1`.bak" @@ -189,7 +189,7 @@ cp_check_and_backup() { # cp_check_and_sed() { [ "$CP_SCRIPT_DEBUG" ] && set -vx - local s sedcmd ret i + local s sedcmd grepret ret i s="$1" shift sedcmd="$1" @@ -198,7 +198,10 @@ cp_check_and_sed() { for i in "$@" do [ -e "$i" ] || continue - egrep -q "$s" "$i" || continue + if ! egrep -q "$s" "$i"; then + grepret=1 + continue + fi [ -h "$i" ] && i=$(readlink -f "$i") sed "$sedcmd" "$i" > "$i.dpkg-tmp" if ! cmp -s "$i" "$i.dpkg-tmp" 2>&1 >/dev/null; then @@ -208,6 +211,7 @@ cp_check_and_sed() { fi ret=0 done + [ "$ret" -eq 2 -a "$grepret"] && ret=1 || true return $ret } @@ -349,7 +353,7 @@ cp_get_ldap_suffix() { if [ ! -f /etc/ldap/slapd.conf ]; then echo "cp_get_ldap_suffix: /etc/ldap/slapd.conf: No such file" >&2 - return 1 + return 2 fi RET="`awk '/^suffix/ { exit } @@ -379,7 +383,7 @@ cp_get_ldap_realm() { if [ ! -f /etc/ldap/slapd.conf ]; then echo "cp_get_ldap_realm: /etc/ldap/slapd.conf: No such file" >&2 - return 1 + return 2 fi cp_get_ldap_suffix || true