29 July 2012

poic and poo

I published this script I wrote for personal use several weeks ago in my gopher hole concretely in the phlog but I decided to include it here under the scripts tag for an easy reference.

Credits go to Robby for his extraordinary suggestion of:

 "This .po file is 'poo'"

I must confess I'm still laughing at it every time I think about it but hopefully I will not get that message very often.

Here is the script:

(As you can see the usage is:  ~$ poic file.po)


 # 'poic' stands for Po Integrity Check

 msgfmt --verbose --check --output-file=/dev/null $1

 if [ "$?" -eq "0" ]
      echo ""
      echo "This .po file is 'good': $(echo $1)"
 elif [ "$?" -ne "0" ]
      echo ""
      echo "This .po file is 'poo': $(echo $1)"

A friend of mine, skizzhg, proposed this alternative version and renamed it to 'poo':

 if [ "$1" = "" ]; then
    printf '%s\n' " Po Integrity Check"
    printf '%s\n' " No file specified. Usage: poo <file.po>"
   msgfmt --verbose --check --output-file=/dev/null "$1" && \
   { printf "\n This .po file is 'good': $1 \n"; } || \
   { printf "\n This .po file is 'poo': $1 \n"; }
I think that skizzhg's version is cleverer than mine and also more complete because it includes information about the script and usage notes.
If you think that 'poo' is not a very nice name be aware that it could perfectly stand for "PO Officer" ;-)
Thank you very much skizzhg. You rock!

Another friend proposed this other version. Let's call it poo2 (His suggestion)


 if [ -z "$1" ]; then
     echo ' Po Integrity Check'
     echo ' No file specified. Usage: poo2 <file.po>'
     exit 1

 if msgfmt --verbose --check --output-file=/dev/null "$1";then
 printf "\n This .po file is '%s': %s \n" "$status" "$1"
Thanks :-)