_execq()

# _execq() -- Execute command and silent output
# Usage: _execq command
#
# Example:
#
# if _execq "/bin/ps auwx"; then
#	echo "ps OK";
# fi
#

_exeq() {
	local cmd=$@;
	$cmd &>/dev/null;
	return $?;
}

rm_str()

# rm_str() -- Remove string/character from string
# Usage: rm_str string string
#
# Example 1:
#
# echo $(rm_str "pungkok hang" "pungkok");
#
# Example 2:
#
# string="$(rm_str "pungkok hang" "pungkok")";
# echo $string;

rm_str() {
	local _str="$1";
	local _chr="$2";
	[ -z "$_chr" ] && _chr='"';
	if [ -n "$_str" -a -n "$_chr" ]; then
		echo ${_str//$_chr};
		return 0;
	fi;
	return 1;
}

lcfirst()

# lcfirst() -- Make a string's first character lowercase
# Usage: lcfirst string
# depend: strtolower(): http://www.ronggeng.net/index.php/2009/04/24/strtolower/
#
# Example:
#
# lcfirst "test test test";
#

if [ -n "${BASH_VERSINFO[0]}" ] && [ ${BASH_VERSINFO[0]} -gt 3 ]; then
	# Updated: 20-Aug-2009 - for bash version 4
	lcfirst() {
		[ $# -eq 1 ] || return 1;
		echo ${1,};
		return 0;
	}
else
	lcfirst() {
		[ $# -eq 1 ] || return 1;
		! type -t strtolower &>/dev/null && return 1;
		echo "$(strtolower "${1:0:1}")${1:1:${#1}}";
		return 0;
	}
fi

str_repeat()

# str_repeat() -- Repeat a string
# Usage: str_repeat input multiplier
# depend: is_num(): http://www.ronggeng.net/index.php/2009/04/24/is_num/
#
# Example:
#
# str_repeat "test test test" 10;
#

str_repeat() {
	[ $# -eq 2 ] || return 1;
	! is_num "$2" && return 1;
	local _cnt _ret="";
	while ((_cnt < $2 )); do
		_ret+="$1";
		((_cnt++));
        done;
	echo "$_ret";
	return 0;
}

is_num()

# is_num() -- Check if input is number between 0-9
# Usage: is_num input
#
# Example:
#
# if is_num 200; then
#	echo "OK";
# fi
#

is_num() {
	[ $# -eq 1 ] || return 1;
	[[ $1 =~ ^([0-9]+)$ ]] && return 0;
	return 1;
}