ca5dfe5816d8dec66b943f5629bb6c2bba2f5b46
2 # Desc: Prints mediawiki code for a summary of months of a year on the bk4 wiki.
3 # Usage: /bin/bash mw_create_summary_months.sh [int year]
5 # Example: /bin/bash mw_create_summary_months.sh [int year] > output.txt
8 yell
() { echo "$0: $*" >&2; } # print script path and all args to stderr
9 die
() { yell
"$*"; exit 111; } # same as yell() but non-zero exit status
10 must
() { "$@" || die
"cannot $*"; } # runs args as command, reports args if command fails
15 if [[ $# -ne 1 ]]; then die
"FATAL:Invalid arg count:$#"; fi;
16 ## Strip leading zeroes (because August/octal)
17 yyyy
="$((10#${yyyy}))";
20 if [[ ! $yyyy =~
$re ]]; then die
"FATAL:Invalid year string:$yyyy"; fi;
21 if [[ ! $yyyy -ge 1582 ]]; then die
"FATAL:Invalid year string:$yyyy"; fi;
25 yyyy_prev
="$((yyyy - 1))";
26 yyyy_next
="$((yyyy + 1))";
28 # Form and print header
29 printf "{{bk journal header}}\n";
30 printf "A summary of monthly journals of [[%d]]. " "$yyyy";
31 printf "Preceded by [[Summary of months of %d]]. " "$yyyy_prev";
32 printf "Followed by [[Summary of months of %d]]. " "$yyyy_next";
36 for (( mm
=1; mm
<= 12; mm
++)); do
37 printf "=[[%4d-%02d]]=" "$yyyy" "$mm";
39 printf "{{:%4d-%02d}}" "$yyyy" "$mm";
45 # Form and print footer
46 printf "{{bk journal footer}}\n";
47 s1
="[[Category:Monthly summaries by year]]"
55 # Author: Steven Baltakatei Sandoval