# Replace whitespace with linebreaks, normalize repeated '/' chars, and sort -u
# (If any libs have whitespace in their filenames, someone needs punishment.)
clean_var() {
- local a=$(echo ${@%%[[:space:]]-\*[[:space:]]*}) # Deliberately unquoted
- # A benchmark shows this loop is faster than piping to sed,
- # as long as there aren't more than a handful of '/' chars.
- while [[ $a = *//* ]]; do a="${a//\/\///}"; done
- sort -u <<< "${a// /$'\n'}"
+ [[ $@ = '-*'* ]] && return
+ shopt -s extglob
+ local a="$@"
+ a="${a%%[[:space:]]-\*[[:space:]]*}" # Delete what follows -*
+ a="${a//+([[:space:]])/$'\n'}" # Turn spaces into linebreaks
+ a="${a//+(\/\/)//}" # Normalize slashes
+ sort -u <<< "$a"
}
# Exit and optionally output to sterr
die() {