Andrey
Andrey

Reputation: 21285

Source command not working in a bash script

Consider this code I run directly in bash (Mac):

> source <(echo "ABC=1")
> echo $ABC
1

Now, if I put these two lines in a test.sh script and execute:

#!/bin/bash
source <(echo "ABC=1")
echo $ABC

nothing is echo'ed, so it looks like source doesn't work? Any ideas?

Btw, I tried replacing source with . - the same problem.

Upvotes: 1

Views: 264

Answers (1)

Carl Norum
Carl Norum

Reputation: 224904

Apple's bash just appears to be too old. I reproduced your failure locally, but it works fine with bash 5.1.16 from homebrew.

I didn't look up any specific bug fixes or version notes, though, sorry.

Upvotes: 2

Related Questions