I dont like this style (invoking the function, then printint 'r' variable) but bash doesn't allow return values in function. Printing inside mongoCmd() it nos a solucion, as there as cases in which I need processing the value to get some other piece of information (see for example cm_forwards_psb_ok.test for an example).