46 lines
1.4 KiB
Diff
46 lines
1.4 KiB
Diff
|
|
From f9529d1d3f3714c707f38b8e44ac72a69af5483b Mon Sep 17 00:00:00 2001
|
||
|
|
From: Jerome Charaoui <jerome@riseup.net>
|
||
|
|
Date: Fri, 13 Jul 2018 21:49:06 -0400
|
||
|
|
Subject: [PATCH] Remove zero-padding from nowday and whenday (fixes #9397)
|
||
|
|
|
||
|
|
This fixes cases where the day component of the when parameter resolved
|
||
|
|
to a non-zero padded integer under 10, such as "when = 1st at 01"
|
||
|
|
|
||
|
|
The comparison against the nowday variable failed consistently since
|
||
|
|
the date command format used always returned a zero-padded two digit
|
||
|
|
integer.
|
||
|
|
|
||
|
|
The solution chosen is to avoid generating nowday with zero-padding and
|
||
|
|
remove any zero-padding from whenday parameter using a more thorough
|
||
|
|
sed pattern which now also removes any non-alphanumeric characters from
|
||
|
|
the string.
|
||
|
|
---
|
||
|
|
src/backupninja.in | 4 ++--
|
||
|
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/src/backupninja.in b/src/backupninja.in
|
||
|
|
index d6a1045..6da7237 100755
|
||
|
|
--- a/src/backupninja.in
|
||
|
|
+++ b/src/backupninja.in
|
||
|
|
@@ -186,7 +186,7 @@ function tolower() {
|
||
|
|
|
||
|
|
# simple to integer function
|
||
|
|
function toint() {
|
||
|
|
- echo "$1" | tr -d '[:alpha:]'
|
||
|
|
+ echo "$1" | @SED@ 's/[^0-9]//g;s/^0\+//'
|
||
|
|
}
|
||
|
|
|
||
|
|
#
|
||
|
|
@@ -202,7 +202,7 @@ function toint() {
|
||
|
|
# we grab the current time once, since processing
|
||
|
|
# all the configs might take more than an hour.
|
||
|
|
nowtime=`LC_ALL=C date +%H`
|
||
|
|
-nowday=`LC_ALL=C date +%d`
|
||
|
|
+nowday=`LC_ALL=C date +%-d`
|
||
|
|
nowdayofweek=`LC_ALL=C date +%A`
|
||
|
|
nowdayofweek=`tolower "$nowdayofweek"`
|
||
|
|
|
||
|
|
--
|
||
|
|
2.24.1
|
||
|
|
|