guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/01: scripts: container: Fix 'exec' command line parsing.


From: David Thompson
Subject: 01/01: scripts: container: Fix 'exec' command line parsing.
Date: Tue, 03 Nov 2015 23:07:06 +0000

davexunit pushed a commit to branch master
in repository guix.

commit d431b232403fbf4d41617ba29664dcd3fff23f96
Author: David Thompson <address@hidden>
Date:   Tue Nov 3 18:05:43 2015 -0500

    scripts: container: Fix 'exec' command line parsing.
    
    * guix/scripts/container/exec.scm (partition-args): Reimplement such
      that all args up to and including the PID are returned as the first of
      the two values.
---
 guix/scripts/container/exec.scm |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/guix/scripts/container/exec.scm b/guix/scripts/container/exec.scm
index b842fd3..10e7056 100644
--- a/guix/scripts/container/exec.scm
+++ b/guix/scripts/container/exec.scm
@@ -50,10 +50,18 @@ Execute COMMMAND within the container process PID.\n"))
 (define (partition-args args)
   "Split ARGS into two lists; one containing the arguments for this program,
 and the other containing arguments for the command to be executed."
-  (break (lambda (arg)
-           ;; Split after the pid argument.
-           (not (false-if-exception (string->number arg))))
-         args))
+  (define (number-string? str)
+    (false-if-exception (string->number str)))
+
+  (let loop ((a '())
+             (b args))
+    (match b
+      (()
+       (values (reverse a) '()))
+      (((? number-string? head) . tail)
+       (values (reverse (cons head a)) tail))
+      ((head . tail)
+       (loop (cons head a) tail)))))
 
 (define (guix-container-exec . args)
   (define (handle-argument arg result)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]