svn - How to pass array of arguments in shell script? -
right have working script pass 2 arguments shell script. script takes ticket# , svn url arguments on command line , gives output of revisions have been changed associated ticket# (in svn comments).
#!/bin/sh jira_ticket=$1 src_url=$2 revs=(`svn log $2 --stop-on-copy | grep -b 2 $1 | grep "^r" | cut -d"r" -f2 | cut -d" " -f1| sort`) revisions in ${!revs[*]} printf "%s %s\n" ${revs[$revisions]} done
output:
4738 4739 4743 4744 4745
i need pass array of arguments - meaning more 1 ticket# , give output of revisions associated ticket numbers passed args script.
i don't think posix shell has arrays, plain , use #!/bin/bash
i put url first arg, , reset tickets
#!/bin/bash revs=() src_url=$1 svn_log=$(svn log "$src_url" --stop-on-copy) shift jira_ticket in "$@"; revs+=( $(grep -b 2 "$jira_ticket" <<< "$svn_log" | grep "^r" | cut -d"r" -f2 | cut -d" " -f1) ) done revisions in $( printf "%s\n" "${!revs[@]}" | sort ) printf "%s %s\n" ${revs[$revisions]} done
Comments
Post a Comment