On 19/07/2025 13:16, Bernhard Voelker wrote:
Hi Collin,

On 7/18/25 05:03, Collin Funk wrote:
I've attached a basic test I wrote for the Thai solar calendar using
th_TH.UTF-8 based on the properties that Bruno described [1].

  > +# Current year in the Gregorian calendar.
  > +current_year=$(LC_ALL=C date +%Y)
  > +
  > +export LC_ALL=th_TH.UTF-8
  > +
  > +# Since 1941, the year in the Thai solar calendar is the Gregorian year 
plus
  > +# 543.
  > +test $(date +%Y) == $(($current_year + 543)) || fail=1
____________________^^_^^^___________________^^
That is 2x bash syntax, and at least the == is flagged by:

    maint.mk: use "test x = x", not "test x == x"
    make: *** [maint.mk:1218: sc_prohibit_test_double_equal] Error 1

The POSIX $(( )) syntax is fine and used elsewhere in tests,
but yes the == should be avoided.


Better use expr(1) instead of $(( )).

I'm also getting this failure here:

    ++ LC_ALL=C
    ++ date +%Y
    + current_year=2025
    + export LC_ALL=th_TH.UTF-8
    + LC_ALL=th_TH.UTF-8
    ++ date +%Y
    + test 2025 == 2568
    + fail=1

  > +# All months that have 31 days end have names that end with "คม".
  > +for month in 01 03 05 07 08 10 12; do
  > +  date --date=$current_year-$month-01 +%B | grep คม$ || fail=1
____________________________________________________^^^

Non-ascii characters are hard to use/read.
I suggest checking for the UTF value instead - something like:

    date ... | od -tx1z -w500 | grep -F '84 e0 b8 a1 0a'

Right, though it might be better to use \uXXXX char specifiers
than raw UTF-8 encodings. Something like:

# All months that have 31 days have names that end with "คม".
days_31_suffix=$(env LC_ALL=th_TH.UTF-8 printf '\u0E04\u0E21')
test $(printf '%s' "$days_31_suffix" | wc -c) = 6 || skip_ 'bad suffix'
for month in 01 03 05 07 08 10 12; do
  date --date=$current_year-$month-01 +%B | grep "$days_31_suffix$" || fail=1
done


cheers,
Pádraig

Reply via email to