1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:27:44 +00:00

Shell: Immediately resolve value when setting a variable

The lazy resolution mechanism made it so that the variables were linked
together, causing unexpected behaviour:

    true
    x=$? # expected: x=0
    false
    echo $x # expected: 0, actual: 1
This commit is contained in:
Ali Mohammad Pur 2022-07-02 19:30:22 +04:30 committed by Ali Mohammad Pur
parent f94c7fc880
commit 6e24d845e0
2 changed files with 19 additions and 3 deletions

View file

@ -381,6 +381,7 @@ class SpecialVariableValue final : public Value {
public:
virtual Vector<String> resolve_as_list(RefPtr<Shell>) override;
virtual String resolve_as_string(RefPtr<Shell>) override;
virtual NonnullRefPtr<Value> resolve_without_cast(RefPtr<Shell>) override;
virtual NonnullRefPtr<Value> clone() const override { return make_ref_counted<SpecialVariableValue>(m_name)->set_slices(m_slices); }
virtual ~SpecialVariableValue();
SpecialVariableValue(char name)
@ -512,9 +513,15 @@ protected:
RefPtr<SyntaxError> m_syntax_error_node;
};
#define NODE(name) \
virtual String class_name() const override { return #name; } \
virtual Kind kind() const override { return Kind::name; }
#define NODE(name) \
virtual String class_name() const override \
{ \
return #name; \
} \
virtual Kind kind() const override \
{ \
return Kind::name; \
}
class PathRedirectionNode : public Node {
public: