Space 字符在 linux 可执行文件中被忽略

Space character ignored in the linux exec file

我正在尝试 运行 以下脚本

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo ${DIR}
source ${DIR}/envcov.sh

回显时,输出为

/Users/John/Desktop/Test/Test Banking/XcodeCoverage

当执行到

   source ${DIR}/envcov.sh

我收到以下错误

 ./getcov: line 7: /Users/John/Desktop/Test/Test: No such file or directory

未处理 space 字符。知道如何解决这个问题吗?

编辑:

source "${DIR}/envconv.sh" 

添加双引号会引发错误:

/Users/John/Desktop/Test/Test Banking/XcodeCoverage/envconv.sh: No such file or directory.

我需要通过在变量 ${DIR} 中找到 space 字符的索引来添加一个 backspace,如下所示:

/Users/John/Desktop/Test/Test\ Banking/XcodeCoverage/envconv.sh

是的,您需要双引号参数:

source "${DIR}/envconv.sh"