Pages

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)


 #!/bin/sh

 # 'poic' stands for Po Integrity Check

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

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


A friend of mine, skizzhg, proposed this alternative version and renamed it to 'poo':
 #!/bin/sh

 if [ "$1" = "" ]; then
    printf '%s\n' " Po Integrity Check"
    printf '%s\n' " No file specified. Usage: poo <file.po>"
 else
   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"; }
 fi
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)


 #!/bin/sh

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

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