No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / format-sh-2
blobcf8bbf0f76d5a283ba3d826c5646be3d79735d07
1 #! /bin/sh
3 # Test checking of Shell format strings.
5 tmpfiles=""
6 trap 'rm -fr $tmpfiles' 1 2 3 15
8 tmpfiles="$tmpfiles f-sh-2.data"
9 cat <<\EOF > f-sh-2.data
10 # Invalid: invalid msgstr
11 msgid "abc$file"
12 msgstr "xyz$file$"
13 # Valid: same arguments, permutation
14 msgid "abc$file in $dir"
15 msgstr "xyz$dir o $file"
16 # Invalid: missing argument
17 msgid "abc$dir/$file"
18 msgstr "xyz$file"
19 # Invalid: added argument
20 msgid "abc$file"
21 msgstr "xyz$file in $dir"
22 # Valid: braces or not, doesn't matter
23 msgid "abc$file"
24 msgstr "xyz${file}"
25 # Invalid: different default value
26 msgid "abc$file"
27 msgstr "xyz${file-/tmpdir}"
28 EOF
30 : ${MSGFMT=msgfmt}
31 n=0
32 while read comment; do
33 read msgid_line
34 read msgstr_line
35 n=`expr $n + 1`
36 tmpfiles="$tmpfiles f-sh-2-$n.po f-sh-2-$n.mo"
37 cat <<EOF > f-sh-2-$n.po
38 #, sh-format
39 ${msgid_line}
40 ${msgstr_line}
41 EOF
42 fail=
43 if echo "$comment" | grep 'Valid:' > /dev/null; then
44 if ${MSGFMT} --check-format -o f-sh-2-$n.mo f-sh-2-$n.po; then
46 else
47 fail=yes
49 else
50 ${MSGFMT} --check-format -o f-sh-2-$n.mo f-sh-2-$n.po 2> /dev/null
51 if test $? = 1; then
53 else
54 fail=yes
57 if test -n "$fail"; then
58 echo "Format string checking error:" 1>&2
59 cat f-sh-2-$n.po 1>&2
60 exit 1
62 rm -f f-sh-2-$n.po f-sh-2-$n.mo
63 done < f-sh-2.data
65 rm -fr $tmpfiles
67 exit 0