From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christopher Baines Subject: [PATCH] scripts: container: Pass through TERM when calling exec Date: Wed, 25 Jan 2017 07:24:20 +0000 Message-ID: <20170125072420.31822-1-mail@cbaines.net> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41805) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWHwQ-0007sg-Qe for guix-devel@gnu.org; Wed, 25 Jan 2017 02:24:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cWHwN-0005s4-MG for guix-devel@gnu.org; Wed, 25 Jan 2017 02:24:26 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:38366 helo=mira.cbaines.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWHwN-0005rs-GQ for guix-devel@gnu.org; Wed, 25 Jan 2017 02:24:23 -0500 Received: from localhost (79-71-12-252.dynamic.dsl.as9105.com [79.71.12.252]) by mira.cbaines.net (Postfix) with ESMTPSA id EC9A713D1D7 for ; Wed, 25 Jan 2017 07:24:20 +0000 (GMT) Received: from dhcppc78.dlink.com (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 777b898b for ; Wed, 25 Jan 2017 07:24:20 +0000 (UTC) List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org * guix/scripts/container/exec.scm (guix-container-exec): Capture the value of the TERM environment variable, and pass it through to the container. This means some applications now work where they did not before (e.g. htop), and others have more functionality, providing that the terminal was capable of enabling that functionality in the first place. --- guix/scripts/container/exec.scm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/guix/scripts/container/exec.scm b/guix/scripts/container/exec.scm index 10e70568c..2dd6d802d 100644 --- a/guix/scripts/container/exec.scm +++ b/guix/scripts/container/exec.scm @@ -74,7 +74,17 @@ and the other containing arguments for the command to be executed." (let* ((opts (parse-command-line args %options '(()) #:argument-handler handle-argument)) - (pid (assoc-ref opts 'pid))) + (pid (assoc-ref opts 'pid)) + (environment (fold (lambda (name alist) + (let ((value (getenv name))) + (if value + (cons (cons name value) alist) + alist))) + '() + ;; Pass through the TERM environment variable + ;; to inform processes about the capabilities + ;; of the terminal + '("TERM")))) (unless pid (leave (_ "no pid specified~%"))) @@ -89,6 +99,9 @@ and the other containing arguments for the command to be executed." (lambda () (match command ((program . program-args) + (for-each + (match-lambda ((name . value) (setenv name value))) + environment) (apply execlp program program program-args))))))) (unless (zero? result) (leave (_ "exec failed with status ~d~%") result))))))) -- 2.11.0