I would like to ask if there a way for the system to capture ifort's exit code for use in a variable (in a bash script)?
I am writing a bash script to compile several sources, and execute them right after each compilation. Since this script is run several times on the same path, usually because I am debugging the source bundle, the executable files are simply overwriten every time compilation succeeds for the respective sources.
Problem: A particular source file throws compilation errors and compilation is aborted. However the executable is still run on the follow-up, because the executable is found in path from previous successful compilations. For that reason I wish to skip execution every time compilation fails for a particular source, but have no elegant way to do it. Right now, I capture stderr to read the "compilation aborted" sub-string as a condition.
It would be particuarly useful to capture ifort's exit code instead. Besides it being more elegant, it can be more manipulative to (thinking about future projects), as the exit codes are differentiated for a reason. (not just 0 or 1)
Thanks in advance!