I have c++ code which includes a system call which in turn calls a bash oneliner
if (system("if [ `ls | wc -l` -eq 1 ]; then return 0 ; else return 1; fi") != 0)
std::cout << "returned non zero" << std::endl;
else
std::cout << "returned zero" << std::endl;
This doesn't work since I get this error
-bash: return: can only `return' from a function or sourced script
If I use echo instead of return I get the return code of the echo command instead the value passed to echo. Any idea how to go around this?
bashto launch yet more programs.