Skip to content

Commit ac1df73

Browse files
committed
---
yaml --- r: 2413 b: refs/heads/master c: 0f23bba h: refs/heads/master i: 2411: 18c47ee v: v3
1 parent a392feb commit ac1df73

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: e2f7f11d471f30f49e858b88c0c0411fc5d5e187
2+
refs/heads/master: 0f23bbac0104fe4c51923eb09b7a98c3e6239571

trunk/src/comp/front/extenv.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,18 @@ fn expand_syntax_ext(parser.parser p,
2323
p.err("malformed #env call");
2424
}
2525

26+
// FIXME: if this was more thorough it would manufacture an
27+
// Option.t[str] rather than just an maybe-empty string.
28+
2629
auto var = expr_to_str(p, args.(0));
27-
auto val = GenericOS.getenv(var);
28-
ret make_new_str(sp, val);
30+
alt (GenericOS.getenv(var)) {
31+
case (Option.none[str]) {
32+
ret make_new_str(sp, "");
33+
}
34+
case (Option.some[str](?s)) {
35+
ret make_new_str(sp, s);
36+
}
37+
}
2938
}
3039

3140
// FIXME: duplicate code copied from extfmt.

trunk/src/lib/GenericOS.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
fn getenv(str n) -> str {
2-
ret Str.str_from_cstr(OS.libc.getenv(Str.buf(n)));
1+
fn getenv(str n) -> Option.t[str] {
2+
auto s = OS.libc.getenv(Str.buf(n));
3+
if (s == 0 as Str.sbuf) {
4+
ret Option.none[str];
5+
} else {
6+
ret Option.some[str](Str.str_from_cstr(s));
7+
}
38
}
49

trunk/src/lib/Term.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn reset(IO.buf_writer writer) {
3131
}
3232

3333
fn color_supported() -> bool {
34-
ret Str.eq(GenericOS.getenv("TERM"), "xterm-color");
34+
ret GenericOS.getenv("TERM") == Option.some[str]("xterm-color");
3535
}
3636

3737
fn set_color(IO.buf_writer writer, u8 first_char, u8 color) {

0 commit comments

Comments
 (0)