Question: I am cloning repository from Bamboo on a windows machine using the following code:

```
cd ${bamboo.build.working.directory}
IF EXIST devops (
    cd devops
    git pull
) ELSE (
    git clone https://myDevops:MyGithub@github.com/myInfo/devops
)

```

This will result in a successful clone of the repo that I am trying to get. But now I am trying to clone the repo on a Mac instead of a windows machine. I have changed the Bash so that it would run without errors to this:

```
cd ${bamboo.build.working.directory}
if [exist devops]; then 
    cd devops
    git pull
 else 
    git clone clone https://myDevops:MyGithub@github.com/myInfo/devops
fi

```

But now I am getting this message in the log:

```
[exist: command not found 

```

While on the windows it will show this in the log:

```
C:\bamboo-home\xml-data\build-dir\THE-BLD-KEY>IF EXIST devops (
cd devops  
     git pull 
)  ELSE (git clone https://myDevops:MyGithub@github.com/myInfo/devops)

```

I don't know why there is the message command not found on the Mac. I originally had the pieces of codes the same but because of syntax errors I changed the Mac one to what it is now. Why can it not get command exist?

Answer: 
Your syntax is indeed incorrect. You could use `if [ -d devops ] ; then` but you can do better than that in one line using `cd` return code (and testing if `devops` is a directory and can be chd' into)

```
cd devops 2>/dev/null && git pull || git clone https://myDevops:MyGithub@github.com/myInfo/devops

```

Edit: chepner suggests that if `git pull` fails it calls `git clone` so my answer is imperfect to that regard.

Suggested replacement one-liner would be still using `if`:

```
if cd devops 2>/dev/null; then git pull; else git clone https://myDevops:MyGithub@github.com/myInfo/devops; fi

```
man bash:

> 
> -d file
>  True if file exists and is a directory.
> 
> 
> 

So you have to use: `[ -d devops ]`