mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +00: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:
parent
8a042cd9cb
commit
71441ea932
2 changed files with 12 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue