From 0f23bbac0104fe4c51923eb09b7a98c3e6239571 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 6 May 2011 16:30:39 -0700 Subject: Fix GenericOS.getenv returning a raw str, return an Option.t[str] instead. --- src/comp/front/extenv.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/comp') diff --git a/src/comp/front/extenv.rs b/src/comp/front/extenv.rs index a3fdde95..15483cec 100644 --- a/src/comp/front/extenv.rs +++ b/src/comp/front/extenv.rs @@ -23,9 +23,18 @@ fn expand_syntax_ext(parser.parser p, p.err("malformed #env call"); } + // FIXME: if this was more thorough it would manufacture an + // Option.t[str] rather than just an maybe-empty string. + auto var = expr_to_str(p, args.(0)); - auto val = GenericOS.getenv(var); - ret make_new_str(sp, val); + alt (GenericOS.getenv(var)) { + case (Option.none[str]) { + ret make_new_str(sp, ""); + } + case (Option.some[str](?s)) { + ret make_new_str(sp, s); + } + } } // FIXME: duplicate code copied from extfmt. -- cgit v1.2.3