2

I've got a daily scheduled .bat batch script that runs Fossil, and automatically commits that day's changes to my projects' source tree. Now I've set it to run every day, including the weekends, since I also want it to pick up changes that I do when working on weekends.

Usually, though, I won't be working on weekends, and so it doesn't need to commit anything for that day (since there are effectively no changes).

Now fossil has the changes command, which can tell me beforehand what changes there are. Unfortunately, it doesn't appear to set the errorlevel. It just doesn't print anything to the output stream (or perhaps a single CRLF) if there is no change.

My question: is there a way to detect the presence of output from a batch file, so I can still use the changes command to detect whether to perform a commit or not?

1 Answer 1

3

You can try using for /f statement. The syntax would be something like this:

for /f %%i in ('fossil_command_goes_here') do

Next, test %i for content and process if not empty

4
  • Thank you, I didn't know the for /f syntax for executing commands. So if I just want to perform the commit once, I can do that, then goto End, I take it?
    – Martijn
    May 31, 2011 at 14:39
  • 2
    correct. More accurately 'goto :EOF' as :EOF is defined by default for all scripts.
    – uSlackr
    May 31, 2011 at 15:53
  • 1
    I bow to you sir: I didn’t know about :EOF either — pity I can’t upvote twice... :-)
    – Martijn
    Jun 1, 2011 at 7:18
  • LOL. It only means I've written too much in the old language. Go Powershell!
    – uSlackr
    Sep 14, 2011 at 21:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .