mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
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 "").
This commit is contained in:
parent
bdcf35a6b2
commit
473b03b3c6
6 changed files with 16 additions and 5 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
11
guix/ui.scm
11
guix/ui.scm
|
@ -26,6 +26,7 @@ (define-module (guix ui)
|
|||
#:use-module (ice-9 match)
|
||||
#:export (_
|
||||
N_
|
||||
install-locale
|
||||
leave
|
||||
show-version-and-exit
|
||||
show-bug-report-information
|
||||
|
@ -45,6 +46,16 @@ (define %gettext-domain
|
|||
(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
|
||||
|
|
Loading…
Reference in a new issue