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