Amin Shah Gilani
1 min readOct 19, 2019

--

Thank you very much for this! However, there’s a small problem with this.

In bash $? means the exit status of the last command only! So, when you run this:

./scripts/run-brakeman.bash
./scripts/run-tests.bash
if [ $? -ne 0 ]; then
echo "Brakeman and Tests must pass before pushing!"
exit 1
fi

If your run-brakeman.bash script fails, but your run-tests.bash script is successful, your $? variable will equal 0 , and the commit will be pushed upstream. A quick and dirty fix for this is to execute both scripts together. Like so:

./scripts/run-brakeman.bash && ./scripts/run-tests.bashif [ $? -ne 0 ]; then
echo "Brakeman and Tests must pass before pushing!"
exit 1
fi

This way, if either one fails, the $? variable will be non-zero.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Amin Shah Gilani
Amin Shah Gilani

Written by Amin Shah Gilani

Founder. Developer. Spaces over tabs. Atom over your favorite X.

No responses yet

Write a response