I don't think IFS
is the cause of your problems. There are two problems with your code:
You put
$(awk ...)
in double quotes, so no word splitting is done. So it treatsexport varname="value"
as the name of the command -- the space is part of the command name, not a separator between the command and the argument.Even without the double quotes, it wouldn't work because quote processing is not performed on the result of command substitution, only word splitting and wildcard expansion are done. So the double quotes in your
export
command will be included as literal characters in the values being assigned.
The solution to this, as pointed out by mplf, is to use eval
:
eval "$(awk -F= '{printf("export %s=\"%s\"", $1, $2)}' <(echo $i) )"