Simplify echo code

This commit is contained in:
Andrius Štikonas 2008-10-15 09:55:06 +03:00
parent 275a27f84a
commit b93bb5328e
1 changed files with 85 additions and 82 deletions

View File

@ -40,59 +40,58 @@ for BRANCH in $TRUNK $BRANCHES; do
nerror=0; nwarn=0; npo=0; nt=0; nu=0; nf=0 nerror=0; nwarn=0; npo=0; nt=0; nu=0; nf=0
rm -f $STATSFILE rm -f $STATSFILE
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"" >> $STATSFILE echo -e "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
echo "\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">" >> $STATSFILE \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">" >> $STATSFILE <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">
echo "<head>" >> $STATSFILE <head>
echo " <meta http-equiv=\"content-type\" content=\"application/xhtml+xml; charset=utf-8\" />" >> $STATSFILE <meta http-equiv=\"content-type\" content=\"application/xhtml+xml; charset=utf-8\" />
<link rel=\"shortcut icon\" type=\"image/png\" href=\"http://www.wesnoth.org/mw/skins/glamdrol/ico.png\" />
echo " <link rel=\"shortcut icon\" type=\"image/png\" href=\"http://www.wesnoth.org/mw/skins/glamdrol/ico.png\" />" >> $STATSFILE <style type=\"text/css\">@import url('http://www.wesnoth.org/mw/skins/glamdrol/main.css');</style>
echo " <style type=\"text/css\">@import url('http://www.wesnoth.org/mw/skins/glamdrol/main.css');</style>" >> $STATSFILE <link rel=\"stylesheet\" type=\"text/css\" href=\"http://gettext.wesnoth.org/styles/old.css\" />
echo " <link rel=\"stylesheet\" type=\"text/css\" href=\"http://gettext.wesnoth.org/styles/old.css\" />" >> $STATSFILE <title>Battle for Wesnoth</title>
echo " <title>Battle for Wesnoth</title>" >> $STATSFILE </head>
echo "</head>" >> $STATSFILE <body>
echo "<body>" >> $STATSFILE
echo "" >> $STATSFILE <div id=\"global\">
echo "<div id=\"global\">" >> $STATSFILE <div id=\"header\">
echo "<div id=\"header\">" >> $STATSFILE <div id=\"logo\">
echo " <div id=\"logo\">" >> $STATSFILE <a href=\"http://www.wesnoth.org/\"><img alt=\"Wesnoth logo\" src=\"http://www.wesnoth.org/mw/skins/glamdrol/wesnoth-logo.jpg\" /></a>
echo " <a href=\"http://www.wesnoth.org/\"><img alt=\"Wesnoth logo\" src=\"http://www.wesnoth.org/mw/skins/glamdrol/wesnoth-logo.jpg\" /></a>" >> $STATSFILE </div>
echo " </div>" >> $STATSFILE </div>
echo "</div>" >> $STATSFILE
echo "" >> $STATSFILE <div id=\"nav\">
echo "<div id=\"nav\">" >> $STATSFILE <ul>
echo "<ul>" >> $STATSFILE <li><a href=\"http://www.wesnoth.org/\">Home</a></li>
echo " <li><a href=\"http://www.wesnoth.org/\">Home</a></li>" >> $STATSFILE <li><a href=\"http://www.wesnoth.org/wiki/Play\">Play</a></li>
echo " <li><a href=\"http://www.wesnoth.org/wiki/Play\">Play</a></li>" >> $STATSFILE
echo "" >> $STATSFILE <li><a href=\"http://www.wesnoth.org/wiki/Create\">Create</a></li>
echo " <li><a href=\"http://www.wesnoth.org/wiki/Create\">Create</a></li>" >> $STATSFILE <li><a href=\"http://www.wesnoth.org/forum/\">Forums</a></li>
echo " <li><a href=\"http://www.wesnoth.org/forum/\">Forums</a></li>" >> $STATSFILE <li><a href=\"http://www.wesnoth.org/wiki/Support\">Support</a></li>
echo " <li><a href=\"http://www.wesnoth.org/wiki/Support\">Support</a></li>" >> $STATSFILE <li><a href=\"http://www.wesnoth.org/wiki/Project\">Project</a></li>
echo " <li><a href=\"http://www.wesnoth.org/wiki/Project\">Project</a></li>" >> $STATSFILE <li><a href=\"http://www.wesnoth.org/wiki/Credits\">Credits</a></li>
echo " <li><a href=\"http://www.wesnoth.org/wiki/Credits\">Credits</a></li>" >> $STATSFILE </ul>
echo "</ul>" >> $STATSFILE </div>
echo "</div>" >> $STATSFILE
echo "" >> $STATSFILE <h2 style=\"display:inline\">Wesnoth translation stats</h2>
echo "<h2 style=\"display:inline\">Wesnoth translation stats</h2>" >> $STATSFILE <div> <br/> </div><p style=\"display:inline\">Last update: <strong>
echo "<div> <br/> </div><p style=\"display:inline\">Last update: <strong>" >> $STATSFILE `LC_TIME="en_US.UTF-8" date`
LC_TIME="en_US.UTF-8" date >> $STATSFILE </strong></p>
echo "</strong></p>" >> $STATSFILE <div> <br/> </div>
echo "<div> <br/> </div>" >> $STATSFILE <table class=\"main\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\"><tr><td>
echo "<table class=\"main\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\"><tr><td>" >> $STATSFILE <table cellspacing=\"1\" cellpadding=\"2\" border=\"0\" width=\"100%\">
echo "<table cellspacing=\"1\" cellpadding=\"2\" border=\"0\" width=\"100%\">" >> $STATSFILE <tr class=\"header\">
echo "<tr class=\"header\">" >> $STATSFILE <td class=\"title\">File</td>
echo "<td class=\"title\">File</td>" >> $STATSFILE <td class=\"title\" align=\"center\">Status</td>
echo "<td class=\"title\" align=\"center\">Status</td>" >> $STATSFILE <td class=\"translated\">translated</td>
echo "<td class=\"translated\">translated</td>" >> $STATSFILE <td class=\"translated\"><strong>%</strong></td>
echo "<td class=\"translated\"><strong>%</strong></td>" >> $STATSFILE
echo "" >> $STATSFILE <td class=\"fuzzy\"><strong>fuzzy</strong></td>
echo "<td class=\"fuzzy\"><strong>fuzzy</strong></td>" >> $STATSFILE <td class=\"fuzzy\"><strong>%</strong></td>
echo "<td class=\"fuzzy\"><strong>%</strong></td>" >> $STATSFILE <td class=\"untranslated\"><strong>untranslated</strong></td>
echo "<td class=\"untranslated\"><strong>untranslated</strong></td>" >> $STATSFILE <td class=\"untranslated\"><strong>%</strong></td>
echo "<td class=\"untranslated\"><strong>%</strong></td>" >> $STATSFILE <td class=\"title\">total</td>
echo "<td class=\"title\">total</td>" >> $STATSFILE <td class=\"title\">graph</td>
echo "<td class=\"title\">graph</td>" >> $STATSFILE </tr>" >> $STATSFILE
echo "</tr>" >> $STATSFILE
for dir in `ls $BRANCH/wesnoth* -d`; do for dir in `ls $BRANCH/wesnoth* -d`; do
file=$DIR"/"`basename $dir`"."$LCODE".po"; file=$DIR"/"`basename $dir`"."$LCODE".po";
@ -189,9 +188,9 @@ for BRANCH in $TRUNK $BRANCHES; do
echo "<tr class=\"row-$CL\">" >> $STATSFILE echo "<tr class=\"row-$CL\">" >> $STATSFILE
CL=$(( ($CL+1)%2 )) CL=$(( ($CL+1)%2 ))
echo " <td align=\"left\"><strong>`basename $filename`</strong></td>" >> $STATSFILE echo " <td align=\"left\"><strong>`basename $filename`</strong></td>
echo " <td class=\"percentage-$CL\" align=\"center\">$st</td>" >> $STATSFILE <td class=\"percentage-$CL\" align=\"center\">$st</td>
echo " <td class=\"row-$CL\" align=\"right\">$t</td>" >> $STATSFILE <td class=\"row-$CL\" align=\"right\">$t</td>" >> $STATSFILE
printf '%s%d%s%.2f%s\n' " <td class=\"percentage-" $CL "\" align=\"right\">" $rt "</td>" >> $STATSFILE printf '%s%d%s%.2f%s\n' " <td class=\"percentage-" $CL "\" align=\"right\">" $rt "</td>" >> $STATSFILE
echo " <td class=\"row-$CL\" align=\"right\">$f</td>" >> $STATSFILE echo " <td class=\"row-$CL\" align=\"right\">$f</td>" >> $STATSFILE
printf '%s%d%s%.2f%s\n' " <td class=\"percentage-" $CL "\" align=\"right\">" $rf "</td>" >> $STATSFILE printf '%s%d%s%.2f%s\n' " <td class=\"percentage-" $CL "\" align=\"right\">" $rf "</td>" >> $STATSFILE
@ -213,31 +212,35 @@ for BRANCH in $TRUNK $BRANCHES; do
if [ "$nerror" -gt 0 ]; then if [ "$nerror" -gt 0 ]; then
echo -n -e "\E[31mFatal errors found. See '" echo -n -e "\E[31mFatal errors found. See '"
tput smso; echo -n "$ERRORS"; tput rmso tput smso; echo -n "$ERRORS"; tput rmso
echo -e "' for details."; tput sgr0 echo -ne "' for details."; tput sgr0
echo ""
else else
echo -e "\E[32mNo fatal errors found."; tput sgr0 echo -ne "\E[32mNo fatal errors found."; tput sgr0
echo ""
if [ -s "$ERRORS" ]; then if [ -s "$ERRORS" ]; then
echo -n -e "\E[31m See '" echo -n -e "\E[31m See '"
tput smso; echo -n "$ERRORS"; tput rmso tput smso; echo -n "$ERRORS"; tput rmso
echo -e "' for warnings."; tput sgr0 echo -ne "' for warnings."; tput sgr0
echo ""
else else
rm -f $ERRORS rm -f $ERRORS
fi fi
fi fi
if [ "$npo" = "$nerror" ]; then if [ "$npo" = "$nerror" ]; then
echo -e "\E[31mAll files have fatal errors."; tput sgr0 echo -en "\E[31mAll files have fatal errors."; tput sgr0
echo ""
else else
sum=$((${nt} + ${nf} + ${nu})) sum=$((${nt} + ${nf} + ${nu}))
nrt=`printf '%s%d%s%d\n' "scale=2; 100*" $nt "/" $sum | bc` nrt=`printf '%s%d%s%d\n' "scale=2; 100*" $nt "/" $sum | bc`
nrf=`printf '%s%d%s%d\n' "scale=2; 100*" $nf "/" $sum | bc` nrf=`printf '%s%d%s%d\n' "scale=2; 100*" $nf "/" $sum | bc`
nru=`printf '%s%d%s%d\n' "scale=2; 100*" $nu "/" $sum | bc` nru=`printf '%s%d%s%d\n' "scale=2; 100*" $nu "/" $sum | bc`
echo "<tr class=\"title\">" >> $STATSFILE echo "<tr class=\"title\">
echo "<td align=\"left\"><strong>Total</strong></td>" >> $STATSFILE <td align=\"left\"><strong>Total</strong></td>
echo "<td align=\"center\"><strong>$STATUS</strong></td>" >> $STATSFILE <td align=\"center\"><strong>$STATUS</strong></td>
echo "<td align=\"right\"><strong>$nt</strong></td>" >> $STATSFILE <td align=\"right\"><strong>$nt</strong></td>" >> $STATSFILE
printf '%s%.2f%s\n' "<td align=\"right\"><strong>" $nrt "</strong></td>" >> $STATSFILE printf '%s%.2f%s\n' "<td align=\"right\"><strong>" $nrt "</strong></td>" >> $STATSFILE
echo "<td align=\"right\"><strong>$nf</strong></td>" >> $STATSFILE echo "<td align=\"right\"><strong>$nf</strong></td>" >> $STATSFILE
printf '%s%.2f%s\n' "<td align=\"right\"><strong>" $nrf "</strong></td>" >> $STATSFILE printf '%s%.2f%s\n' "<td align=\"right\"><strong>" $nrf "</strong></td>" >> $STATSFILE
@ -250,24 +253,24 @@ for BRANCH in $TRUNK $BRANCHES; do
nru=`printf '%s%f\n' "scale=2; 3*" $nru | bc` nru=`printf '%s%f\n' "scale=2; 3*" $nru | bc`
printf '%s%.2f%s%.2f%s%.2f%s\n' "<td><img src=\"http://gettext.wesnoth.org/images/green.png\" height=\"15\" width=\"" $nrt "\" alt=\"translated\"/><img src=\"http://gettext.wesnoth.org/images/blue.png\" height=\"15\" width=\"" $nrf "\" alt=\"fuzzy\"/><img src=\"http://gettext.wesnoth.org/images/red.png\" height=\"15\" width=\"" $nru "\" alt=\"untranslated\"/></td>" >> $STATSFILE printf '%s%.2f%s%.2f%s%.2f%s\n' "<td><img src=\"http://gettext.wesnoth.org/images/green.png\" height=\"15\" width=\"" $nrt "\" alt=\"translated\"/><img src=\"http://gettext.wesnoth.org/images/blue.png\" height=\"15\" width=\"" $nrf "\" alt=\"fuzzy\"/><img src=\"http://gettext.wesnoth.org/images/red.png\" height=\"15\" width=\"" $nru "\" alt=\"untranslated\"/></td>" >> $STATSFILE
echo "</tr>" >> $STATSFILE echo "</tr>
echo "</table>" >> $STATSFILE </table>
echo "</td>" >> $STATSFILE </td>
echo "</tr>" >> $STATSFILE </tr>
echo "</table>" >> $STATSFILE </table>
echo "<div> <br/> </div>" >> $STATSFILE <div> <br/> </div>
echo "<div id=\"footer\">" >> $STATSFILE <div id=\"footer\">
echo "" >> $STATSFILE
echo "<div id=\"footnote\">" >> $STATSFILE <div id=\"footnote\">
echo "&copy; 2003-"`date +%Y`" The Battle for Wesnoth<br/>" >> $STATSFILE &copy; 2003-"`date +%Y`" The Battle for Wesnoth<br/>
echo "<br/>" >> $STATSFILE <br/>
echo "<a href=\"http://validator.w3.org/check?uri=referer\"><img src=\"http://www.w3.org/Icons/valid-xhtml11-blue\"" >> $STATSFILE <a href=\"http://validator.w3.org/check?uri=referer\"><img src=\"http://www.w3.org/Icons/valid-xhtml11-blue\"
echo "alt=\"Valid XHTML 1.1!\" height=\"31\" width=\"88\" /></a>" >> $STATSFILE alt=\"Valid XHTML 1.1!\" height=\"31\" width=\"88\" /></a>
echo "</div>" >> $STATSFILE </div>
echo "</div>" >> $STATSFILE </div>
echo "</div>" >> $STATSFILE </div>
echo "</body>" >> $STATSFILE </body>
echo "</html>" >> $STATSFILE </html>" >> $STATSFILE
fi fi
done done