echo -e. The escape sequence was not putting \end into the document.
To avoid compatibility issues between 'dash' and a real 'sh'
we will use printf
# We drop bad lines "\end{document}" generated by dblatex
grep -vE '^(\\end{document}|\\subsection\*)$$' slony-tmp.tex > slony.tex
# We put the required '\end{document}' at the end of the Tex file
- echo "\end{document}" >> slony.tex
+ printf '\\end{document}' >> slony.tex
# Latex required to run the following command 3 times in order to generating the TOC of the document
pdflatex slony.tex
pdflatex slony.tex