0

I'm completely new to Bash, and I'm trying to make a simple script to automate Git pulling and pushing from a repo, but I can't get it to work.

Here is a pastebin of the code: http://pastebin.com/JrXqktD4

#!/bin/bash
#Git Puller / Pusher for MobArenaBattles

echo "Please type whether you want to pull or push:"

read proc
cd $HOME/Desktop/IdeaProjects/Plugins/MobArenaBattles

if ["$proc"="push"]; then
  echo "Please type the commit message:"
  read message
  git status
  git add -A
  git commit -m $message
  git push
elif ["$proc"="pull"]; then
  git status
  git pull
else
  echo "Invalid choice! Exiting."
fi

The error I get is:

./MAB Git.sh: line 9: [push=push]: command not found
./MAB Git.sh: line 16: [push=pull]: command not found

I have tried using == and -eq but it comes up with the same error. Sorry if I'm being stupid, it's my first attempt.

Thanks in advance.

Byte Commander
  • 107,489

1 Answers1

3

You need spaces:

if [ "$s1" == "$s2" ]
Mahdi
  • 1,467
  • The answer is correct, I just want to emphasize that there must be spaces around the square brackets [/] as well as around the comparison operator ==. Also you may use both = or == as they are equal in Bash, but -eq is only for comparing numerical values, not for strings. – Byte Commander Apr 10 '16 at 11:43