1#! /bin/sh 2. "${srcdir=.}/init.sh"; path_prepend_ . ../src 3 4# Test checking of Shell format strings. 5 6cat <<\EOF > f-sh-2.data 7# Invalid: invalid msgstr 8msgid "abc$file" 9msgstr "xyz$file$" 10# Valid: same arguments, permutation 11msgid "abc$file in $dir" 12msgstr "xyz$dir o $file" 13# Invalid: missing argument 14msgid "abc$dir/$file" 15msgstr "xyz$file" 16# Invalid: added argument 17msgid "abc$file" 18msgstr "xyz$file in $dir" 19# Valid: braces or not, doesn't matter 20msgid "abc$file" 21msgstr "xyz${file}" 22# Invalid: different default value 23msgid "abc$file" 24msgstr "xyz${file-/tmpdir}" 25EOF 26 27: ${MSGFMT=msgfmt} 28n=0 29while read comment; do 30 read msgid_line 31 read msgstr_line 32 n=`expr $n + 1` 33 cat <<EOF > f-sh-2-$n.po 34#, sh-format 35${msgid_line} 36${msgstr_line} 37EOF 38 fail= 39 if echo "$comment" | grep 'Valid:' > /dev/null; then 40 if ${MSGFMT} --check-format -o f-sh-2-$n.mo f-sh-2-$n.po; then 41 : 42 else 43 fail=yes 44 fi 45 else 46 ${MSGFMT} --check-format -o f-sh-2-$n.mo f-sh-2-$n.po 2> /dev/null 47 if test $? = 1; then 48 : 49 else 50 fail=yes 51 fi 52 fi 53 if test -n "$fail"; then 54 echo "Format string checking error:" 1>&2 55 cat f-sh-2-$n.po 1>&2 56 Exit 1 57 fi 58 rm -f f-sh-2-$n.po f-sh-2-$n.mo 59done < f-sh-2.data 60 61Exit 0 62