[procps] Re: top buglets + misc

  • From: Sami Kerola <kerolasa@xxxxxx>
  • To: procps@xxxxxxxxxxxxx
  • Date: Wed, 15 Feb 2012 22:59:17 +0100

On Wed, Feb 15, 2012 at 09:01, Jim Warner <james.warner@xxxxxxxxxxx> wrote:
> Hi Craig,
>
> I noticed a couple of Debian bug reports regarding rcfile incompatibility. 
>  The first one (#651213) prematurely and incorrectly suggested the problem is 
> solved in the latest release.
>
> So I decided to fix that (sort of) to make your reply true.  I'd be 
> interested in your feedback on my approach.
>
> I also addressed a couple of other things in the attached tarball.
>
> Thanks in advance for committing them.

Hi Jim,

The message in patch 0006 looked odd to me. How about allowing users
to overwrite location of new top rc file location? See attached patch
how that could work.

-- 
   Sami Kerola
   http://www.iki.fi/kerolasa/
From a3e6856fb65fea66c5827374cc3b1469a02d406d Mon Sep 17 00:00:00 2001
From: Sami Kerola <kerolasa@xxxxxx>
Date: Wed, 15 Feb 2012 22:41:06 +0100
Subject: [PATCH] top: add TOPRC environment variable

The TOPRC environment variable is meant to ease adaptation of the new
top by allowing users to speficy alternative path for new format
.toprc file.

Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 top/top.1     |    5 +++--
 top/top.c     |    9 +++++++--
 top/top_nls.c |    2 +-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/top/top.1 b/top/top.1
index 7a074c3..8f1f13a 100644
--- a/top/top.1
+++ b/top/top.1
@@ -1471,8 +1471,9 @@ Here is an example of the contents of\fI /etc/toprc\fR:
 .\" ......................................................................
 .SS 6b. PERSONAL Configuration File
 .\" ----------------------------------------------------------------------
-This file is written as '$HOME/.your-name-4-top' + 'rc'.
-Use the 'W' \*(CI to create it or update it.
+Unless TOPRC envinronment variable is set file is written as
+'$HOME/.your-name-4-top' + 'rc'.  The TOPRC is expected to have full path to
+user readable file.  Use the 'W' \*(CI to create the file or update it.
 
 Here is the general layout:
 .Bd -literal -compact
diff --git a/top/top.c b/top/top.c
index 29c1400..f9a73b5 100644
--- a/top/top.c
+++ b/top/top.c
@@ -2177,8 +2177,13 @@ static void configs_read (void) {
    int i, x;
    char id;
 
-   p = getenv("HOME");
-   snprintf(Rc_name, sizeof(Rc_name), "%s/.%src", (p && *p) ? p : ".", Myname);
+   p = getenv("TOPRC");
+   if (p) {
+      snprintf(Rc_name, sizeof(Rc_name), "%s", p);
+   } else {
+      p = getenv("HOME");
+      snprintf(Rc_name, sizeof(Rc_name), "%s/.%src", (p && *p) ? p : ".", 
Myname);
+   }
 
    fp = fopen(SYS_RCFILESPEC, "r");
    if (fp) {
diff --git a/top/top_nls.c b/top/top_nls.c
index 7bad652..29261a5 100644
--- a/top/top_nls.c
+++ b/top/top_nls.c
@@ -238,7 +238,7 @@ static void build_norm_nlstab (void) {
       "\n"
       "Rather than deleting the old incompatible rcfile you could try any of 
these:\n"
       "  . temporarily rename the old file while experimenting with new top\n"
-      "  . create a symlink to this new top and thus change the rcfile name\n"
+      "  . use TOPRC environment variable pointing to new top configuration 
file\n"
       "\n"
       "You'll find that with this new top, less time is required for 
configuration.\n"
       "And the new fields and commands could make reconfiguration a rewarding 
task.");
-- 
1.7.9

Other related posts: