* [PATCH] scripts: container: Pass through TERM when calling exec
@ 2017-01-25 7:24 Christopher Baines
2017-01-25 13:24 ` Ludovic Courtès
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Christopher Baines @ 2017-01-25 7:24 UTC (permalink / raw)
To: guix-devel
* 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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] scripts: container: Pass through TERM when calling exec
2017-01-25 7:24 [PATCH] scripts: container: Pass through TERM when calling exec Christopher Baines
@ 2017-01-25 13:24 ` Ludovic Courtès
2017-01-25 13:28 ` Ludovic Courtès
2017-01-25 16:00 ` Thompson, David
2 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2017-01-25 13:24 UTC (permalink / raw)
To: Christopher Baines; +Cc: guix-devel
Christopher Baines <mail@cbaines.net> skribis:
> * 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.
Good idea. Applied, thanks!
Ludo’.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scripts: container: Pass through TERM when calling exec
2017-01-25 7:24 [PATCH] scripts: container: Pass through TERM when calling exec Christopher Baines
2017-01-25 13:24 ` Ludovic Courtès
@ 2017-01-25 13:28 ` Ludovic Courtès
2017-01-25 16:00 ` Thompson, David
2 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2017-01-25 13:28 UTC (permalink / raw)
To: Christopher Baines; +Cc: guix-devel
Christopher Baines <mail@cbaines.net> skribis:
> + (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"))))
I changed that to ‘filter-map’, which is slightly more concise.
Ludo’.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scripts: container: Pass through TERM when calling exec
2017-01-25 7:24 [PATCH] scripts: container: Pass through TERM when calling exec Christopher Baines
2017-01-25 13:24 ` Ludovic Courtès
2017-01-25 13:28 ` Ludovic Courtès
@ 2017-01-25 16:00 ` Thompson, David
2 siblings, 0 replies; 4+ messages in thread
From: Thompson, David @ 2017-01-25 16:00 UTC (permalink / raw)
To: Christopher Baines; +Cc: guix-devel
Hey Christopher,
On Wed, Jan 25, 2017 at 2:24 AM, Christopher Baines <mail@cbaines.net> wrote:
> * 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.
Good idea! Thanks for doing this!
- Dave
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-01-25 16:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-25 7:24 [PATCH] scripts: container: Pass through TERM when calling exec Christopher Baines
2017-01-25 13:24 ` Ludovic Courtès
2017-01-25 13:28 ` Ludovic Courtès
2017-01-25 16:00 ` Thompson, David
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).