forked from ungleich-public/cdist-contrib
[type/__mail_alias] Fix error with some AWK implementations
Some AWK implementations seem to have a problem with parameters named default. awk: cmd. line:2: function sepafter(f, default, _) { awk: cmd. line:2: ^ syntax error awk: cmd. line:5: return _ ? _ : default awk: cmd. line:5: ^ syntax error In addition the temp file is removed if an error occurs.
This commit is contained in:
parent
43c59985d0
commit
49d39eaee5
1 changed files with 3 additions and 2 deletions
|
@ -67,10 +67,10 @@ cat <<'EOF'
|
|||
test -f "${aliases_file}" || touch "${aliases_file}"
|
||||
|
||||
awk -F ':[ \t]*' -v mode=$mode '
|
||||
function sepafter(f, default, _) {
|
||||
function sepafter(f, def, _) {
|
||||
# finds the separator between field $f and $(f+1)
|
||||
_ = substr($0, length($f)+1, index(substr($0, length($f)+1), $(f+1))-1)
|
||||
return _ ? _ : default
|
||||
return _ ? _ : def
|
||||
}
|
||||
|
||||
function write_aliases() {
|
||||
|
@ -134,6 +134,7 @@ END {
|
|||
write_aliases()
|
||||
}
|
||||
' <"${aliases_file}" >"${aliases_file}.tmp" || {
|
||||
rm -f "${aliases_file}.tmp"
|
||||
echo 'Generating new aliases file failed!' >&2
|
||||
exit 1
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue