git - 使用 shell 脚本克隆 git repo - Shell 在“.git”之后添加一个空格?
问题描述
我正在尝试做一个非常简单的任务,即将一个 git repo 和 cd 克隆到其中。
我有这个 shell 脚本:
#!/bin/bash
# Clone a git repository, and go into it
git clone git@someNumbers:myGitRepo.git
cd myGitRepo
当我运行它时,shell 认为 git repo 是“克隆 git@someNumbers:myGitRepo.git ”(有空格,我的代码中没有空格,我敢肯定)!
和输出:
Cloning into 'myGitRepo.git '...
当它应该说:
Cloning into 'myGitRepo'...
我还尝试将两个命令(一次)复制粘贴到命令提示符下,但同样会失败。只有单独运行它,或者在最后不使用 linebrake 的情况下复制粘贴它,才能成功克隆 git repo。
这里发生了什么?如何编写一个可以克隆 git 存储库的简单 shell 脚本?
解决方案
在您写的评论中od -tx1c myscript.sh
显示. g i t 342 200 213 \n c d
。那是U+200B ZERO WIDTH SPACE的 UTF-8 编码,显然它不被 shell 识别为空格。
如果您在编辑器中看不到它,只需删除整行,包括末尾的换行符,然后从头开始输入。
推荐阅读
- c++ - 是否有可能去掉 gcov 仪器
- c++ - 为什么在某些情况下可以省略模板参数规范?
- c# - 当我们在 y 轴上旋转操纵器时,如何通过 Manipulator 在sharpdx 中移动模型
- centos - 尝试安装 NNTP 阅读器锡和 parsdate.y 错误
- java - XML 转义忽略重音字符
- c++ - 使用向量作为输出缓冲区?
- r - 在 R 中创建一列预测值
- java - Reactor - 如何压缩通量
在飞行中? - haskell - Ghci 模式匹配/打印 int 列表
- google-drive-api - Google Drive API:是否可以在没有权限访问文件的情况下拥有应用程序