| #!/bin/bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| function cli_getRepoName { |
| |
| local NAME="$1" |
| local TYPE="$2" |
| local DIRS='' |
| local DIR='' |
| local CLEANDIRS='' |
| local PREFIXDIR='' |
| |
| case $TYPE in |
| |
| 'f' | 'basename' ) |
| |
| |
| |
| |
| NAME=$(basename $NAME) |
| |
| |
| NAME=$(echo $NAME \ |
| | tr -s ' ' '_' \ |
| | tr '[:upper:]' '[:lower:]') |
| ;; |
| |
| 'd' | 'dirname' ) |
| |
| |
| |
| |
| |
| |
| |
| if [[ $NAME =~ '.+/.+' ]];then |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| PREFIXDIR=$(echo $NAME \ |
| | sed -r "s,^((${HOME}/artwork/)?(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 |
| ;; |
| |
| 'fd' | 'basename-to-dirname' ) |
| |
| |
| NAME=$(cli_getRepoName $NAME 'f') |
| |
| |
| NAME=$(cli_getRepoName $NAME 'd') |
| ;; |
| |
| 'df' | 'dirname-to-basename' ) |
| |
| |
| NAME=$(cli_getRepoName $NAME 'd') |
| |
| |
| NAME=$(cli_getRepoName $NAME 'f') |
| ;; |
| |
| 'dfd' | 'dirname-to-basename-to-dirname' ) |
| |
| |
| NAME=$(cli_getRepoName $NAME 'd') |
| |
| |
| NAME=$(cli_getRepoName $NAME 'f') |
| |
| |
| NAME=$(cli_getRepoName $NAME 'd') |
| ;; |
| esac |
| |
| |
| echo $NAME |
| |
| } |