summaryrefslogblamecommitdiffstats
path: root/modules/str.inc
blob: 617903358133f070a371cf80b327e42824e3068d (plain) (tree)

























                                                                                                             
#!/bin/ash

str_trim() {
	if [ $# = 0 ]; then
		tr '\n' '\r' | sed -r 's/^[[:space:]]+//;s/[[:space:]]+$//' | tr '\r' '\n'
	else
		printf "%s" "$*" | tr '\n' '\r' | sed -r 's/^[[:space:]]+//;s/[[:space:]]+$//' | tr '\r' '\n'
	fi
}

str_upper() {
	if [ $# = 0 ]; then
		tr 'a-z' 'A-Z'
	else
		printf "%s" "$*" | tr 'a-z' 'A-Z'
	fi
}

str_lower() {
	if [ $# = 0 ]; then
		tr 'A-Z' 'a-z'
	else
		printf "%s" "$*" | tr 'A-Z' 'a-z'
	fi
}