* bug#27180: [PATCH core-updates] utils: Add helper method to invoke programs.
@ 2017-06-01 7:22 Danny Milosavljevic
2017-06-01 12:13 ` Ludovic Courtès
0 siblings, 1 reply; 3+ messages in thread
From: Danny Milosavljevic @ 2017-06-01 7:22 UTC (permalink / raw)
To: 27180
* 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)))))
+
\f
;;;
;;; Locales.
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#27180: [PATCH core-updates] utils: Add helper method to invoke programs.
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
2017-06-01 17:09 ` Danny Milosavljevic
0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2017-06-01 12:13 UTC (permalink / raw)
To: Danny Milosavljevic; +Cc: 27180
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’.
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#27180: [PATCH core-updates] utils: Add helper method to invoke programs.
2017-06-01 12:13 ` Ludovic Courtès
@ 2017-06-01 17:09 ` Danny Milosavljevic
0 siblings, 0 replies; 3+ messages in thread
From: Danny Milosavljevic @ 2017-06-01 17:09 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 27180-done
Good idea to end it with #t :)
Pushed your variant as 3f65c190d23296e7e718c3deff413e8beb61d8ba to core-updates.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-06-01 17:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2017-06-01 17:09 ` Danny Milosavljevic
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.