X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=functions.util;h=83ec302c9812c8c24a141635ac8fa600cd7c0726;hb=711ffac1e45041250adcdecff39a8101cc3b52e5;hp=c0721900195e904f98190468930f79b9a1d2fb0b;hpb=18b433722e3468cbb57a6c99d64e76c97a1eac20;p=people%2Farne_f%2Fnetwork.git diff --git a/functions.util b/functions.util index c0721900..83ec302c 100644 --- a/functions.util +++ b/functions.util @@ -21,7 +21,7 @@ # Print a pretty error message function error() { - echo -e " ${FAIL}ERROR${NORMAL} : $@" >&2 + echo -e " ${COLOUR_ERROR}ERROR${COLOUR_NORMAL} : $@" >&2 } function error_log() { @@ -31,7 +31,7 @@ function error_log() { # Print a pretty warn message function warning() { - echo -e " ${WARN}WARNING${NORMAL}: $@" >&2 + echo -e " ${COLOUR_WARN}WARNING${COLOUR_NORMAL}: $@" >&2 } function warning_log() { @@ -39,6 +39,7 @@ function warning_log() { log WARNING "$@" } +# XXX uses tr function listsort() { local i for i in $@; do @@ -46,6 +47,31 @@ function listsort() { done | sort | tr "\n" " " } +function listmatch() { + local match=${1} + shift + + assert isset match + + local i + for i in $@; do + [ "${match}" = "${i}" ] && return ${EXIT_OK} + done + + return ${EXIT_ERROR} +} + +function listlength() { + local length=0 + + local i + for i in $@; do + length=$(( ${length} + 1 )) + done + + echo "${length}" +} + function config_read() { local config_file=${1} @@ -181,7 +207,7 @@ function mac_is_valid() { } function uuid() { - cat /proc/sys/kernel/random/uuid + echo $(