From 93f72848510f85bc8e93687cd8d1fd4188e13be6 Mon Sep 17 00:00:00 2001 From: Willi Goesgens Date: Fri, 13 Feb 2015 11:32:58 +0100 Subject: [PATCH] if we detect that we're running in a cygwin shell, assume we can use unix like message printing. --- arangosh/ArangoShell/ArangoClient.cpp | 36 +++++++++++++++------------ arangosh/V8Client/arangosh.cpp | 7 +++++- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/arangosh/ArangoShell/ArangoClient.cpp b/arangosh/ArangoShell/ArangoClient.cpp index 87e518a4d9..49cb3a7c51 100644 --- a/arangosh/ArangoShell/ArangoClient.cpp +++ b/arangosh/ArangoShell/ArangoClient.cpp @@ -48,7 +48,9 @@ double const ArangoClient::DEFAULT_REQUEST_TIMEOUT = 300.0; size_t const ArangoClient::DEFAULT_RETRIES = 2; double const ArangoClient::LONG_TIMEOUT = 86400.0; - +#ifdef _WIN32 +bool cygwinShell = false; +#endif namespace { #ifdef _WIN32 bool _newLine () { @@ -564,24 +566,26 @@ void ArangoClient::_printLine (const string &s) { } void ArangoClient::printLine (const string& s, bool forceNewLine) { -#ifdef _WIN32 - // no, we cannot use std::cout as this doesn't support UTF-8 on Windows - //fprintf(stdout, "%s\r\n", s.c_str()); - TRI_vector_string_t subStrings = TRI_SplitString(s.c_str(), '\n'); - bool hasNewLines = (s.find("\n") != string::npos) | forceNewLine; - if (hasNewLines) { - for (size_t i = 0; i < subStrings._length; i++) { - _printLine(subStrings._buffer[i]); - _newLine(); +#if _WIN32 + if (!cygwinShell) { + // no, we cannot use std::cout as this doesn't support UTF-8 on Windows + //fprintf(stdout, "%s\r\n", s.c_str()); + TRI_vector_string_t subStrings = TRI_SplitString(s.c_str(), '\n'); + bool hasNewLines = (s.find("\n") != string::npos) | forceNewLine; + if (hasNewLines) { + for (size_t i = 0; i < subStrings._length; i++) { + _printLine(subStrings._buffer[i]); + _newLine(); + } } + else { + _printLine(s); + } + TRI_DestroyVectorString(&subStrings); } - else { - _printLine(s); - } - TRI_DestroyVectorString(&subStrings); -#else - fprintf(stdout, "%s\n", s.c_str()); + else #endif + fprintf(stdout, "%s\n", s.c_str()); } //////////////////////////////////////////////////////////////////////////////// diff --git a/arangosh/V8Client/arangosh.cpp b/arangosh/V8Client/arangosh.cpp index d7eab90ee7..60b3bcc570 100644 --- a/arangosh/V8Client/arangosh.cpp +++ b/arangosh/V8Client/arangosh.cpp @@ -2302,7 +2302,12 @@ int main (int argc, char* args[]) { eRunMode runMode = eInteractive; // reset the prompt error flag (will determine prompt colors) bool promptError = false; - +#if _WIN32 + extern bool cygwinShell; + if (getenv("SHELL") != NULL) { + cygwinShell = true; + } +#endif arangoshEntryFunction(); TRIAGENS_C_INITIALISE(argc, args);