Skip to content

Commit 691b535

Browse files
committed
260222.114502.CET revise the processing of the leading zeros of date +%N, as the previous version does not work on Alpine, which uses ash instead of bash
1 parent 25d87dc commit 691b535

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

.cirrus.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ task:
105105
cd $ROOT_DIR/fortran/tests
106106
107107
# Decide the solver to test by $(date + %N)
108-
# The 10# prefix tells bash to interpret the number as base 10, regardless of leading zeros.
109-
SOLVER_NUM=$((10#$(date +%N) % 5))
108+
NS=$(date +%N)
109+
NS=${NS#"${NS%%[!0]*}"} # Strip leading zeros, or the shell will interpret the number as octal and fail if it contains digits 8 or 9.
110+
SOLVER_NUM=$((${NS:-0} % 5)) # Use 0 if completely empty
110111
if [ $SOLVER_NUM -eq 0 ] ; then
111112
SOLVER=uobyqa
112113
elif [ $SOLVER_NUM -eq 1 ] ; then
@@ -121,13 +122,15 @@ task:
121122
echo $SOLVER_NUM $SOLVER
122123
123124
# Decide the integer kind to test by $(date +%N)
124-
# The 10# prefix tells bash to interpret the number as base 10, regardless of leading zeros.
125-
IK=$((2**(10#$(date +%N) % 3 + 1)))
125+
NS=$(date +%N)
126+
NS=${NS#"${NS%%[!0]*}"} # Strip leading zeros, or the shell will interpret the number as octal and fail if it contains digits 8 or 9.
127+
IK=$((2**((${NS:-0} % 3) + 1))) # Use 0 if completely empty
126128
echo $IK
127129
128130
# Decide the real kind to test by $(date +%N)
129-
# The 10# prefix tells bash to interpret the number as base 10, regardless of leading zeros.
130-
RK=$((2**(10#$(date +%N) % 3 + 2)))
131+
NS=$(date +%N)
132+
NS=${NS#"${NS%%[!0]*}"} # Strip leading zeros, or the shell will interpret the number as octal and fail if it contains digits 8 or 9.
133+
RK=$((2**((${NS:-0} % 3) + 2))) # Use 0 if completely empty
131134
echo $RK
132135
133136
$MK clean && $MK gtest_i${IK}_r${RK}_d1_tst.$SOLVER

0 commit comments

Comments
 (0)