checking $? value

I have written a build script which creates a bin directory and compiles java code.
I call this in another script, ,I would like to test that the script ran correctly.
For this I used $?, but this value is turning out to be 1 instead of 0 even though the is correctly running.?Basically what I want to test is that the contents of ran properly-ie the code was compiled properly.
Is there a way to test that it ran correctly?
Who is Participating?
FrivolousSamConnect With a Mentor Commented:
$? returns the exit code of the command that was last run.

You need to check where is exiting that means the last command returned a nonzero exit code.

Start at the last instruction and do something like:
echo "command: xxxx | exit code: $?"
after it.

Keep adding echo commands until you realise which command is causing the problem.
ams7503Author Commented:
Thank you for your help- by echoing stuff out I was able to figure out what was going wrong.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.