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.

1
3

You need spaces:

if [ "$s1" == "$s2" ]
1
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.