all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Danny Milosavljevic <dannym@scratchpost.org>
Cc: 27180@debbugs.gnu.org
Subject: bug#27180: [PATCH core-updates] utils: Add helper method to invoke programs.
Date: Thu, 01 Jun 2017 14:13:05 +0200	[thread overview]
Message-ID: <87shjjzz1q.fsf@gnu.org> (raw)
In-Reply-To: <20170601072207.27718-1-dannym@scratchpost.org> (Danny Milosavljevic's message of "Thu, 1 Jun 2017 09:22:07 +0200")

Danny Milosavljevic <dannym@scratchpost.org> 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	other threads:[~2017-06-01 12:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-01  7:22 bug#27180: [PATCH core-updates] utils: Add helper method to invoke programs Danny Milosavljevic
2017-06-01 12:13 ` Ludovic Courtès [this message]
2017-06-01 17:09   ` Danny Milosavljevic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87shjjzz1q.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=27180@debbugs.gnu.org \
    --cc=dannym@scratchpost.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.