I am attempting to use the 'entr' command to automatically compile Groff documents.
I wish to run the following line:
refer references.bib $1 | groff -ms $1 -T pdf > $2
Sadly it will only compile once if I try this:
echo $1 | entr refer references.bib $1 | groff -ms $1 -T pdf > $2
I have also tried the following, but it creates an infinite loop that cant be exited with Ctrl+C:
compile(){
refer references.bib $1 | groff -ms $1 -T pdf > $2
}
while true; do
compile $1 $2
echo $1 | entr -pd -s 'kill $PPID'
done
What is the correct way of doing this?
I didn't try this because I didn't want to install
entr. But I think the following should work:Note that we run the pipe
refer | groffin a shell to group it together. The command from your question without the shell runsreferupon file change, butgroffonly once. Inentr ... | groffthegroffpart isn't executed byentr, but bybashin parallel.This command works only if
$1and$2do not contain special symbols like spaces,*, or$. The correct way to handle these arguments would be ...