forked from ungleich-public/cdist-contrib
[type/__mail_alias] Fixes (mostly mawk compatibility)
This commit is contained in:
parent
a5f3f3cdaf
commit
988f277ad6
3 changed files with 11 additions and 12 deletions
|
@ -22,13 +22,11 @@
|
|||
aliases_file=$("${__type_explorer}/aliases_file")
|
||||
test -r "${aliases_file}" || exit 0
|
||||
|
||||
name=$__object_id
|
||||
|
||||
awk -F ':[[:blank:]]*' '
|
||||
function print_aliases (aliases, matches) {
|
||||
split(aliases, matches, /,[[:blank:]]*/)
|
||||
awk -F ':[ \t]*' '
|
||||
function print_aliases(aliases, matches) {
|
||||
split(aliases, matches, /,[ \t]*/)
|
||||
for (i in matches) {
|
||||
gsub(/^[[:blank:]]*|[[:blank:]]*$/, "", matches[i])
|
||||
gsub(/^[ \t]*|[ \t]*$/, "", matches[i])
|
||||
print matches[i]
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +38,7 @@ function print_aliases (aliases, matches) {
|
|||
|
||||
{
|
||||
cont = ($0 ~ /\\$/)
|
||||
if (cont) sub(/[[:blank:]]*\\$/, "", $0)
|
||||
if (cont) sub(/[ \t]*\\$/, "", $0)
|
||||
}
|
||||
|
||||
/^[[:blank:]]/ || cont {
|
||||
|
|
0
type/__mail_alias/explorer/aliases_file
Normal file → Executable file
0
type/__mail_alias/explorer/aliases_file
Normal file → Executable file
|
@ -23,7 +23,7 @@ state_should=$(cat "${__object}/parameter/state")
|
|||
case $state_should
|
||||
in
|
||||
(present)
|
||||
if cmp "${__object}/explorer/aliases" "${__object}/parameter/alias"
|
||||
if cmp -s "${__object}/explorer/aliases" "${__object}/parameter/alias"
|
||||
then
|
||||
# all good!
|
||||
exit 0
|
||||
|
@ -57,7 +57,8 @@ printf 'mode=%u\n' "${mode}"
|
|||
printf "aliases_file='%s'\n" "${aliases_file}"
|
||||
|
||||
cat <<'EOF'
|
||||
awk -F ':[[:blank:]]*' -v mode="${mode}" '
|
||||
test -f "${aliases_file}" || touch "${aliases_file}"
|
||||
awk -F ':[ \t]*' -v mode="${mode}" '
|
||||
function sepafter(f, default, _) {
|
||||
_ = substr($0, length($f) + 1, index(substr($0, length($f)+1), $(f+1)) - 1)
|
||||
if (_) return _
|
||||
|
@ -90,10 +91,10 @@ BEGIN {
|
|||
|
||||
{
|
||||
cont = ($0 ~ /\\$/)
|
||||
if (cont) sub(/[[:blank:]]*\\$/, "", $0)
|
||||
if (cont) sub(/[ \t]*\\$/, "", $0)
|
||||
}
|
||||
|
||||
/^[[:blank:]]/ || cont {
|
||||
/^[ \t]/ || cont {
|
||||
# continuation line
|
||||
if (select) next
|
||||
}
|
||||
|
@ -118,7 +119,7 @@ END {
|
|||
exit 1
|
||||
}
|
||||
|
||||
if ! cmp "${aliases_file}" "${aliases_file}.tmp"
|
||||
if ! cmp -s "${aliases_file}" "${aliases_file}.tmp"
|
||||
then
|
||||
mv "${aliases_file}.tmp" "${aliases_file}"
|
||||
newaliases
|
||||
|
|
Loading…
Reference in a new issue