Shell: Error out on invalid `export' argument

Previously `export =` would crash the shell, make this an error instead.
This commit is contained in:
Ali Mohammad Pur 2023-03-07 23:28:27 +03:30 committed by Ali Mohammad Pur
parent a5c47d0be3
commit 56b5b78d7b
Notes: sideshowbarker 2024-07-16 23:13:25 +09:00

View file

@ -541,6 +541,10 @@ ErrorOr<int> 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]));