Bash github 项目在 WSL Ubuntu 上克隆时无法 运行

Bash github project fails to run when cloned on WSL Ubuntu

我在 WSL Ubuntu 系统上编写了一个简单的 bash 脚本;它 运行 就在那里。然后我 git push 到 github,然后转到不同的系统 WSL Ubuntu 和 git clone 项目,cd 到那个文件夹和 运行 脚本,但由于以下错误而损坏。

我试过dos2unix,但这不起作用,同样的错误和同样的损坏状态。您对可能导致此问题的原因有什么建议吗(我猜是通过将其存储在 github 中来更改某些内容),以及如何修复(和以前一样,在原始文件中可以看到以下错误中的 none WSL Ubuntu系统,脚本运行完美)?

: command not found
: command not found
: command not found
: invalid shell option name
: command not found
: command not found
-bash: .custom: line 147: syntax error near unexpected token `$'{\r''
'bash: .custom: line 147: `fnheader() {

我在 Windows 行尾有同样的问题,所以我的解决方案是:

# Remove cloned repo
git config --global core.autocrlf input
# Clone again the repo

让我知道它是否也适合你。

此致。