在 sh shell 中找不到 source 命令

问题描述:

我有一个使用 sh shell 的脚本.我在使用 source 命令的行中收到错误消息.我的 sh shell 中似乎没有包含 source.

I have a script that uses sh shell. I get an error in the line that uses the source command. It seems source is not included in my sh shell.

如果我明确尝试从 shell 运行 source 我得到:

If I explicitly try to run source from shell I get:

sh: 1: source: not found

我应该以某种方式安装源代码"吗?我的 sh 版本有误吗?

Should I somehow install "source"? Do I have a wrong version of sh?

/bin/sh 通常是其他一些试图模仿 The Shell 的 shell.许多发行版使用 /bin/bash 作为 sh,它支持 source.但是,在 Ubuntu 上,使用了不支持 source/bin/dash.大多数 shell 使用 . 而不是 source.如果您无法编辑脚本,请尝试更改运行它的 shell.

/bin/sh is usually some other shell trying to mimic The Shell. Many distributions use /bin/bash for sh, it supports source. On Ubuntu, though, /bin/dash is used which does not support source. Most shells use . instead of source. If you cannot edit the script, try to change the shell which runs it.