Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a working post-commit hook bash script that syncronises a Trac instance with the latest revision for an SVN commit.

#!/bin/sh

TRAC="/var/trac/"

REPOS="$1"
REV="$2"

if [[ "$REPOS" = "*TechReader*"]]; then trac-admin $TRAC"techreader" changeset added $REPOS $REV; fi
if [[ "$REPOS" = "*InteractEnglish*"]]; then trac-admin $TRAC"interactenglish" changeset added $REPOS $REV; fi

trac-admin $TRAC"egloo" changeset added $REPOS $REV

The final trac-admin call runs and updates the internal Trac instance as desired but the if statements don't seem to fire the updates for our client instances of Trac.

The commands to sync are the same so is something wrong with the conditions?

share|improve this question
add comment

1 Answer

With some tinkering, I was able to get this to execute correctly. Note that I replaced your trac-admin calls with simple echos for testing.

#!/bin/bash

TRAC="/var/trac/"

REPOS="$1"
REV="$2"

if [[ "$REPOS" == *TechReader* ]]; then echo "first IF" $REPOS $REV; fi
if [[ "$REPOS" == *InteractEnglish* ]]; then echo "second IF" $REPOS $REV; fi

echo "done";

Changes I made

  • change bin/sh to bin/bash
  • add a space before ]]
  • remove quotes around the second arguments
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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