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



我有一个在WSL Ubuntu系统上编写的简单bash脚本;它在那里运行得很好。然后我git push它到github,去一个不同的系统WSL Ubuntu和git clone的项目,cd到那个文件夹并运行脚本,但它被下面的错误打破了。

我尝试了dos2unix,但这不起作用,相同的错误和相同的破碎状态。你有一些关于什么可能导致这种情况的建议(我猜是通过将其存储在github中而改变的),以及如何修复(像以前一样,在原始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

让我知道它是否也适用于你。

致意。

最新更新