Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I've created the below script and would appreciate any feedback.

# svn directory ^/tags/release/
# 1/
# 2/
# 3/
# 4/
# usage: svnnextrelease fixes email formatting 
# generated line: svn cp ^/trunk ^/tags/release/# -m'fixes email formatting'

function svnnextrelease(){
NextVersion=$(svn ls ^/tags/release | tail -n 1 | while read tag; do expr $(echo "${tag%?}") + 1; done)
# svn ls ^/tags/release, listing the directories
# tail -n 1, give me the last (latest) directory
# while loop reads result
# expr $(echo "${tag%?}") + 1, echo statment removes the "/" so 4/ becomes 4. expr then increments it.
# echo $NextVersion; 5

svn cp ^/trunk ^/tags/release/$NextVersion -m'$@'
}
share|improve this question

1 Answer

up vote 1 down vote accepted

Here is a small improvement.

svnnextrelease() {
  v=$(svn ls ^/tags/release | tail -n 1)
  svn cp ^/trunk ^/tags/release/$((${v%/} + 1 )) -m "$@"
}
  • You can use $(( )) as a replacement for expr in bash. (depends on your taste.)
  • bash can cheaply get rid of / for you.
share|improve this answer

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.