# HG changeset patch # User Jun Wu # Date 1492041023 25200 # Node ID ac55270210974ebb9b1cea9b9d0448f96ba5631c # Parent 6ce09d2cc2db6aeed0b46da1b26426798d91833c chg: respect environment variables for pager Previously chg runs the pager command without respecting its environment variables being told to use. This patch makes it so. diff -r 6ce09d2cc2db -r ac5527021097 contrib/chg/hgclient.c --- a/contrib/chg/hgclient.c Mon Apr 10 17:36:40 2017 +0200 +++ b/contrib/chg/hgclient.c Wed Apr 12 16:50:23 2017 -0700 @@ -252,7 +252,7 @@ ctx->datasize = sizeof(r_n); writeblock(hgc); } else if (strcmp(args[0], "pager") == 0) { - setuppager(args[1]); + setuppager(args[1], args + 3); if (hgc->capflags & CAP_ATTACHIO) attachio(hgc); /* unblock the server */ diff -r 6ce09d2cc2db -r ac5527021097 contrib/chg/procutil.c --- a/contrib/chg/procutil.c Mon Apr 10 17:36:40 2017 +0200 +++ b/contrib/chg/procutil.c Wed Apr 12 16:50:23 2017 -0700 @@ -177,7 +177,7 @@ /* This implementation is based on hgext/pager.py (post 369741ef7253) * Return 0 if pager is not started, or pid of the pager */ -pid_t setuppager(const char *pagercmd) +pid_t setuppager(const char *pagercmd, const char *envp[]) { assert(pagerpid == 0); if (!pagercmd) @@ -205,7 +205,8 @@ close(pipefds[0]); close(pipefds[1]); - int r = execlp("/bin/sh", "/bin/sh", "-c", pagercmd, NULL); + int r = execle("/bin/sh", "/bin/sh", "-c", pagercmd, NULL, + envp); if (r < 0) { abortmsgerrno("cannot start pager '%s'", pagercmd); } diff -r 6ce09d2cc2db -r ac5527021097 contrib/chg/procutil.h --- a/contrib/chg/procutil.h Mon Apr 10 17:36:40 2017 +0200 +++ b/contrib/chg/procutil.h Wed Apr 12 16:50:23 2017 -0700 @@ -15,7 +15,7 @@ void restoresignalhandler(void); void setupsignalhandler(pid_t pid, pid_t pgid); -pid_t setuppager(const char *pagercmd); +pid_t setuppager(const char *pagercmd, const char *envp[]); void waitpager(void); #endif /* PROCUTIL_H_ */