I'm trying to write a fairly simple bash script to retrieve third party software from the cloud and call this with the CMake execute_process(). I did not expect to spend this long on this, but I'm having difficulty finding examples and I've never been good with bash syntax
The structure of the script is simple, three functions:
- verifyObject()
- getFile()
- clean()
the verify file is structured like this
verifyObject() {
if [ -e "${TP_LIB_PATH}/${TP_LIB_SO}" ]; then
return 1
else
return 0
}
If tested this with debug messages and it seems to work, but I cannot get the syntax correct to do what I want to do with the other two functions. I want to use the result of the verify function in other if conditions such as:
c/c++ psudocode
if(!verifyObject()) {
// do something
else
// do something else
fi
}
I've hunted all over and haven't found examples of this. I've found a couple of syntax's that run but end up falling through the logic to the else regardless. Here is my latest attempt:
clean() {
if [ verifyObject -eq 1 ]; then
// This never is ends up happening even when the return
// value is 1
else
// This always happens
fi
}
What is the correct syntax to accomplish this?
note:
I am only doing it this way because the CMake doc's recommend bash scripts for anything more than simple scripting.