| #!/bin/bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| function cli_getRepoName { |
| |
| |
| local ARGSS='f,d' |
| |
| |
| local ARGSL='basename,dirname' |
| |
| |
| |
| local ARGUMENTS='' |
| |
| |
| cli_parseArgumentsReDef "$@" |
| |
| |
| cli_parseArguments |
| |
| |
| eval set -- "$ARGUMENTS" |
| |
| |
| local NAME=$(echo $@ | sed -r 's!^.*--[[:space:]](.+)$!\1!') |
| |
| |
| while true;do |
| |
| case "$1" in |
| |
| -f|--basename ) |
| |
| |
| |
| |
| NAME=$(basename $NAME) |
| |
| |
| NAME=$(echo $NAME \ |
| | tr -s ' ' '_' \ |
| | tr '[:upper:]' '[:lower:]') |
| |
| shift 1 |
| ;; |
| |
| -d|--dirname ) |
| |
| local DIR='' |
| local DIRS='' |
| local CLEANDIRS='' |
| local PREFIXDIR='' |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| if [[ $NAME =~ '.+/.+' ]];then |
| |
| |
| |
| |
| |
| |
| |
| |
| PREFIXDIR=$(echo $NAME \ |
| | sed -r "s,^(($(cli_getRepoTLDir)/)?(trunk|branches|tags)/).+$,\1,") |
| |
| |
| |
| DIRS=$(dirname "$NAME" \ |
| | sed -r "s!^${PREFIXDIR}!!" \ |
| | tr '/' ' ') |
| |
| else |
| |
| |
| |
| |
| DIRS=$NAME |
| |
| fi |
| |
| for DIR in $DIRS;do |
| |
| |
| if [[ $DIR =~ '^[a-z]' ]];then |
| DIR=$(echo ${DIR} \ |
| | tr -s ' ' '_' \ |
| | tr '[:upper:]' '[:lower:]' \ |
| | sed -r 's/^([[:alpha:]])/\u\1/') |
| fi |
| |
| |
| CLEANDIRS="${CLEANDIRS}/$DIR" |
| |
| done |
| |
| |
| NAME=$(echo ${CLEANDIRS} | sed -r "s!^/!!") |
| |
| |
| |
| if [[ "$PREFIXDIR" != '' ]];then |
| NAME=${PREFIXDIR}${NAME} |
| fi |
| |
| shift 1 |
| ;; |
| |
| -- ) |
| shift 1 |
| break |
| ;; |
| |
| esac |
| |
| done |
| |
| |
| echo $NAME |
| |
| } |