bash - 在 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() {
解决方案
我对 Windows 行尾有同样的问题,所以我的解决方案是:
# Remove cloned repo
git config --global core.autocrlf input
# Clone again the repo
让我知道它是否也适合你。
问候。
推荐阅读
- javascript - TENSORFLOW.JS 3D 姿势估计不起作用
- android - 面向 Android 12 及更高版本的应用需要为“android:exported”指定一个显式值,但我有这样的值
- github - Toast UI Editor 在 Github 上编辑文件?
- jenkins - Jenkins 2.303.1 升级后 ProjectMatrixAuthorizationStrategy 管理员用户/密码不起作用
- android - 尝试在空对象引用上调用虚拟方法“int android.graphics.Bitmap.getWidth()”
- checkbox - 更改复选框的默认行为
- javascript - React - 使用 window.onClick 事件监听器导航元素
- nuxt.js - Nuxt Auth loginWith() 加载微调器?
- google-sheets - 逐页获取 google 电子表格的评论
- python - 我正在尝试更新 django 中默认用户的电子邮件