diff options
author | Ludovic Courtès <ludo@gnu.org> | 2013-01-29 23:59:27 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-01-30 00:09:32 +0100 |
commit | 473b03b3c6fbca909e18dbb5888ac5a98992207a (patch) | |
tree | f193b7488453c4794f67c1bec157807788af42f8 | |
parent | bdcf35a6b294c1db7ce78a5550ba51e067863069 (diff) | |
download | patches-473b03b3c6fbca909e18dbb5888ac5a98992207a.tar patches-473b03b3c6fbca909e18dbb5888ac5a98992207a.tar.gz |
Gracefully handle failure to install the current locale.
* guix/ui.scm (install-locale): New procedure.
* guix-build.in, guix-download.in, guix-gc.in, guix-import.in,
guix-package.in: Use it instead of (setlocale LC_ALL "").
-rw-r--r-- | guix-build.in | 2 | ||||
-rw-r--r-- | guix-download.in | 2 | ||||
-rw-r--r-- | guix-gc.in | 2 | ||||
-rw-r--r-- | guix-import.in | 2 | ||||
-rw-r--r-- | guix-package.in | 2 | ||||
-rw-r--r-- | guix/ui.scm | 11 |
6 files changed, 16 insertions, 5 deletions
diff --git a/guix-build.in b/guix-build.in index 4d3db0aa6d..eb8d2fa016 100644 --- a/guix-build.in +++ b/guix-build.in @@ -220,7 +220,7 @@ Build the given PACKAGE-OR-DERIVATION and return their output paths.\n")) name version) (leave (_ "~A: unknown package~%") name)))))) - (setlocale LC_ALL "") + (install-locale) (textdomain "guix") (setvbuf (current-output-port) _IOLBF) (setvbuf (current-error-port) _IOLBF) diff --git a/guix-download.in b/guix-download.in index f8859618d7..4b814699ca 100644 --- a/guix-download.in +++ b/guix-download.in @@ -134,7 +134,7 @@ and the hash of its contents.\n")) (alist-cons 'argument arg result)) %default-options)) - (setlocale LC_ALL "") + (install-locale) (textdomain "guix") (setvbuf (current-output-port) _IOLBF) (setvbuf (current-error-port) _IOLBF) diff --git a/guix-gc.in b/guix-gc.in index ab7ce3214f..1a4a5413d9 100644 --- a/guix-gc.in +++ b/guix-gc.in @@ -155,7 +155,7 @@ interpreted." (alist-cons 'argument arg result)) %default-options)) - (setlocale LC_ALL "") + (install-locale) (textdomain "guix") (setvbuf (current-output-port) _IOLBF) (setvbuf (current-error-port) _IOLBF) diff --git a/guix-import.in b/guix-import.in index af5c5897e0..97619a9a59 100644 --- a/guix-import.in +++ b/guix-import.in @@ -115,7 +115,7 @@ Import and convert the Nix expression ATTRIBUTE of NIXPKGS.\n")) (alist-cons 'argument arg result)) %default-options)) - (setlocale LC_ALL "") + (install-locale) (textdomain "guix") (setvbuf (current-output-port) _IOLBF) (setvbuf (current-error-port) _IOLBF) diff --git a/guix-package.in b/guix-package.in index 913872c925..ab0191faa2 100644 --- a/guix-package.in +++ b/guix-package.in @@ -598,7 +598,7 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n")) #t)) (_ #f)))) - (setlocale LC_ALL "") + (install-locale) (textdomain "guix") (setvbuf (current-output-port) _IOLBF) (setvbuf (current-error-port) _IOLBF) diff --git a/guix/ui.scm b/guix/ui.scm index 761b1ce444..3ec7be771b 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -26,6 +26,7 @@ #:use-module (ice-9 match) #:export (_ N_ + install-locale leave show-version-and-exit show-bug-report-information @@ -45,6 +46,16 @@ (define _ (cut gettext <> %gettext-domain)) (define N_ (cut ngettext <> <> <> %gettext-domain)) +(define (install-locale) + "Install the current locale settings." + (catch 'system-error + (lambda _ + (setlocale LC_ALL "")) + (lambda args + (format (current-error-port) + (_ "warning: failed to install locale: ~a~%") + (strerror (system-error-errno args)))))) + (define-syntax-rule (leave fmt args ...) "Format FMT and ARGS to the error port and exit." (begin |