【发布时间】:2020-08-10 04:37:04
【问题描述】:
所以我在使用 bash shell 脚本和 python 自动化我的项目时遇到了一个问题......
我想编写一个程序来帮助我使用 GitHub 创建新的存储库。但是,我在执行代码时遇到了这个问题。
基本上,我想做的是运行“create repo repo-name”并在本地创建一个新的 github 存储库。
function create() {
cd
cd path/to/python/file
python3 gh-create-command.py $*
if [$1 == 'repo']
then
<creating repository>
fi
}
但是当我运行这段代码时,我得到了错误,bash: [repo: command not found。
有人可以帮我吗?
如果我应该发布完整的代码,请回复。
谢谢。
编辑:完整代码
function create() {
cd
cd path/to/python/file
python3 gh-create-command.py $*
echo $1
if [ '$1' == 'repo' ]
then
cd
cd path/
mkdir $2
cd $2
touch README.md
git init
cd ..
cd path/to/python/file
python3 gh-create-online-repo.py $*
git remote add origin 'https://github.com/advaitvariyar/$2.git'
git add .
git commit -m "initial commit"
git push -u origin master
code .
fi
}
输出:回购
【问题讨论】:
-
[后面缺少一个空格
标签: bash shell automation command mkdir