File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -23,9 +23,18 @@ fn expand_syntax_ext(parser.parser p,
23
23
p. err ( "malformed #env call" ) ;
24
24
}
25
25
26
+ // FIXME: if this was more thorough it would manufacture an
27
+ // Option.t[str] rather than just an maybe-empty string.
28
+
26
29
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
+ }
29
38
}
30
39
31
40
// FIXME: duplicate code copied from extfmt.
Original file line number Diff line number Diff line change 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
+ }
3
8
}
4
9
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ fn reset(IO.buf_writer writer) {
31
31
}
32
32
33
33
fn color_supported ( ) -> bool {
34
- ret Str . eq ( GenericOS . getenv ( "TERM" ) , "xterm-color" ) ;
34
+ ret GenericOS . getenv ( "TERM" ) == Option . some [ str ] ( "xterm-color" ) ;
35
35
}
36
36
37
37
fn set_color ( IO . buf_writer writer , u8 first_char , u8 color ) {
You can’t perform that action at this time.
0 commit comments