user3122648
user3122648

Reputation: 917

How to check if a file is changed in svn and decide the next action based on it in a script

I want to write a bash script That if a file is changed then I commit. is there a command that returns true or false so That I can check it in my "If the file is changed?"

I have:

if ???

svn --trust-server-cert --non-interactive --username MYUSERNAME --password MYPASSWORD commit . -m "MY COMMENT"`;

I created a .sh file and here is the content just to test what svn status is returning and even if there is no change to the file it returns "$SVNST is NOT empty":

#!/bin/bash
echo "Hello world"
SVNST=$`svn status MYFILE`
echo $SVNST
if [ -z "$SVNST" ]
then
      echo "\$SVNST is empty"
else
      echo "\$SVNST is NOT empty"
fi

Upvotes: 0

Views: 315

Answers (1)

zb226
zb226

Reputation: 10500

You have an extra $ before the svn invocation, which results in your -z zero check always being false, because there is always that $ at the beginning of $SVNST. Change:

SVNST=$`svn status MYFILE`

to:

SVNST=`svn status MYFILE`

and your script will work as you intended it.

Upvotes: 1

Related Questions