diff options
| Commit | 456f1e37b0f3d8fffa23f728004623cb681677df (patch) | |
|---|---|---|
| Author | 2023-10-16 18:18:58 +0300 | |
| Committer | 2023-10-16 18:19:56 +0300 | |
| Files | ca3421faee8e1d7e0a326827689ea57abdb8fd98 | |
| csg-456f1e37b0f3d8fffa23f728004623cb681677df.tar csg-456f1e37b0f3d8fffa23f728004623cb681677df.tar.gz csg-456f1e37b0f3d8fffa23f728004623cb681677df.zip | ||
| Parent | a1615f27a1d38c0d7ac0049497142af7ef137ac7 (diff) | |
(s1,s2) Roughly implemented awk script execution
1 files changed, 34 insertions, 0 deletions
| -rwxr-xr-x | csg | 34 |
@@ -37,11 +37,37 @@ find "$OUTPUT" -type f -name "*index.md" -links +1 | while read -r file; do mv "$file" "${file%md}html" done +scr_path=() +scr_recip=() +while read -r reg; read -r scripts +do + cat $scripts > /tmp/csg-${#scr_path[@]}.awk + scr_path+=("/tmp/csg-${#scr_path[@]}.awk") + scr_recip+=("$(find $OUTPUT -type f -regex "$reg")") +done < <(awk ' +{ + # Remove first field + $1=""; sub("^["FS"]*", "", $0) + # + if (awks[$0] == "") awks[$0] = FILENAME + else awks[$0] = awks[$0] " " FILENAME + + nextfile +} +END { + for (reg in awks) { + print reg + print awks[reg] + } +} +' $(find $AWKS -type f -name "[A-Z]*.awk")) + ### Stage 2 ### Transforming Markdown transform-file() { local file="$1" local outf="${file%md}html" + local scripts="$2" # Markdown stats for a file: title, description, words, date created, date edited local title="$(grep -m 1 '^# ' "$file")" @@ -75,6 +101,8 @@ 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" # Create final file awk -v title="$title" -v description="$descr" ' @@ -91,5 +119,11 @@ transform-file() { while read -r file; do transform-file "$file" & + scripts="" + for i in {0..5} + do + [ "${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") wait |
