I\'m trying to figure out how to sanely and portably (as much as possible) deal with environment variables with names that don\'t map to valid shell variables. It is critica
One unportable approach (Linux-only) is to parse /proc/self/environ:
declare -A environ
while IFS='' read -r -d ''; do
var=${REPLY%%=*}
val=${REPLY#*=}
environ[$var]="$val"
done </proc/self/environ
printf '%q\n' "${environ["Invalid Name"]}"