Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] Y07call_program: only check values of LC_ALL etc.



On MY Ubuntu-26.04 Y07call_program fails as:

@@ -1,4 +1,4 @@
 line: {tst }{}
 MESSAGE:{e z é}
 line: {tst }{}
-MESSAGE:{e é z}
+MESSAGE:{e z é}
Test Y07call_program.ztst failed: output differs from expected as shown above for:
  if [[ -z ${lc::=${ ZTST_find_UTF8 }} ]]; then
    ZTST_skip='no utf8 locale'
  else
    comptesteval "old_LC_ALL=\$LC_ALL; LC_ALL=${(q+)lc}"
    for 1 in '' -l; do
      tst_call_program $1 tag '
        local -a arr=( z e é )
        print -r - ${(o)arr}
      '
    done
    comptesteval 'LC_ALL=$old_LC_ALL'
  fi
Was testing: -l


This is because only the following 4 locales are available:

% locale -a
C
C.utf8
POSIX
ja_JP.utf8
%
(this happens if you select 'Japanese' while installing Ubuntu)

ZTST_find_UTF8() finds C.utf8, but in this locale 'e < z < é'.

I think it is sufficient to check the values of LC_ALL etc. that are
passed to the command run by _call_program:


diff --git a/Test/Y07call_program.ztst b/Test/Y07call_program.ztst
index 19eca8f9f..afdb3bc69 100644
--- a/Test/Y07call_program.ztst
+++ b/Test/Y07call_program.ztst
@@ -71,20 +71,23 @@
   if [[ -z ${lc::=${ ZTST_find_UTF8 }} ]]; then
     ZTST_skip='no utf8 locale'
   else
-    comptesteval "old_LC_ALL=\$LC_ALL; LC_ALL=${(q+)lc}"
-    for 1 in '' -l; do
-      tst_call_program $1 tag '
-        local -a arr=( z e é )
-        print -r - ${(o)arr}
-      '
-    done
+    comptesteval "old_LC_ALL=\$LC_ALL; lc=$lc; LC_ALL=$lc"
+    # without -l: _comp_locale sets LC_CTYPE=$lc, LC_ALL=, LANG=C
+    tst_call_program tag '
+      [[ $LC_CTYPE != $lc ]] && echo "bad LC_CTYPE (without -l)"
+      print -r - LANG=$LANG LC_ALL=$LC_ALL
+    '
+    # with -l: locale doesn't change: LC_ALL=$lc
+    tst_call_program -l tag '
+      [[ $LC_ALL != $lc ]] && echo "LC_ALL changed (with -l)"
+    '
     comptesteval 'LC_ALL=$old_LC_ALL'
   fi
 0:-l
 >line: {tst }{}
->MESSAGE:{e z é}
+>MESSAGE:{LANG=C LC_ALL=}
 >line: {tst }{}
->MESSAGE:{e é z}
+>MESSAGE:{}
 
   tst_call_program    tag print a b c
   tst_call_program -p tag print a b c






Messages sorted by: Reverse Date, Date, Thread, Author