Bash - export environment variables with special characters ($)
You don't need eval at all, just use declare
built-in in bash
to create variables on-the-fly!
case "$key" in
'#'*) ;;
*)
declare $key=$value
export "$key"
esac
Just use single quotes:
export VAR2='d#r3_P{os-!kblg1$we3d4xhshq7=mf$@6@3l^'
Just escape the $ sign with backslash \