Fixed month arithmetic defect

This commit is contained in:
Scott C. MacCallum 2023-03-15 21:01:46 +00:00
parent 85428b731c
commit 2fb87ab7f5

View File

@ -20,12 +20,17 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
month=$(date '+%m') month=$(date '+%m')
let prevmonth=$month-1 one=1
last_month=$(($month - $one))
year=$(date '+%Y') year=$(date '+%Y')
letter="s" letter="s"
finger() finger()
{ {
echo
echo "Finger conversion"
echo
# Download the index.html and $month.html files # Download the index.html and $month.html files
sftp $USER@ma.sdf.org:/meta/$letter/$USER/html/index.html /sdf/arpa/ns/$letter/$USER/finger sftp $USER@ma.sdf.org:/meta/$letter/$USER/html/index.html /sdf/arpa/ns/$letter/$USER/finger
sftp $USER@ma.sdf.org:/meta/$letter/$USER/html/posts/$year/$month.html /sdf/arpa/ns/$letter/$USER/finger sftp $USER@ma.sdf.org:/meta/$letter/$USER/html/posts/$year/$month.html /sdf/arpa/ns/$letter/$USER/finger
@ -49,10 +54,10 @@ finger()
cat /sdf/arpa/ns/$letter/$USER/finger/$month-e01 | col -b -x > /sdf/arpa/ns/$letter/$USER/finger/$month-e02 cat /sdf/arpa/ns/$letter/$USER/finger/$month-e01 | col -b -x > /sdf/arpa/ns/$letter/$USER/finger/$month-e02
# Remove the HTML link reference to previous month posts # Remove the HTML link reference to previous month posts
if [ $prevmonth -lt 10 ]; then if [ $last_month -lt 10 ]; then
sed -i "s/0$prevmonth//" /sdf/arpa/ns/$letter/$USER/finger/$month-e02 sed -i "s/0$last_month//" /sdf/arpa/ns/$letter/$USER/finger/$month-e02
else else
sed -i "s/$prevmonth//" /sdf/arpa/ns/$letter/$USER/finger/$month-e02 sed -i "s/$last_month//" /sdf/arpa/ns/$letter/$USER/finger/$month-e02
fi fi
# Write a header file from index-e02 # Write a header file from index-e02
@ -79,6 +84,10 @@ finger()
gopher() gopher()
{ {
echo
echo "Gopher conversion"
echo
# If the year has changed, and a new year directory does not already # If the year has changed, and a new year directory does not already
# exist, create it # exist, create it
@ -117,6 +126,10 @@ gopher()
gemini() gemini()
{ {
echo
echo "Gemini conversion"
echo
# If the year has changed, and a new year directory does not already # If the year has changed, and a new year directory does not already
# exist, create it # exist, create it
@ -160,7 +173,6 @@ gemini()
finger finger
gopher gopher
web
gemini gemini
exit 0 exit 0