diff --git a/src/frontend/mosh-client.cc b/src/frontend/mosh-client.cc index 7efa161..e934601 100644 --- a/src/frontend/mosh-client.cc +++ b/src/frontend/mosh-client.cc @@ -192,7 +192,7 @@ int main( int argc, char *argv[] ) success = false; } - printf( "\n[mosh is exiting.]\n" ); + printf( "[mosh is exiting.]\n" ); free( key ); diff --git a/src/frontend/mosh-server.cc b/src/frontend/mosh-server.cc index e4c0b55..efefbb0 100644 --- a/src/frontend/mosh-server.cc +++ b/src/frontend/mosh-server.cc @@ -406,7 +406,15 @@ static int run_server( const char *desired_ip, const char *desired_port, network->set_verbose(); } - printf( "\nMOSH CONNECT %s %s\n", network->port().c_str(), network->get_key().c_str() ); + /* + * If mosh-server is run on a pty, then typeahead may echo and break mosh.pl's + * detection of the MOSH CONNECT message. Print it on a new line to bodge + * around that. + */ + if ( isatty( STDIN_FILENO ) ) { + puts( "\r\n" ); + } + printf( "MOSH CONNECT %s %s\n", network->port().c_str(), network->get_key().c_str() ); /* don't let signals kill us */ struct sigaction sa;