fix return status and format anyway if stdin not a tty