Blame Scripts/Bash/Functions/cli_getRepoName.sh

4c79b5
#!/bin/bash
4c79b5
#
4c79b5
# cli_getRepoName.sh -- This function sets naming convenction. Inside
4c79b5
# CentOS Artowrk Repository, regular files are written in lower case
4c79b5
# and directories are written in lower case but with the first letter
ae8a10
# in upper case. Use this function to sanitate the name of regular
4c79b5
# files and directories you work with.
4c79b5
#
4c79b5
# Copyright (C) 2009-2010 Alain Reguera Delgado
4c79b5
# 
4c79b5
# This program is free software; you can redistribute it and/or modify
4c79b5
# it under the terms of the GNU General Public License as published by
4c79b5
# the Free Software Foundation; either version 2 of the License, or
4c79b5
# (at your option) any later version.
4c79b5
# 
4c79b5
# This program is distributed in the hope that it will be useful, but
4c79b5
# WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c79b5
# General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with this program; if not, write to the Free Software
4c79b5
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
4c79b5
# USA.
4c79b5
# 
4c79b5
# ----------------------------------------------------------------------
418249
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
4c79b5
function cli_getRepoName {
4c79b5
a31714
   local NAME="$1"
a31714
   local TYPE="$2"
4c79b5
a31714
   case $TYPE in
4c79b5
a31714
      f | regular-file )
4c79b5
      NAME=$(echo $NAME \
4c79b5
         | tr -s ' ' '_' \
4c79b5
         | tr '[:upper:]' '[:lower:]')
4c79b5
      ;;
4c79b5
a31714
      d | directory )
4c79b5
      NAME=$(echo $NAME \
4c79b5
         | tr -s ' ' '_' \
4c79b5
         | tr '[:upper:]' '[:lower:]' \
4c79b5
         | sed -r 's/^([[:alpha:]])/\u\1/')
4c79b5
      ;;
4c79b5
4c79b5
   esac
4c79b5
4c79b5
   echo $NAME
4c79b5
4c79b5
}