From 49d39eaee50bc848840cb4fda91e2ed0cb4a14f1 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Wed, 26 Aug 2020 18:01:52 +0200 Subject: [PATCH] [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. --- type/__mail_alias/gencode-remote | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/type/__mail_alias/gencode-remote b/type/__mail_alias/gencode-remote index 3eaad75..9f4af1b 100755 --- a/type/__mail_alias/gencode-remote +++ b/type/__mail_alias/gencode-remote @@ -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 }