From 56b5b78d7b33a95d0c694b556c5c9e6bbccc82bd Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Tue, 7 Mar 2023 23:28:27 +0330 Subject: [PATCH] Shell: Error out on invalid `export' argument Previously `export =` would crash the shell, make this an error instead. --- Userland/Shell/Builtin.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Userland/Shell/Builtin.cpp b/Userland/Shell/Builtin.cpp index d9cc2a60ce..71900c33ca 100644 --- a/Userland/Shell/Builtin.cpp +++ b/Userland/Shell/Builtin.cpp @@ -541,6 +541,10 @@ ErrorOr Shell::builtin_export(Main::Arguments arguments) for (auto& value : vars) { auto parts = value.split_limit('=', 2); + if (parts.is_empty()) { + warnln("Shell: Invalid export spec '{}', expected `variable=value' or `variable'", value); + return 1; + } if (parts.size() == 1) { auto value = TRY(lookup_local_variable(parts[0]));