diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2020-07-14 14:09:00 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2020-07-14 14:09:00 +0200 |
commit | b2a83ba28ef61f5c6aa32f3d81233e95cab1f3b0 (patch) | |
tree | 0fa168bb26f58df1b4b9f48edcf6476e05049528 | |
parent | 205c54bf10f4b0fdce64c5dace5c5a86de27d248 (diff) |
Override TERM environment variable on Windows when running less
-rw-r--r-- | libbutl/pager.cxx | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/libbutl/pager.cxx b/libbutl/pager.cxx index a3eb5e1..44aa83e 100644 --- a/libbutl/pager.cxx +++ b/libbutl/pager.cxx @@ -124,6 +124,18 @@ namespace butl args.push_back (nullptr); + // On Windows if we are using default less, then set the TERM environment + // variable to cygwin. Failed that, some environments like git-bash may + // set it to some strange values (like xterm-256color) which confuses + // less. + // + const char* env[] = {nullptr, nullptr}; + +#ifdef _WIN32 + if (pager == nullptr) + env[0] = "TERM=cygwin"; +#endif + if (verbose) { for (const char* const* p (args.data ()); *p != nullptr; ++p) @@ -151,7 +163,9 @@ namespace butl // try { - p_ = process (args.data (), -1); // Redirect child's STDIN to a pipe. + // Redirect child's STDIN to a pipe. + // + p_ = process (args.data (), -1, 1, 2, nullptr /* cwd */, env); // Wait a bit and see if the pager has exited before reading anything // (e.g., because exec() couldn't find the program). If you know a |