The bash PS1
variable seemingly has access to all the shell's variables.
$ foo=bar
$ PS1='$foo '
bar # Works as expected.
But, setting a variable there does not work.
$ PS1='$(bar=baz)\$ '
$ echo $bar
$ # Does not work.
Why, and how to make this work?