I need to perform some operation if a target file is changed in the SVN repo. How can I test it?

More specifically, I have a local version of a doc.tex file from which I generate a doc.pdf file that is not on the server. If my local version of doc.tex file is outdated I want to copy the doc.pdf file to doc-old.pdf, than update the doc.tex, generate the new doc.pdf file and, finally, compare the two pdfs.

The only step I miss is the checking for updates of the doc.tex file on server.


The solution I adopted is:

if svn diff -r BASE:HEAD ./doc/guidelines/typesetter-guidelines.tex | grep -q ^
    then echo "Out of date"
    else echo "Updated"

Is there any contraindication? Can I do better than this?

|improve this answer|||||
  • I don't know what that svn command outputs for an up-to-date or not up-to-date file, but wouldn't grep -q ^ just return true for any output that is not empty? – Kusalananda Jun 30 '17 at 10:39
  • @Kusalananda Indeed if the files if up-to-date there will be no output. – Gabriele Nicolardi Jun 30 '17 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.