首页 > 解决方案 > 在 WSL Ubuntu 上克隆时,Bash github 项目无法运行

问题描述

我有一个在 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() {

标签: bashgitshellgithubwsl-2

解决方案


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

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

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

问候。


推荐阅读