docker-alpine icon indicating copy to clipboard operation
docker-alpine copied to clipboard

Strings with Greek characters are getting ignored in scripts. [ tolower command doesn't work on Greek Characters ]

Open zzecool opened this issue 1 year ago • 1 comments

Hi,

I was trying to run a script where there are REGEX with Greek strings inside and i found that they are getting ignored by the script engine .

What i have tried is the install locales in the quest to fix that and even change the locales to no avail. No matter what the Greek strings are getting ignored.

Thanks in advance.

EDIT : I found that the problem was not actually the Greek characters but the "tolower" command

Same behaviour appears to ubuntu docker base image as well, but not in VM's or real installations.

The script to reproduce the problem is the following :

#!/bin/bash CHMOD=666

phrase="Άλφα & Δέλτα" REGEX="(άλφα|βήτα).*?(γάμα|δέλτα)" lowphrase=$(echo "$phrase" | awk '{print tolower($0)}')

echo $lowphrase

if [[ "$lowphrase" =~ $REGEX ]] then echo "It's working" else echo "It doesnt work" fi

zzecool avatar Oct 07 '22 08:10 zzecool

The problem resides in the awk command that is build in the busybox

Ubuntu base images using the awk from the mawk package have the same problem

Installing the gawk package fixes the problem

Step to reproduce :

root@:/config# ./test_greek.sh Άλφα & Δέλτα It doesnt work root@:/config# apk add --no-cache gawk fetch http://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz (1/1) Installing gawk (5.1.0-r0) Executing busybox-1.33.1-r8.trigger OK: 156 MiB in 133 packages root@:/config# ./test_greek.sh άλφα & δέλτα It's working root@:/config#

zzecool avatar Oct 08 '22 11:10 zzecool