WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: getlocale.sh broken on pi  (Read 192 times)

Offline vext01

  • Newbie
  • *
  • Posts: 22
getlocale.sh broken on pi
« on: June 11, 2026, 05:09:23 PM »
Hi,

As mentioned in https://forum.tinycorelinux.net/index.php?topic=28163.0, getlocale.sh is currently broken, at least on picore.

When I first ran it, it just exits silently. This was for two reasons:
  • It didn't like TERM=alacritty (vt100 was fine)
  • It writes a bogus dialog scrpt

This diff fixes the latter:
Code: [Select]
--- /usr/local/bin/getlocale.sh 2014-01-15 11:26:39.000000000 +0000
+++ getlocale.sh 2026-06-06 19:19:01.000000000 +0000
@@ -10,7 +10,7 @@

 echo "--separate-output --checklist \"Choose which locales to support:\" 0 42 10 " > $temp2
 for i in `cat $SFILE`; do
- echo "$i \" \" off \\" >> $temp2
+ echo "$i \" \" off" >> $temp2
 done

 dialog --file $temp2 2> $tempfile

This is on:
Code: [Select]
NAME=piCore
VERSION="16.0"

I've seen this now on both 32 and 64 bit raspberry pi.

Cheers

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 12848
Re: getlocale.sh broken on pi
« Reply #1 on: June 12, 2026, 11:47:43 AM »
Hi vext01
What happens if you do it this way:
Code: [Select]
tc@E310:~$ diff -u /tmp/tcloop/getlocale/usr/local/bin/getlocale.sh /usr/local/bin/getlocale.sh
--- /tmp/tcloop/getlocale/usr/local/bin/getlocale.sh    2014-01-15 11:26:39.000000000 +0000
+++ /usr/local/bin/getlocale.sh 2026-06-12 11:30:53.339562305 +0000
@@ -13,6 +13,8 @@
        echo "$i \" \" off \\" >> $temp2
 done
 
+echo >> $temp2
+
 dialog --file $temp2 2> $tempfile
 
 [ "$?" -ne 0 ] && exit 1
That should fix it too.

I don't like the idea of removing the line continuation characters.

Offline vext01

  • Newbie
  • *
  • Posts: 22
Re: getlocale.sh broken on pi
« Reply #2 on: June 12, 2026, 06:41:16 PM »
Hi,

Applied the diff, but it's not right.

Code: [Select]
$ sudo sh -x getlocale.sh
...
+ echo 'zu_ZA/ISO-8859-1 " " off \'
+ echo
+ dialog --file /tmp/tmp.Q3Gl3zv17I
+ '[' 255 -ne 0 ]
+ exit 1

Code: [Select]
$ sudo dialog --file /tmp/tmp.Q3Gl3zv17I

Error: Expected 3 arguments, found extra 1.
Use --help to list options.

Code: [Select]
$ sudo less /tmp/tmp.Q3Gl3zv17I
--separate-output --checklist "Choose which locales to support:" 0 42 10
aa_DJ.UTF-8/UTF-8 " " off \
aa_DJ/ISO-8859-1 " " off \
aa_ER/UTF-8 " " off \
aa_ER@saaho/UTF-8 " " off \
...

These backslashes on the end of the dialog file are not right.

Offline mjmouse

  • Newbie
  • *
  • Posts: 12
Re: getlocale.sh broken on pi
« Reply #3 on: Today at 04:28:49 AM »
Looking at the code for dialog, the parsing has had a fix for its escaping since the version in piCore (20181107).

The one in use in x86 and x86_64 versions of tinycore is also more recent (20250116).

This is diffing the argv.c from dialog-1.3-20260107 (current) and dialog-1.3-20181107 (piCore):
(parts snipped for clarity)
Code: [Select]
--- dialog-1.3-20181107/argv.c
+++ dialog-1.3-20260107/argv.c
...
@@ -60,37 +59,38 @@
     for (pass = 0; pass < 2; ++pass) {
         bool inparm = FALSE;
         bool quoted = FALSE;
-        bool escape = FALSE;
         char *param = blob;
         size_t count = 0;
 
         for (n = 0; n < length; ++n) {
-            if (escape) {
-                ;
-            } else if (quoted && blob[n] == '"') {
+            if (quoted && blob[n] == '"') {
                 quoted = FALSE;
             } else if (blob[n] == '"') {
                 quoted = TRUE;
                 if (!inparm) {
-                    if (pass)
+                    if (pass) {
                         result[count] = param;
+                    }
                     ++count;
                     inparm = TRUE;
                 }
             } else if (!quoted && isspace(UCH(blob[n]))) {
                 if (inparm) {
                     if (pass) {
-                        *param++ = '\0';
+                        *param = '\0';
                     }
+                    ++param;
                     inparm = FALSE;
                 }
             } else {
                 if (blob[n] == '\\') {
-                    if (n + 1 == length) {
+                    size_t n1 = (n + 1);
+                    bool ignore = FALSE;
+                    if (n1 == length) {
                         break;        /* The string is terminated by a backslash */
-                    } else if ((blob[n + 1] == '\\') ||
-                               (blob[n + 1] == '"') ||
-                               (!quoted && blob[n + 1] == '\n')) {
+                    } else if ((blob[n1] == '\\') ||
+                               (blob[n1] == '"') ||
+                               (ignore = (blob[n1] == '\n'))) {
                         /* eat the backslash */
                         if (pass) {
                             --length;
@@ -98,38 +98,40 @@
                                 blob[k] = blob[k + 1];
                             blob[length] = '\0';
                         } else {
-                            escape = TRUE;
-                            continue;
+                            ++param;        /* pretend I ate it */
                         }
+                        if (ignore)
+                            continue;
                     }
                 }
...

Perhaps we can request an updated extension from bmarkus?

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 15663
Re: getlocale.sh broken on pi
« Reply #4 on: Today at 09:00:24 AM »
dialog updated in piCore repo