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. – Chris Conover Sep 22 '15 at 19:34export $(cat foo | xargs)
? – Zanchey Sep 22 '15 at 23:38$
in$(cat foo | xargs)
– Chris Conover Sep 23 '15 at 04:07