From 9f6222ac1bf8c2d7ddeb45bf61dcc2a87f7143ee Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 23 Oct 2023 14:58:17 +0300 Subject: [s0] Reworked timestamp.txt generation to use while heredoc and an awk script for creation Faster and more portable --- csg | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/csg b/csg index 53a6f70..c145ca2 100755 --- a/csg +++ b/csg @@ -131,12 +131,15 @@ endTimer() { if [ -n "$CSG_TIMESTAMP_FILE" ] && isCommand 'git' then timestamps_writeDates() { - for file in $(find . -type f -name '*.md') + while read -r file do - dates=($(git log --follow --pretty=format:%ad --date="format:%d %B %Y" -- "$file")) - line="$DESTINATION${file:1:-2}html\t${dates[@]: -3:3} ${dates[@]:0:3}" - echo -e "$line" >> "$CSG_TIMESTAMP_FILE" - done + git log --follow --pretty=format:%ad --date="format:%d %B %Y" -- "$file" | $CSG_AWK -v dest="$DESTINATION" -v file="$file" ' + BEGIN { file = dest substr(file, 2, length(file) - 3) "html" } + NR == 1 { later = $0 } + END { print file "\t" $0 "\t" later }' >> "$CSG_TIMESTAMP_FILE" + done << EOF +$(find . -type f -name '*.md') +EOF } headc="$(git rev-parse HEAD)" -- cgit v1.3.1-23-gd82d