1

So I ran into a problem when automating my projects with bash shell script and python...

I want to write a program that can help me to create new repositories using GitHub. However, I ran into this problem when executing my code.

Essentially, what I want to do is run 'create repo repo-name' and create a new github repository locally.

function create() {
    cd
    cd path/to/python/file
    python3 gh-create-command.py $*
    if [$1 == 'repo']
    then
        <creating repository>
    fi
}

But when I run this code I get the error, bash: [repo: command not found.

Can someone help me out here?

Please reply if I should post the complete code.

Thanks.

EDIT: FULL CODE

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 }

output: repo

1 Answers1

2

You're missing whitespaces, it should be:

if [ $1 == 'repo' ]

And it's a good practice to quote all of your variables to avoid word splitting:

if [ "$1" == 'repo' ]

and to avoid Bashisms to make your code more portable. Use:

create() {

and

if [ "$1" = 'repo' ]

Arkadiusz Drabczyk
  • 8,447
  • 2
  • 14
  • 29