guix-patches
[Top][All Lists]
Advanced

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

bug#27180: [PATCH core-updates] utils: Add helper method to invoke progr


From: Ludovic Courtès
Subject: bug#27180: [PATCH core-updates] utils: Add helper method to invoke programs.
Date: Thu, 01 Jun 2017 14:13:05 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

Danny Milosavljevic <address@hidden> skribis:

> * guix/build/utils.scm (invoke): New variable.
> ---
>  guix/build/utils.scm | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/guix/build/utils.scm b/guix/build/utils.scm
> index 6d3c29d00..b2307d9d6 100644
> --- a/guix/build/utils.scm
> +++ b/guix/build/utils.scm
> @@ -84,6 +84,7 @@
>              fold-port-matches
>              remove-store-references
>              wrap-program
> +            invoke
>  
>              locale-category->string))
>  
> @@ -1058,6 +1059,13 @@ with definitions for VARS."
>          (chmod prog-tmp #o755)
>          (rename-file prog-tmp prog))))
>  
> +(define invoke
> +  "Invokes the program (array-ref ARGS 0) and gives it ARGS.
> +   If the exit code is non-zero, raises an error."
> +  (lambda args
> +    (if (not (zero? (system* args)))
> +      (error (format #f "Failed to invoke ~a" args)))))

Good idea.  I would suggest writing it this way though:

  (define (invoke program . args)
    "Invoke PROGRAM with the given ARGS.  Raise an error if the exit
  code is non-zero; otherwise return #t."
    (let ((status (apply system* program args)))
      (unless (zero? status)
        (error (format #f "program ~s exited with non-zero code" program)
               status))
      #t))

If that’s fine with you, please push to ‘core-updates’.  (Just in time!)

Thanks,
Ludo’.





reply via email to

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