When you are creating tutorials online for people to use in a single terminal sometimes it's nice to source inline code...however none of these worked as I would expect. I would expect
foo to be "bar" for all of these. Anyone know why?
#!/usr/bin/env bash source <(echo "export foo=bar"); echo "$foo" source <(cat <<< "export foo=bar"); echo "$foo" source <(cat <<EOF export foo=bar EOF ); echo "$foo"
My only guess is that
source cannot read from a file descriptor? I also tried using
. instead of
source same thing.
I am on MacOS,
bash --version output:
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18) Copyright (C) 2007 Free Software Foundation, Inc.