为什么我的 envsubst 命令只是插入空白字符串?

Why is my envsubst command just inserting blank strings?

我正在尝试 运行 命令 envsubst < myfile 替换环境变量,但它们没有被替换为它们的值,而是被替换为空白字符串。

这是我的示例命令(为清楚起见,分成不同的行):

SIGNOFF="Goodbye"
&&
printf "\nOkay, $SIGNOFF has been set to \"$SIGNOFF\"\n\nOriginal contents:\n\n"
&&
cat test.conf
&&
printf "\n\nContents after envsubst < test.conf\n\n"
&&
envsubst < test.conf | cat
&&
printf "\n\n"

这是我的结果:

$ SIGNOFF="Goodbye" && printf "\nOkay, $SIGNOFF has been set to \"$SIGNOFF\"\n\nOriginal contents:\n\n" && cat test.conf && printf "\n\nContents after envsubst < test.conf\n\n" && envsubst < test.conf | cat && printf "\n\n"

Okay, $SIGNOFF has been set to "Goodbye"

Original contents:

Hello world, let's change the variable in the quotes below to say Goodbye!
"$SIGNOFF" (it certainly shouldn't just be blank!)

Contents after envsubst < test.conf

Hello world, let's change the variable in the quotes below to say Goodbye!
"" (it certainly shouldn't just be blank!)

$ 

我显然做错了一些明显的错误,我只是愚蠢地怀疑这是其中一件非常明显的事情,以至于我必须过度复杂化自己的 google 搜索以试图找到答案

该变量未导出,因此对任何命令都不可见。导出它。

SIGNOFF="Goodbye"
export SIGNOFF
envsubst < file