0

看到我想source在我的 shell 脚本中使用命令。现在,当我在终端上键入 source 时,它​​显示为

-bash: source: filename argument required
source: usage: source filename [arguments]

现在当我像这样在我的shell脚本中使用它时

#!/bin/sh
source

并保存为 test.sh

然后运行然后像这样

./test.sh: 2: source: not found

如何解决这个问题呢?

4

1 回答 1

5

您使用 运行脚本sh,而不是使用bash. source不存在 plain sh,但你可以使用.它,它的意思是一样的。

#!/bin/sh
. /path/to/other/script
function_defined_in_other_script
于 2012-08-03T13:36:23.017 回答