Skip to content

Commit e54a282

Browse files
authored
Add function to remove dots and slashes (#13)
1 parent 18d3606 commit e54a282

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#-----------------------------------------------------------------------
2+
#
3+
# Basescript function
4+
#
5+
# The basescript functions were designed to work as abstract function,
6+
# so it could be used in many different contexts executing specific job
7+
# always remembering Unix concept DOTADIW - "Do One Thing And Do It Well"
8+
#
9+
# Developed by
10+
# Evert Ramos <evert.ramos@gmail.com>
11+
#
12+
# Copyright Evert Ramos
13+
#
14+
#-----------------------------------------------------------------------
15+
#
16+
# Be careful when editing this file, it is part of a bigger script!
17+
#
18+
# Basescript - https://github.com/evertramos/basescript
19+
#
20+
#-----------------------------------------------------------------------
21+
22+
#-----------------------------------------------------------------------
23+
# This function has one main objective:
24+
# 1. Remove dot (.) and slash (/) from a string
25+
#
26+
# You must/might inform the parameters below:
27+
# 1. String that will be analized
28+
# 2. [optional] (default: )
29+
#
30+
#-----------------------------------------------------------------------
31+
string_remove_dot_slash_from_string()
32+
{
33+
local LOCAL_STRING
34+
35+
LOCAL_STRING=${1:-null}
36+
37+
[[ $LOCAL_STRING == "" || $LOCAL_STRING == null ]] && echoerror "You must inform the required argument(s) to the function: '${FUNCNAME[0]}'"
38+
39+
[[ "$DEBUG" == true ]] && echo "Removing dots (.) and slashes (/) from '$LOCAL_STRING'"
40+
41+
STRING_REMOVE_DOT_SLASH_FROM_STRING_RESPONSE=$(echo $LOCAL_STRING | tr -d ' ./' | tr '[:upper:]' '[:lower:]' | tr -d '[:cntrl:]')
42+
43+
return 0
44+
}
45+

0 commit comments

Comments
 (0)