Add a shell function which is used in the "tcp" system test, but has
been accidentally omitted from !2425 (merged). Make sure the function does not
change the value of "ret" itself, so that the caller can decide what to
do with the function's return value.