[前][次][番号順一覧][スレッド一覧]

ruby-changes:60750

From: Nobuyoshi <ko1@a...>
Date: Sun, 12 Apr 2020 14:58:29 +0900 (JST)
Subject: [ruby-changes:60750] 3825662d77 (master): Set up environment variable for pager [Feature #16754]

https://git.ruby-lang.org/ruby.git/commit/?id=3825662d77

From 3825662d777ae406136fa7d720b60fe04c6eafd2 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 12 Apr 2020 12:56:17 +0900
Subject: Set up environment variable for pager [Feature #16754]


diff --git a/ruby.c b/ruby.c
index 79cd595..03c1644 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1585,6 +1585,12 @@ rb_f_chomp(int argc, VALUE *argv, VALUE _) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1585
     return str;
 }
 
+static void
+setup_pager_env(void)
+{
+    if (!getenv("LESS")) ruby_setenv("LESS", "-R"); // Output "raw" control characters.
+}
+
 static VALUE
 process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
 {
@@ -1627,12 +1633,14 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1633
                     close(fds[0]);
                     close(fds[1]);
                     if (pid > 0) {
+                        setup_pager_env();
                         rb_f_exec(1, &pager);
                         kill(SIGTERM, pid);
                         rb_waitpid(pid, 0, 0);
                     }
                 }
 #else
+                setup_pager_env();
                 VALUE port = rb_io_popen(pager, rb_str_new_lit("w"), Qnil, Qnil);
                 if (!NIL_P(port)) {
                     int oldout = dup(1);
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]