From df38a35b07180e235dec9ffca3d434aa4e7e27c9 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Mon, 30 May 2016 18:05:44 -0400 Subject: [PATCH] mosh: Assume terminal supports 256 colors Assuming that the terminal running mosh in Termux supports 256 colors should be safe, and avoids a popen() call which uses /system/bin/sh and may not always work. --- packages/mosh/build.sh | 2 +- packages/mosh/mosh.cc | 18 +----------------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/packages/mosh/build.sh b/packages/mosh/build.sh index 52ab1a49..456e52da 100644 --- a/packages/mosh/build.sh +++ b/packages/mosh/build.sh @@ -1,7 +1,7 @@ TERMUX_PKG_HOMEPAGE=http://mosh.mit.edu/ TERMUX_PKG_DESCRIPTION="Mobile shell that supports roaming and intelligent local echo" TERMUX_PKG_VERSION=1.2.5.20160523 -TERMUX_PKG_BUILD_REVISION=1 +TERMUX_PKG_BUILD_REVISION=2 TERMUX_PKG_SRCURL=http://mosh.mit.edu/mosh-${TERMUX_PKG_VERSION}.tar.gz _COMMIT=05fe24d50ddbabf1c87be748b7397907ae1b9654 TERMUX_PKG_SRCURL=https://github.com/mobile-shell/mosh/archive/${_COMMIT}.zip diff --git a/packages/mosh/mosh.cc b/packages/mosh/mosh.cc index 02b475d4..9c306a22 100644 --- a/packages/mosh/mosh.cc +++ b/packages/mosh/mosh.cc @@ -339,25 +339,9 @@ int main( int argc, char *argv[] ) char **command = &argv[optind]; int commands = argc - optind; - string color_invocation = client + " -c"; - FILE *color_file = popen( color_invocation.c_str(), "r" ); - if ( !color_file ) die( "%s: popen: %d", argv[0], errno ); char *buf = NULL; size_t buf_sz = 0; ssize_t n; - if ( ( n = getline( &buf, &buf_sz, color_file ) ) < 0 ) { - die( "%s: Can't count colors: %d", argv[0], errno ); - } - // Chomp the trailing newline: - if ( n > 0 && buf[n - 1] == '\n' ) n--; - string colors = string( buf, n ); - pclose( color_file ); - - if ( !colors.size() || - colors.find_first_not_of( "0123456789" ) != string::npos || - atoi( colors.c_str() ) < 0 ) { - colors = "0"; - } int pty, pty_slave; struct winsize ws; @@ -383,7 +367,7 @@ int main( int argc, char *argv[] ) server_args.push_back( "new" ); server_args.push_back( "-s" ); server_args.push_back( "-c" ); - server_args.push_back( colors ); + server_args.push_back( "256" ); if ( port_request.size() ) { server_args.push_back( "-p" ); server_args.push_back( port_request ); -- 2.11.0