mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 22:52:22 +02:00
Shell: Allow lossy conversion from list -> string in POSIX mode
Similar to bash, this operation returns only the first element because reasons.
This commit is contained in:
committed by
Ali Mohammad Pur
parent
8a042cd9cb
commit
71441ea932
Notes:
sideshowbarker
2024-07-17 06:35:16 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/71441ea932 Pull-request: https://github.com/SerenityOS/serenity/pull/18429 Reviewed-by: https://github.com/nico ✅
@@ -3691,6 +3691,17 @@ ErrorOr<Vector<String>> ListValue::resolve_as_list(RefPtr<Shell> shell)
|
||||
return resolve_slices(shell, move(values), m_slices);
|
||||
}
|
||||
|
||||
ErrorOr<String> ListValue::resolve_as_string(RefPtr<Shell> shell)
|
||||
{
|
||||
if (!shell || !shell->posix_mode())
|
||||
return Value::resolve_as_string(shell);
|
||||
|
||||
if (m_contained_values.is_empty())
|
||||
return resolve_slices(shell, String {}, m_slices);
|
||||
|
||||
return resolve_slices(shell, TRY(m_contained_values[0]->resolve_as_string(shell)), m_slices);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Value>> ListValue::resolve_without_cast(RefPtr<Shell> shell)
|
||||
{
|
||||
Vector<NonnullRefPtr<Value>> values;
|
||||
|
||||
Reference in New Issue
Block a user