diff --git a/cdist/conf/type/__ini_value/files/gen-awk.sh b/cdist/conf/type/__ini_value/files/gen-awk.sh index ba26672a..a73a3f7b 100755 --- a/cdist/conf/type/__ini_value/files/gen-awk.sh +++ b/cdist/conf/type/__ini_value/files/gen-awk.sh @@ -34,11 +34,23 @@ SHELL # generate the script and strip awk -v state="$state" ' + function parse(line) { + if(match(line, /^[ \t]*# %code_print%$/) > 0) { + if(state == "present") + print "v_print()" + else if(state == "commented") + print "v_print_commented()" + else + print "print \"script compile error! cdist state " state " unkown!\" > /dev/stderr" + } + else print line + } { - if(match($0, /^[ \t]*# %codeblock_([^%]+)%$/, result) > 0) { - file = (ENVIRON["__type"] "/files/parts/" state "/" result[1] ".awk") + if(match($0, /^[ \t]*# %codeblock_([^%]+)%$/) > 0) { + split($2, result, "_"); type = substr(result[2], 1, length(result[2]) - 1) + file = (ENVIRON["__type"] "/files/parts/" state "/" type ".awk") while((getline line < file) > 0) - print line + parse(line) close(file) } else print diff --git a/cdist/conf/type/__ini_value/files/parts/commented b/cdist/conf/type/__ini_value/files/parts/commented new file mode 120000 index 00000000..568612b9 --- /dev/null +++ b/cdist/conf/type/__ini_value/files/parts/commented @@ -0,0 +1 @@ +present \ No newline at end of file diff --git a/cdist/conf/type/__ini_value/files/parts/commented/found.awk b/cdist/conf/type/__ini_value/files/parts/commented/found.awk deleted file mode 100644 index 934e3cc7..00000000 --- a/cdist/conf/type/__ini_value/files/parts/commented/found.awk +++ /dev/null @@ -1,8 +0,0 @@ -# check if last line was the comment -was_com_there = was_comment(lastline(), comment) - -# print + comment if not there -flush_buffer() -if(comment && !was_com_there) c_print() - -v_print_commented() diff --git a/cdist/conf/type/__ini_value/files/parts/commented/insert.awk b/cdist/conf/type/__ini_value/files/parts/commented/insert.awk deleted file mode 100644 index 3064ab81..00000000 --- a/cdist/conf/type/__ini_value/files/parts/commented/insert.awk +++ /dev/null @@ -1,9 +0,0 @@ -was_com_there = was_comment(lastline(), comment) - -# print before and comment -flush_buffer() -if(comment && !was_com_there) c_print() - -# print value + seperator line at the end -v_print_commented() -print "" diff --git a/cdist/conf/type/__ini_value/files/parts/present/found.awk b/cdist/conf/type/__ini_value/files/parts/present/found.awk index 7ea4248f..4e456bbb 100644 --- a/cdist/conf/type/__ini_value/files/parts/present/found.awk +++ b/cdist/conf/type/__ini_value/files/parts/present/found.awk @@ -5,4 +5,4 @@ was_com_there = was_comment(lastline(), comment) flush_buffer() if(comment && !was_com_there) c_print() -v_print() +# %code_print% diff --git a/cdist/conf/type/__ini_value/files/parts/present/insert.awk b/cdist/conf/type/__ini_value/files/parts/present/insert.awk index eeaa7eb8..9cb70327 100644 --- a/cdist/conf/type/__ini_value/files/parts/present/insert.awk +++ b/cdist/conf/type/__ini_value/files/parts/present/insert.awk @@ -50,7 +50,7 @@ flush_lines(insertpoint - firstline_index) # print before and comment if(insert_line_before) print "" if(comment && !no_insert_comment) c_print() -v_print() +# %code_print% if(insert_line_after) print "" flush_buffer()