From: "Ludovic Courtès" <ludo@gnu.org>
To: 30772@debbugs.gnu.org
Subject: [bug#30772] [PATCH 1/2] utils: Add 'false-if-file-not-found'.
Date: Sun, 11 Mar 2018 22:49:50 +0100 [thread overview]
Message-ID: <20180311214951.14709-1-ludo@gnu.org> (raw)
In-Reply-To: <20180311211253.13430-1-ludo@gnu.org>
* guix/build/utils.scm (false-if-file-not-found): New macro.
---
guix/build/utils.scm | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index d7ed3d517..ab309aa0d 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
@@ -61,6 +61,7 @@
delete-file-recursively
file-name-predicate
find-files
+ false-if-file-not-found
search-path-as-list
set-path-environment-variable
@@ -396,6 +397,15 @@ also be included. If FAIL-ON-ERROR? is true, raise an exception upon error."
stat)
string<?)))
+(define-syntax-rule (false-if-file-not-found exp)
+ "Evaluate EXP but return #f if it raises to 'system-error with ENOENT."
+ (catch 'system-error
+ (lambda () exp)
+ (lambda args
+ (if (= ENOENT (system-error-errno args))
+ #f
+ (apply throw args)))))
+
\f
;;;
;;; Search paths.
--
2.16.2
next prev parent reply other threads:[~2018-03-11 21:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-11 21:12 [bug#30772] [PATCH 0/2] Factorize the 'bootstrap' phase Ludovic Courtès
2018-03-11 21:49 ` Ludovic Courtès [this message]
2018-03-11 21:49 ` [bug#30772] [PATCH 2/2] build-system/gnu: Add " Ludovic Courtès
2018-03-14 11:18 ` bug#30772: [PATCH 0/2] Factorize the " Ludovic Courtès
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=20180311214951.14709-1-ludo@gnu.org \
--to=ludo@gnu.org \
--cc=30772@debbugs.gnu.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.