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'$@'
}
palacsint
30.3k9 gold badges82 silver badges157 bronze badges
asked Aug 17, 2012 at 15:38
\$\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.
answered Aug 18, 2012 at 5:05
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.