Utente:Amux/Verifica integrità repositories Mercurial

#!/bin/bash

function handleError() {
   echo "ERROE: errore (codice $1) nel repository \"$2\""
   echo -e "\n"
   [[:en:Internal field separator|IFS]]=${SAVEIFS}
   exit
}

SAVEIFS=${[[:en:Internal field separator|IFS]]}
[[:en:Internal field separator|IFS]]=$(echo -en "\n\b")

reset

for i in `find . -maxdepth 1 -mindepth 1 -type d -exec basename '{}' \;`
do
   :
   echo "Inizio controllo integrità per \"${i}\""
   hg --repository ${i} verify >/dev/null
   if [ "$?" -ne "0" ]; then
           handleError "${?}" "${i}"
   fi
   echo "OK: \"${i}\" è integro"
   echo -e "\n"
done
echo "OK: sembra che tutti i repository siano integri"

IFS=${SAVEIFS}

Si veda: en:Internal field separator.