Gracefully handle `setlocale' errors at the REPL.
authorLudovic Courtès <ludo@gnu.org>
Tue, 26 Apr 2011 22:57:16 +0000 (00:57 +0200)
committerLudovic Courtès <ludo@gnu.org>
Tue, 26 Apr 2011 22:57:53 +0000 (00:57 +0200)
* module/ice-9/top-repl.scm (top-repl): Catch exceptions from
  `setlocale'.  Reported by CRLF0710 <crlf0710@gmail.com>.

module/ice-9/top-repl.scm

index 64c0239977a60f857d6fa892d8b8c9188f0cf1b5..d43436c4aa1312ec4142384441c8664b636d5d73 100644 (file)
     (call-with-sigint
      (lambda ()
        (and (defined? 'setlocale)
-            (setlocale LC_ALL ""))
+            (catch 'system-error
+              (lambda ()
+                (setlocale LC_ALL ""))
+              (lambda (key subr fmt args errno)
+                (format (current-error-port)
+                        "warning: failed to install locale: ~a~%"
+                        (strerror (car errno))))))
+
        (let ((status (start-repl 'scheme)))
          (run-hook exit-hook)
          status)))))