使用shell脚本克隆位桶存储库会导致目录中的每个存储库都以'$'\ r串联,现在文本换行在终端中

问题描述

  • 大家好,我运行了shell脚本

my_repo_list.sh

  • 其中仅包含git clone命令列表:

git clone https://repo@bitbucket.org/handle/group.git repoName1

git clone https://repo@bitbucket.org/handle/group.git repoName2

git clone https://repo@bitbucket.org/handle/group.git repoName3

git clone https://repo@bitbucket.org/handle/group.git repoName4

  • 而不仅仅是回购名称:

repoName1

repoName2

repoName3

repoName4

  • 目录中存储库的名称”格式为:

'repoName1'$'\ r'

'repoName2'$'\ r'

'repoName3'$'\ r'

'repoName4'$'\ r'

很抱歉格式化有关此问题的任何线索。

解决方法

诊断:您的my_repo_list.sh脚本具有CR-LF行尾,而不是Linux shell需要的仅LF行尾。

每个git clone命令如下:

git clone https://repo@bitbucket.org/handle/group.git repoName1<CR>

代替:

git clone https://repo@bitbucket.org/handle/group.git repoName1

其中<CR>表示文字控制M或$'\r'字符。因此,每个新目录名称都以文字控件M结尾。不管显示为何,这些名称都会巧妙地以外壳(可能是bash)可能正确解释的形式显示。

修复:重命名每个目录以消除回车符:

for i in repoName1 repoName2 repoName3 repoName4; do
    mv ${i}$'\r' ${i}
done

下次,请注意脚本中的行尾。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...