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.
This commit is contained in:
David Thompson 2015-11-03 18:05:43 -05:00
parent bab020d7ca
commit d431b23240
1 changed files with 12 additions and 4 deletions

View File

@ -50,10 +50,18 @@ Execute COMMMAND within the container process PID.\n"))
(define (partition-args args) (define (partition-args args)
"Split ARGS into two lists; one containing the arguments for this program, "Split ARGS into two lists; one containing the arguments for this program,
and the other containing arguments for the command to be executed." and the other containing arguments for the command to be executed."
(break (lambda (arg) (define (number-string? str)
;; Split after the pid argument. (false-if-exception (string->number str)))
(not (false-if-exception (string->number arg))))
args)) (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 (guix-container-exec . args)
(define (handle-argument arg result) (define (handle-argument arg result)