diff --git a/src/parser.cpp b/src/parser.cpp index fd33f58fd..ce79a0c04 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -100,7 +100,7 @@ static wcstring user_presentable_path(const wcstring &path) { return replace_home_directory_with_tilde(path); } -parser_t::parser_t() = default; +parser_t::parser_t() : variables(env_stack_t::principal()) {} // Out of line destructor to enable forward declaration of parse_execution_context_t parser_t::~parser_t() = default; diff --git a/src/parser.h b/src/parser.h index bfeea4406..deef053ac 100644 --- a/src/parser.h +++ b/src/parser.h @@ -173,7 +173,8 @@ class parser_t { std::vector> block_stack; /// The 'depth' of the fish call stack. int eval_level = -1; - + /// Set of variables for the parser. + env_stack_t &variables; #if 0 // TODO: Lint says this isn't used (which is true). Should this be removed? /// Gets a description of the block stack, for debugging. @@ -271,6 +272,10 @@ class parser_t { /// Get the list of jobs. job_list_t &job_list() { return my_job_list; } + /// Get the variables. + env_stack_t &vars() { return variables; } + const env_stack_t &vars() const { return variables; } + /// Pushes a new block created with the given arguments /// Returns a pointer to the block. The pointer is valid /// until the call to pop_block()