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