3
\$\begingroup\$

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'$@'
}
\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

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.
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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