diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2022-01-05 08:00:06 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-01-09 12:25:36 +0100 |
commit | 310a18da1e7e73ed3d88eaceac3cb99bf555fed8 (patch) | |
tree | ec565271a496d5cf25b923424ed721ddd14f56b8 /Userland/Shell/AST.cpp | |
parent | 689fe7ddfff49566d18eb64a1944b521f63e582d (diff) | |
download | serenity-310a18da1e7e73ed3d88eaceac3cb99bf555fed8.zip |
Shell: Don't reset 'last_return_code' before running commands
Some variables depend on its value to function correctly.
Fixes the following issue:
$ false; echo $?
1
$ false
$ echo $?
128
Diffstat (limited to 'Userland/Shell/AST.cpp')
-rw-r--r-- | Userland/Shell/AST.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Shell/AST.cpp b/Userland/Shell/AST.cpp index b945fd9cb8..46d3db24ec 100644 --- a/Userland/Shell/AST.cpp +++ b/Userland/Shell/AST.cpp @@ -3564,7 +3564,7 @@ Vector<String> SpecialVariableValue::resolve_as_list(RefPtr<Shell> shell) switch (m_name) { case '?': - return { resolve_slices(shell, String::number(shell->last_return_code), m_slices) }; + return { resolve_slices(shell, String::number(shell->last_return_code.value_or(0)), m_slices) }; case '$': return { resolve_slices(shell, String::number(getpid()), m_slices) }; case '*': |