aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/GenericOS.rs9
-rw-r--r--src/lib/Term.rs2
2 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/GenericOS.rs b/src/lib/GenericOS.rs
index c60fa2b8..30b1d1d0 100644
--- a/src/lib/GenericOS.rs
+++ b/src/lib/GenericOS.rs
@@ -1,4 +1,9 @@
-fn getenv(str n) -> str {
- ret Str.str_from_cstr(OS.libc.getenv(Str.buf(n)));
+fn getenv(str n) -> Option.t[str] {
+ auto s = OS.libc.getenv(Str.buf(n));
+ if (s == 0 as Str.sbuf) {
+ ret Option.none[str];
+ } else {
+ ret Option.some[str](Str.str_from_cstr(s));
+ }
}
diff --git a/src/lib/Term.rs b/src/lib/Term.rs
index fca04bff..b07dcc0c 100644
--- a/src/lib/Term.rs
+++ b/src/lib/Term.rs
@@ -31,7 +31,7 @@ fn reset(IO.buf_writer writer) {
}
fn color_supported() -> bool {
- ret Str.eq(GenericOS.getenv("TERM"), "xterm-color");
+ ret GenericOS.getenv("TERM") == Option.some[str]("xterm-color");
}
fn set_color(IO.buf_writer writer, u8 first_char, u8 color) {