From 8879e8c691b94710c0e1903f685c99d7c56e15e1 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 16 Oct 2023 18:45:36 +0300 Subject: (s1,s2) Added more general logic for awk libraries --- csg | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/csg b/csg index 012a5cc..2b71bbe 100755 --- a/csg +++ b/csg @@ -91,6 +91,14 @@ END { } ' $(find $AWKS -type f -name "[A-Z]*.awk")) +overwriteLine "[Stage 1] Finding awk libraries" + +scr_libs="" +while read -r file +do + scr_libs+=" -f $file " +done < <(find $AWKS -type f -name "#*.awk") + endTimer "[Stage 1] Done" ### Stage 2 @@ -133,8 +141,13 @@ transform-file() { "$file" > "$outf" # Run custom awk scripts - awk --posix -f './awk-edits/#strings.awk' $scripts -f '/tmp/awk-print' "$outf" > "$outf.tmp" - mv -f "$outf.tmp" "$outf" + awk --posix \ + -v title="$title" \ + -v description="$descr" \ + -v words="$words" \ + $scr_libs $scripts -f '/tmp/csg-print.awk' \ + "$outf" > "$outf.tmp" + mv "$outf.tmp" "$outf" # Create final file awk -v title="$title" -v description="$descr" ' @@ -152,9 +165,9 @@ transform-file() { while read -r file do scripts="" - for i in {0..5} + for i in ${!scr_recip[@]} do - [ "${scr_recip[$i]}" != "${scr_recip[$i]/${file%md}html/}" ] && scripts+="-f ${scr_path[$i]} " + [ "${scr_recip[$i]}" != "${scr_recip[$i]/${file%md}html/}" ] && scripts+=" -f ${scr_path[$i]} " done transform-file "$file" "$scripts" & done < <(find "$OUTPUT" -type f -name "*.md") -- cgit v1.3.1-26-gb76a