1# Note: this test depends on strerror() using locale. 2 3failures=0 4 5check() { 6 if ! eval "[ $1 ]"; then 7 echo "Failed: $1 at $2" 8 : $((failures += 1)) 9 fi 10} 11 12unset LANG LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC LC_TIME LC_MESSAGES 13unset LANGUAGE 14 15msgeng="No such file or directory" 16msgdut="Bestand of map niet gevonden" 17 18# Verify C locale error message. 19case $(command . /var/empty/foo 2>&1) in 20 *"$msgeng"*) ok=1 ;; 21 *) ok=0 ;; 22esac 23check '$ok -eq 1' $LINENO 24 25# Various locale variables that should not affect the message. 26case $(LC_ALL=C command . /var/empty/foo 2>&1) in 27 *"$msgeng"*) ok=1 ;; 28 *) ok=0 ;; 29esac 30check '$ok -eq 1' $LINENO 31 32case $(LC_ALL=C LANG=nl_NL.ISO8859-1 command . /var/empty/foo 2>&1) in 33 *"$msgeng"*) ok=1 ;; 34 *) ok=0 ;; 35esac 36check '$ok -eq 1' $LINENO 37 38case $(LC_ALL=C LC_MESSAGES=nl_NL.ISO8859-1 command . /var/empty/foo 2>&1) in 39 *"$msgeng"*) ok=1 ;; 40 *) ok=0 ;; 41esac 42check '$ok -eq 1' $LINENO 43 44case $(LC_CTYPE=nl_NL.ISO8859-1 command . /var/empty/foo 2>&1) in 45 *"$msgeng"*) ok=1 ;; 46 *) ok=0 ;; 47esac 48check '$ok -eq 1' $LINENO 49 50# Verify Dutch message. 51case $(export LANG=nl_NL.ISO8859-1; command . /var/empty/foo 2>&1) in 52 *"$msgdut"*) ok=1 ;; 53 *) ok=0 ;; 54esac 55check '$ok -eq 1' $LINENO 56 57case $(export LC_MESSAGES=nl_NL.ISO8859-1; command . /var/empty/foo 2>&1) in 58 *"$msgdut"*) ok=1 ;; 59 *) ok=0 ;; 60esac 61check '$ok -eq 1' $LINENO 62 63case $(export LC_ALL=nl_NL.ISO8859-1; command . /var/empty/foo 2>&1) in 64 *"$msgdut"*) ok=1 ;; 65 *) ok=0 ;; 66esac 67check '$ok -eq 1' $LINENO 68 69case $(LANG=nl_NL.ISO8859-1 command . /var/empty/foo 2>&1) in 70 *"$msgdut"*) ok=1 ;; 71 *) ok=0 ;; 72esac 73check '$ok -eq 1' $LINENO 74 75case $(LC_MESSAGES=nl_NL.ISO8859-1 command . /var/empty/foo 2>&1) in 76 *"$msgdut"*) ok=1 ;; 77 *) ok=0 ;; 78esac 79check '$ok -eq 1' $LINENO 80 81case $(LC_ALL=nl_NL.ISO8859-1 command . /var/empty/foo 2>&1) in 82 *"$msgdut"*) ok=1 ;; 83 *) ok=0 ;; 84esac 85check '$ok -eq 1' $LINENO 86 87# Verify that command assignments do not set the locale persistently. 88case $(command . /var/empty/foo 2>&1) in 89 *"$msgeng"*) ok=1 ;; 90 *) ok=0 ;; 91esac 92check '$ok -eq 1' $LINENO 93 94case $(LANG=nl_NL.ISO8859-1 command . /var/empty/foo 2>&1; command . /var/empty/foo 2>&1) in 95 *"$msgdut"*"$msgeng"*) ok=1 ;; 96 *) ok=0 ;; 97esac 98check '$ok -eq 1' $LINENO 99 100case $(LC_MESSAGES=nl_NL.ISO8859-1 command . /var/empty/foo 2>&1; command . /var/empty/foo 2>&1) in 101 *"$msgdut"*"$msgeng"*) ok=1 ;; 102 *) ok=0 ;; 103esac 104check '$ok -eq 1' $LINENO 105 106case $(LC_ALL=nl_NL.ISO8859-1 command . /var/empty/foo 2>&1; command . /var/empty/foo 2>&1) in 107 *"$msgdut"*"$msgeng"*) ok=1 ;; 108 *) ok=0 ;; 109esac 110check '$ok -eq 1' $LINENO 111 112# Check special builtin; add colon invocation to avoid depending on certain fix. 113case $(LC_ALL=nl_NL.ISO8859-1 . /var/empty/foo 2>&1; :) in 114 *"$msgdut"*) ok=1 ;; 115 *) ok=0 ;; 116esac 117check '$ok -eq 1' $LINENO 118 119# Assignments on special builtins are exported to that builtin; the export 120# is not persistent. 121case $(LC_ALL=nl_NL.ISO8859-1 . /dev/null; . /var/empty/foo 2>&1) in 122 *"$msgeng"*) ok=1 ;; 123 *) ok=0 ;; 124esac 125check '$ok -eq 1' $LINENO 126 127case $(export LC_ALL; LC_ALL=nl_NL.ISO8859-1 . /dev/null; . /var/empty/foo 2>&1) in 128 *"$msgdut"*) ok=1 ;; 129 *) ok=0 ;; 130esac 131check '$ok -eq 1' $LINENO 132 133exit $((failures > 0)) 134