diff options
author | 2011-07-28 19:50:44 +0800 | |
---|---|---|
committer | 2011-08-02 15:52:19 +0800 | |
commit | 9bfb2dbd4180e1171db2026fb58646045c1e7144 (patch) | |
tree | 11ec06d9a84e27cac0699b49e252583915680109 /src | |
parent | Parser: split token compositions (diff) | |
download | libbash-9bfb2dbd4180e1171db2026fb58646045c1e7144.tar.gz libbash-9bfb2dbd4180e1171db2026fb58646045c1e7144.tar.bz2 libbash-9bfb2dbd4180e1171db2026fb58646045c1e7144.zip |
Walker: support expansions without colon
Diffstat (limited to 'src')
-rw-r--r-- | src/core/interpreter.h | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/core/interpreter.h b/src/core/interpreter.h index 1ee02dd..091d4b7 100644 --- a/src/core/interpreter.h +++ b/src/core/interpreter.h @@ -372,12 +372,12 @@ public: /// \param value the value of the word /// \param index the index of the paramter /// \return the expansion result - const std::string do_default_expansion(const std::string& name, + const std::string do_default_expansion(bool cond, + const std::string& name, const std::string& value, const unsigned index) const { - return (is_unset_or_null(name, index)? - value : resolve<std::string>(name, index)); + return (cond ? value : resolve<std::string>(name, index)); } /// \brief perform ${parameter:=word} expansion @@ -385,12 +385,12 @@ public: /// \param value the value of the word /// \param index the index of the paramter /// \return the expansion result - const std::string do_assign_expansion(const std::string& name, + const std::string do_assign_expansion(bool cond, + const std::string& name, const std::string& value, const unsigned index) { - return (is_unset_or_null(name, index)? - set_value(name, value, index) : resolve<std::string>(name, index)); + return (cond ? set_value(name, value, index) : resolve<std::string>(name, index)); } /// \brief perform ${parameter:+word} expansion @@ -398,11 +398,10 @@ public: /// \param value the value of the word /// \param index the index of the paramter /// \return the expansion result - const std::string do_alternate_expansion(const std::string& name, - const std::string& value, - const unsigned index) const + const std::string do_alternate_expansion(bool cond, + const std::string& value) const { - return (is_unset_or_null(name, index)? "" : value); + return (cond ? "" : value); } /// \brief perform substring expansion |