Is it possible to set environment variables with export in Fish Shell? I am working on a project that configures variables this way and it does not make sense to maintain a separate configuration file just for fish.
Consider this example in bash:
echo -e "foo=1\nfoobar=2\n" > foo; export $(cat foo | xargs); env | grep foo
foo=1
foobar=2
In fish shell, it appears that it will only set a single variable, and only if there is one variable in the file:
~ $ echo -e "foo=3\nfoobar=4" > foo; export (cat foo | xargs); env | grep foo
~ $ echo -e "foo=3" > foo; export (cat foo | xargs); env | grep foo
foo=3
Is this just a flaw / omission in the Fish implementation of export?
This question is similar to but different from these other two posts:
set
, but given thatexport
is a builtin in bash, and there is no binary to fallback to, where else would it be coming from? My example above showed that it worked for a single argument but not two. If not for this detail, fish could be used in more teams that primarily use bash.export $(cat foo | xargs)
?$
in$(cat foo | xargs)