Fix and simplify socat escape detection