diff options
| Commit | e196fe2c81e69a08dad7c834556461d2cc6465fb (patch) | |
|---|---|---|
| Author | 2023-10-17 15:50:27 +0300 | |
| Committer | 2023-10-17 15:50:33 +0300 | |
| Files | fec7914e10bace6d4eedc866dd2fa1a8771c58a9 | |
| csg-e196fe2c81e69a08dad7c834556461d2cc6465fb.tar csg-e196fe2c81e69a08dad7c834556461d2cc6465fb.tar.gz csg-e196fe2c81e69a08dad7c834556461d2cc6465fb.zip | ||
| Parent | 57e9d1666dcaae4d952a166d3af1c67aa1b1b251 (diff) | |
[s1] awk scripts are combined and awk libraries are extracted only when AWKSCRIPTS isn't empty string
1 files changed, 32 insertions, 29 deletions
| -rwxr-xr-x | csg | 61 |
@@ -156,40 +156,43 @@ do mv "$file" "${file%md}html" done -overwriteLine "[Stage 1] Combining awk scripts" +if [ -n "$AWKSCRIPTS" ] +then + overwriteLine "[Stage 1] Combining awk scripts" -scr_path=() -scr_recip=() -while read -r reg; read -r scripts -do - cat $scripts > "$CSG_TMP_DIR/csg-${#scr_path[@]}.awk" - scr_path+=("$CSG_TMP_DIR/csg-${#scr_path[@]}.awk") - scr_recip+=("$(find $DESTINATION -type f -regex "$reg")") -done < <($CSG_AWK ' -{ - # Remove first field - $1=""; sub(FS, "") - # Associate current file with regex - if (awks[$0] == "") awks[$0] = FILENAME - else awks[$0] = awks[$0] " " FILENAME + scr_path=() + scr_recip=() + while read -r reg; read -r scripts + do + cat $scripts > "$CSG_TMP_DIR/csg-${#scr_path[@]}.awk" + scr_path+=("$CSG_TMP_DIR/csg-${#scr_path[@]}.awk") + scr_recip+=("$(find $DESTINATION -type f -regex "$reg")") + done < <($CSG_AWK ' + { + # Remove first field + $1=""; sub(FS, "") + # Associate current file with regex + if (awks[$0] == "") awks[$0] = FILENAME + else awks[$0] = awks[$0] " " FILENAME - nextfile -} -END { - for (reg in awks) { - print reg - print awks[reg] + nextfile } -} -' $(find $AWKSCRIPTS -type f -name "[A-Z]*.awk")) + END { + for (reg in awks) { + print reg + print awks[reg] + } + } + ' $(find $AWKSCRIPTS -type f -name "[A-Z]*.awk")) -overwriteLine "[Stage 1] Finding awk libraries" + overwriteLine "[Stage 1] Finding awk libraries" -scr_libs="" -while read -r file -do - scr_libs+=" -f $file " -done < <(find $AWKSCRIPTS -type f -name "#*.awk") + scr_libs="" + while read -r file + do + scr_libs+=" -f $file " + done < <(find $AWKSCRIPTS -type f -name "#*.awk") +fi endTimer "[Stage 1] Done" |
