No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / format-sh-1
blob6bbb32f9537d109efb798829386980a9680e68ab
1 #! /bin/sh
3 # Test recognition of Shell format strings.
5 tmpfiles=""
6 trap 'rm -fr $tmpfiles' 1 2 3 15
8 tmpfiles="$tmpfiles f-sh-1.data"
9 cat <<\EOF > f-sh-1.data
10 # Invalid: no argument
11 "abc"
12 # Valid: one argument
13 "abc$file"
14 # Valid: one argument
15 "abc$f_x"
16 # Invalid: context dependent variable
17 "abc$0"
18 # Invalid: context dependent variable
19 "abc$$"
20 # Invalid: complex shell syntax
21 "abc${tmpdir-/tmp}"
22 # Invalid: unterminated
23 "abc$"
24 # Invalid: unterminated name
25 "abc${A"
26 # Invalid: non-ASCII character
27 "abc$ß"
28 # Invalid: non-ASCII character
29 "abc${ß}"
30 # Invalid: an empty name
31 "abc${}"
32 # Valid: three arguments
33 "abc$dir$file"
34 # Valid: three arguments, two with equal names
35 "abc$addr$char$addr"
36 EOF
38 : ${XGETTEXT=xgettext}
39 n=0
40 while read comment; do
41 read string
42 n=`expr $n + 1`
43 tmpfiles="$tmpfiles f-sh-1-$n.in f-sh-1-$n.po"
44 sed -e 's,\$,\\$,g' <<EOF > f-sh-1-$n.in
45 gettext ${string};
46 EOF
47 ${XGETTEXT} -L Shell --from-code=ISO-8859-1 -o f-sh-1-$n.po f-sh-1-$n.in || exit 1
48 test -f f-sh-1-$n.po || exit 1
49 fail=
50 if echo "$comment" | grep 'Valid:' > /dev/null; then
51 if grep sh-format f-sh-1-$n.po > /dev/null; then
53 else
54 fail=yes
56 else
57 if grep sh-format f-sh-1-$n.po > /dev/null; then
58 fail=yes
59 else
63 if test -n "$fail"; then
64 echo "Format string recognition error:" 1>&2
65 cat f-sh-1-$n.in 1>&2
66 echo "Got:" 1>&2
67 cat f-sh-1-$n.po 1>&2
68 exit 1
70 rm -f f-sh-1-$n.in f-sh-1-$n.po
71 done < f-sh-1.data
73 rm -fr $tmpfiles
75 exit 0