diff --git a/cdist/conf/type/__uci_section/files/functions.sh b/cdist/conf/type/__uci_section/files/functions.sh new file mode 100644 index 00000000..9f510958 --- /dev/null +++ b/cdist/conf/type/__uci_section/files/functions.sh @@ -0,0 +1,52 @@ +# -*- mode: sh; indent-tabs-mode: t -*- + +append_values() { + while read -r _value + do + set -- "$@" --value "${_value}" + done + unset _value + "$@" &2 +} + +uci_validate_name() { + # like util.c uci_validate_name() + test -n "$*" && test -z "$(printf %s "$*" | tr -d '[:alnum:]_' | tr -c '' .)" +} + +unquote_lines() { + sed -e '/^".*"$/{s/^"//;s/"$//}' \ + -e '/'"^'.*'"'$/{s/'"^'"'//;s/'"'$"'//}' +} + +validate_options() { + grep -shv -e '^[[:alnum:]_]\{1,\}=' "$@" +} diff --git a/cdist/conf/type/__uci_section/manifest b/cdist/conf/type/__uci_section/manifest index a7865315..208a2c4e 100755 --- a/cdist/conf/type/__uci_section/manifest +++ b/cdist/conf/type/__uci_section/manifest @@ -18,46 +18,8 @@ # along with cdist. If not, see . # -grep_line() { { shift; printf '%s\n' "$@"; } | grep -qxF "$1"; } -prefix_lines() { - while test $# -gt 0 - do - echo "$2" | awk -v prefix="$1" '$0 { printf "%s %s\n", prefix, $0 }' - shift; shift - done -} -uci_validate_name() { - # like util.c uci_validate_name() - test -n "$*" && test -z "$(printf %s "$*" | tr -d '[:alnum:]_' | tr -c '' .)" -} -validate_options() { grep -shv -e '^[[:alnum:]_]\{1,\}=' "$@"; } -unquote_lines() { - sed -e '/^".*"$/{s/^"//;s/"$//}' \ - -e '/'"^'.*'"'$/{s/'"^'"'//;s/'"'$"'//}' -} -append_values() { - while read -r _value - do - set -- "$@" --value "${_value}" - done - unset _value - "$@" &2 -} +# shellcheck source=files/functions.sh +. "${__type:?}/files/functions.sh" ## Check section name and error if invalid!