From 8a042cd9cbbc85538a4f77a0016a11a09bcd69bf Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Wed, 19 Apr 2023 12:16:23 +0330 Subject: [PATCH] Shell: Allow non-exhaustive 'case' statements in POSIX --- Userland/Shell/AST.cpp | 4 +++- Userland/Shell/Shell.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Userland/Shell/AST.cpp b/Userland/Shell/AST.cpp index 45dd80f8e7..f155304c6d 100644 --- a/Userland/Shell/AST.cpp +++ b/Userland/Shell/AST.cpp @@ -2363,7 +2363,9 @@ ErrorOr> MatchExpr::run(RefPtr shell) return move(result).get>(); } - shell->raise_error(Shell::ShellError::EvaluatedSyntaxError, "Non-exhaustive match rules!", position()); + // Non-exhaustive 'case' statements are valid in POSIX. + if (!shell || !shell->posix_mode()) + shell->raise_error(Shell::ShellError::EvaluatedSyntaxError, "Non-exhaustive match rules!", position()); return make_ref_counted({}); } diff --git a/Userland/Shell/Shell.h b/Userland/Shell/Shell.h index 2babf1a4ce..b4e7501c88 100644 --- a/Userland/Shell/Shell.h +++ b/Userland/Shell/Shell.h @@ -308,6 +308,8 @@ public: void notify_child_event(); + bool posix_mode() const { return m_in_posix_mode; } + struct termios termios; struct termios default_termios; bool was_interrupted { false };