Combining export with command substitution on one line hides the exit status of the command. The assignment
runs a command, but the overall status comes from export, which usually succeeds.
Assign first, then export: foo="$(mycmd)" and then export foo.
Literal values such as export foo=bar do not have this problem.