diff options
-rwxr-xr-x | postfix/postfix.sh | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/postfix/postfix.sh b/postfix/postfix.sh index 563ecd3..4a54774 100755 --- a/postfix/postfix.sh +++ b/postfix/postfix.sh @@ -144,15 +144,16 @@ catfirstfile() { cat "$configdir/$file" } -# TODO: support quoted string, and trailing comment. +# TODO: support trailing comment. getperlvarfromfile() { set -e - export var=$1 - export default=$2 + var=$1 + default=$2 file=$3 context=${4:-postfix} catfirstfile "$file" "$context" \ - | perl -nE'/^\$$ENV{"var"}\h*=\h*(\d+)/ and $s=$1; END {print length($s) ? $s : $ENV{"default"}}' + | var=$var default=$default perl -n \ + -e '/^\$$ENV{"var"}\h*=\h*(\d+)/ and $s=$1; END {print length($s) ? $s : $ENV{"default"}}' } getlinesfromfile() { |