2021-10-22 09:25:33 -07:00
|
|
|
#!/usr/bin/env sh
|
2024-07-22 05:28:58 -07:00
|
|
|
# compat: +ash +bash +dash +zsh
|
2021-10-22 09:25:33 -07:00
|
|
|
|
|
|
|
v_domap() {
|
|
|
|
argc $# -eq 1 "$0" || return
|
|
|
|
# TODO: sanity-check on characters of the variable name.
|
|
|
|
local _k_="$1" _v_= _new_= _next_= _i_= _o_=
|
|
|
|
eval "_v_=\"\$$_k_\""
|
|
|
|
while [ -n "$_v_" ]; do
|
2023-08-16 05:30:36 -07:00
|
|
|
_next_="${_v_#?}"
|
2021-10-22 09:25:33 -07:00
|
|
|
_i_="${_v_%"$_next_"}"; _v_="$_next_"
|
|
|
|
map
|
|
|
|
_new_="$_new_$_o_"
|
|
|
|
#printf 'new: %s\n' "$_new_"
|
|
|
|
done
|
|
|
|
eval "$_k_=\"\$_new_\""
|
|
|
|
}
|
|
|
|
|
|
|
|
[ -n "${preload+-}" ] || . ~/sh/preload || exit 2
|
|
|
|
eval ${preload:-preload} argc
|
|
|
|
[ -n "${preload+-}" ] || v_domap "$@"
|