File for development of the function ecfpc "ecfpc.bash", and "test-ecfpc.bash" to tests the function included in "annex.lib"
Fichier de mise au point de la fonction ecfpc "ecfpc.bash", et "test-ecfpc.bash" pour éprouver la fonction en librairie "annex.lib"
function ecfpc.
Development of the function
function ecfpc ()
 Projectdir=$Workdir/$Bookname
 if [ -n $Site ] && [ "$Suffix" = "compiled" ]; 
 then 
 echo "url is a version Collections."; 
 #wget https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel
 #wget $1
 cat $Lastfield | grep /$Bookname/ > beforelastfield.txt
 cat beforelastfield.txt | awk -F " " '{for (i=1;i<=NF;i++) print $i}' | grep "href=" > fieldlist.txt
 cat fieldlist.txt | sed -e "s/href=\"\/wiki\//sed -e "s/\"//g" > fieldlist2.txt
 cat fieldlist2.txt | sed -f ~/Add_appendix/datas/conversions.dat > $Bookname.$Suffix
 fi
 if test -d $Projectdir 
 then
 echo "Project directory = $Projectdir"
 if [ -r "$Projectdir/$Bookname.$Suffix" ] 
 then 
 echo -n -e "$(gettext ' \033[31mUpdate $Bookname.$Suffix ? y/n :\033[0m ')"; read -s -n1 -p "inkey : " Inkey;echo " ";
 if [ "$Inkey" = "y" ]; 
 then chmod 755 "$Projectdir/$Bookname.$Suffix"; cp "$Bookname.$Suffix" $Projectdir/.; chmod 555 "$Projectdir/$Bookname.$Suffix";
 else echo "$(gettext ' file is not updated ! ... Continue ... ')"
 fi
 else cp $Bookname.$Suffix $Projectdir/.
 fi
 fi
test-ecfpc.bash "with function in annex.lib".
Version=210415
clear
echo "ecfpc.sh $Version for testing ecfpc in annex.lib"
 Site=""
 Bookname=""
 Suffix=""
 Return_value="non available"
 pwd > pwd.txt
 read Currentdir < pwd.txt
 echo -n "/" > homedir.txt
 cat pwd.txt | head -n 3 | cut -d '/' -f 2-3 » homedir.txt
 read Homedir < homedir.txt
 echo -n "/" > workdir.txt
 cat pwd.txt | head -n 4 | cut -d '/' -f 2-4 » workdir.txt
 read Workdir < workdir.txt
 # rm pwd.txt homedir.txt workdir.txt
 echo "Current directory = $Currentdir"
 echo ""
 echo "Home directory = $Homedir"
 echo ""
 echo "Working directory = $Workdir"
 if test -a /usr/local/lib/annex.lib; then Libdir=/usr/local/lib; Bindir=/usr/local/bin; Sharedir=/usr/local/share
 elif test -a $Workdir/lib/annex.lib; then Libdir=$Workdir/lib; Bindir=Workdir/bin; Sharedir=$Workdir/share
 elif test -a $Workdir/tests/1-annex.lib/annex.lib; then Libdir=$Workdir/tests/1-annex.lib/
 else echo "Lib directory is not found, exit -1"; exit -1
 fi
 if test -a $Workdir/datas/conversions.dat; then Datadir=$Workdir/datas; else echo "Datas directory is not found in $Workdir/datas"; fi
 echo -n "Working directory = $Workdir"
 if [ -d $Workdir ]; then echo " found"; else echo "notfound";fi
 echo -n "Lib directory = $Libdir"
 if [ -d $Libdir ]; then echo " found"; else echo "notfound";fi
 echo -n "bin directory = $Bindir"
 if [ -d $Bindir ]; then echo " found"; else echo "notfound";fi
 echo -n "share directory = $Sharedir"
 if [ -d $Sharedir ]; then echo " found"; else echo "notfound";fi
 echo "----"
 clear 
 #if test -a function_ecfpc ; then source function_ecfpc; echo "function ecfpc is in current directory";fi
 source $Libdir/annex.lib
 #if test -z $1; then echo "Syntax : ecfpc <book url> or ./ecfpc <book url>"; exit 1; fi
 #ecfpc https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_fleurir_le_sel
 echo "Test for $1"
 findbook $1
 Bookfullurl=$1
 echo ""
 echo "* Bookfullurl: "$Bookfullurl
 echo "* mw book url: "$MWbookurl
 echo "* Site name : "$Site
 echo "* Last field : "$Lastfield
 echo "* Bookname : "$Bookname
 echo "* Suffix : "$Suffix
 echo "* Bookname.Suffix : "$Bookname.$Suffix
 ecfpc $1
 if [ $0="./ecfpc.sh" ] || [ $0="$Testsdir/1-annex.lib/13-ecfpc/ecfpc.sh" ]; then echo "$Bookname.$Suffix :"; cat $Bookname.$Suffix; fi