]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Only use LC_ALL=C where intended
authorMichał Kępień <michal@isc.org>
Tue, 10 Dec 2019 09:31:33 +0000 (10:31 +0100)
committerMichał Kępień <michal@isc.org>
Tue, 10 Dec 2019 09:56:19 +0000 (10:56 +0100)
The LC_ALL=C assignments in the "idna" system test, which were only
meant to affect a certain subset of checks, in fact persist throughout
all the subsequent checks in that system test.  That affects the test's
behavior and is misleading.

When the "VARIABLE=value command ..." syntax is used in a shell script,
in order for the variable assignment to only apply to "command", the
latter must be an external binary; otherwise, the VARIABLE=value
assignment persists for all subsequent commands in a script:

    $ cat foo.sh
    #!/bin/sh

    foo() {
        /bin/sh bar.sh
    }

    BAR="baz0"
    BAR="baz1" /bin/sh bar.sh
    echo "foo: BAR=${BAR}"
    BAR="baz2" foo
    echo "foo: BAR=${BAR}"

    $ cat bar.sh
    #!/bin/sh

    echo "bar: BAR=${BAR}"

    $ /bin/sh foo.sh
    bar: BAR=baz1
    foo: BAR=baz0
    bar: BAR=baz2
    foo: BAR=baz2
    $

Fix by saving the value of LC_ALL before the relevant set of checks in
the "idna" system test, restoring it afterwards, and dropping the
"LC_ALL=C command ..." syntax.

bin/tests/system/idna/tests.sh

index fe8ae5551d426ccaa065a11b7fe7cb3f21edf652..486216662d2ee0098302c0fec4982a2e635ee453 100644 (file)
@@ -252,16 +252,19 @@ idna_enabled_test() {
     #            is displayed as the corresponding A-label.
     #
     # The "+[no]idnout" flag has no effect in these cases.
+    saved_LC_ALL="${LC_ALL}"
+    LC_ALL="C"
     text="Checking valid A-label in C locale"
     label="xn--nxasmq6b.com"
-    if command -v idn2 >/dev/null && ! LC_ALL=C idn2 -d "$label" >/dev/null 2>/dev/null; then
-       LC_ALL=C idna_test "$text" ""                   "$label" "$label."
-       LC_ALL=C idna_test "$text" "+noidnin +noidnout" "$label" "$label."
-       LC_ALL=C idna_test "$text" "+noidnin +idnout"   "$label" "$label."
-       LC_ALL=C idna_test "$text" "+idnin +noidnout"   "$label" "$label."
-       LC_ALL=C idna_test "$text" "+idnin +idnout"     "$label" "$label."
-       LC_ALL=C idna_test "$text" "+noidnin +idnout"   "$label" "$label."
+    if command -v idn2 >/dev/null && ! idn2 -d "$label" >/dev/null 2>/dev/null; then
+       idna_test "$text" ""                   "$label" "$label."
+       idna_test "$text" "+noidnin +noidnout" "$label" "$label."
+       idna_test "$text" "+noidnin +idnout"   "$label" "$label."
+       idna_test "$text" "+idnin +noidnout"   "$label" "$label."
+       idna_test "$text" "+idnin +idnout"     "$label" "$label."
+       idna_test "$text" "+noidnin +idnout"   "$label" "$label."
     fi
+    LC_ALL="${saved_LC_ALL}"