1

I'm trying to clone a repo and test it after is done via bash script. I have written my test code based on Bash Shell: Check File Exists or Not.

#!/bin/bash

echo "*** TRY TO INIT INFER ***"

# Clone Infer
INFER_GIT_PATH="https://github.com/facebook/infer.git"
echo "> Try to Clone Infer from ${INFER_GIT_PATH}"
git clone ${INFER_GIT_PATH}

INFER_PATH="/infer/infer/bin/infer"
[ -e ${INFER_PATH} ] && echo "Infer downloaded successfully" || echo "Something went wrong :("

Although repo can be downloaded successfully and /infer/infer/bin/infer.sh exists, I'm always getting Something went wrong :( message.

2 Answers 2

2

Change it to this (use a relative path):

INFER_PATH="./infer/infer/bin/infer"
[ -e ${INFER_PATH} ] && echo "Infer downloaded successfully" || echo "Something went wrong :("

and it should work.

Sign up to request clarification or add additional context in comments.

3 Comments

That line was my mistake, I just updated my code. Thanks for pointing out but I still have same output :(
so the name of your file is infer or infer.sh?
I updated my comment. You have to use a relative path.
1

If you want to know if a file exist, you can use -f flag:

[ -f /infer/infer/bin/infer ] && echo "Infer downloaded successfully" || echo "Something went wrong :("

1 Comment

Unfortunately I'm still getting Something went wrong :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.