I am trying to parse the output on svn info without resorting to an external shell command like sed or awk. This is purely academic as I know I could do this in a heartbeat with those tools.
Output I am parsing is:
Path: .
URL: svn://[email protected]/handbrake_batch/trunk/handbrake
Repository Root: svn://[email protected]/handbrake_batch
Repository UUID: 99c2cca7-102b-e211-ab20-02060a000c0b
Revision: 6
Node Kind: directory
Schedule: normal
Last Changed Author: ilium007
Last Changed Rev: 6
Last Changed Date: 2012-11-10 19:00:35 +1000 (Sat, 10 Nov 2012)
Here is my code:
#!/bin/bash
#set -x
OLD_IFS="$IFS"
IFS=$'\r\n'
# Get the output from svn info into an array
SVN_INFO_ARR=(`svn info`)
COUNT=0
for i in ${SVN_INFO_ARR[@]}; do
echo $COUNT
echo "$i"
(( COUNT++ ))
done
# Get the element that says "Revision: 6"
REV_ARR=${SVN_INFO_ARR[4]}
# Testing the loop over what should be a two element array
COUNT=0
for i in ${REV_ARR[@]}; do
echo $COUNT
echo "$i"
(( COUNT++ ))
done
#This should give the number 6 (or string or something)
REV_NUMBER=${REV_ARR[1]}
echo ${REV_NUMBER}
### INCREMENT REVISION NUMBER FROM ARRAY ELEMENT ###
#NEW_REV_NUMBER= ????? + 1
IFS="$OLD_IFS"
I would like to be able to take the string:
Revision: 6
and pull out the 6 and increment by 1 so I can update a release txt file to be included in the SVN commit.
I have tried to make that 6 turn into a 7 for an hour now and feel like an idiot because I can't do it.