mirror of
https://github.com/dredx/prole.git
synced 2026-09-24 19:34:31 +00:00
20 lines
400 B
Bash
20 lines
400 B
Bash
#!/usr/bin/env bash
|
|
|
|
prole_trim() {
|
|
local s="${1:-}"
|
|
# Trim leading/trailing whitespace without invoking external tools.
|
|
s="${s#${s%%[![:space:]]*}}"
|
|
s="${s%${s##*[![:space:]]}}"
|
|
printf '%s' "$s"
|
|
}
|
|
|
|
prole_normalize_realm() {
|
|
local realm
|
|
realm=$(prole_trim "${1:-}")
|
|
if [[ -z "$realm" ]]; then
|
|
printf '%s' ""
|
|
return 0
|
|
fi
|
|
printf '%s' "$realm" | tr '[:lower:]' '[:upper:]'
|
|
}
|