diff options
author | Ludovic Courtès <ludo@gnu.org> | 2015-10-28 15:53:17 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2015-10-28 15:53:17 +0100 |
commit | fd688c82bf4ee543dbb5f55bf3913668c4bf4483 (patch) | |
tree | 13f5647663f9cf3980fd89db6a392df98cd3a367 /guix/ui.scm | |
parent | 35b50a753563c03a57d98761d7ebff12efdd5c3d (diff) | |
download | gnu-guix-fd688c82bf4ee543dbb5f55bf3913668c4bf4483.tar gnu-guix-fd688c82bf4ee543dbb5f55bf3913668c4bf4483.tar.gz |
ui: Add 'make-regexp*'.
Fixes <http://bugs.gnu.org/21773>.
Reported by Jan Synáček <jan.synacek@gmail.com>.
* guix/ui.scm (make-regexp*): New procedure.
* guix/scripts/package.scm (options->installable, guix-package): Use it
when processing user-provided regexps.
Diffstat (limited to 'guix/ui.scm')
-rw-r--r-- | guix/ui.scm | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/guix/ui.scm b/guix/ui.scm index 72208e7de7..312c2a01a1 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -61,6 +61,7 @@ warn-about-load-error show-version-and-exit show-bug-report-information + make-regexp* string->number* size->number show-derivation-outputs @@ -350,6 +351,16 @@ General help using GNU software: <http://www.gnu.org/gethelp/>")) (list (strerror (car errno)) target) (list errno))))))) +(define (make-regexp* regexp . flags) + "Like 'make-regexp' but error out if REGEXP is invalid, reporting the error +nicely." + (catch 'regular-expression-syntax + (lambda () + (apply make-regexp regexp flags)) + (lambda (key proc message . rest) + (leave (_ "'~a' is not a valid regular expression: ~a~%") + regexp message)))) + (define (string->number* str) "Like `string->number', but error out with an error message on failure." (or (string->number str) |