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