builtin set --show: put read-only part on same line.

This commit is contained in:
Aaron Gyes 2022-11-12 06:18:58 -08:00
parent d31847b1d8
commit e38c9bb062
2 changed files with 6 additions and 8 deletions

View File

@ -539,13 +539,14 @@ static void show_scope(const wchar_t *var_name, int scope, io_streams_t &streams
const wchar_t *exportv = var->exports() ? _(L"exported") : _(L"unexported");
const wchar_t *pathvarv = var->is_pathvar() ? _(L" a path variable") : L"";
wcstring_list_t vals = var->as_list();
streams.out.append_format(_(L"$%ls: set in %ls scope, %ls,%ls with %d elements\n"), var_name,
streams.out.append_format(_(L"$%ls: set in %ls scope, %ls,%ls with %d elements"), var_name,
scope_name, exportv, pathvarv, vals.size());
// HACK: PWD can be set, depending on how you ask.
// For our purposes it's read-only.
if (env_var_t::flags_for(var_name) & env_var_t::flag_read_only) {
streams.out.append(_(L"Variable is read-only\n"));
streams.out.append(_(L" (read-only)\n"));
}
else streams.out.push_back(L'\n');
for (size_t i = 0; i < vals.size(); i++) {
if (vals.size() > 100) {

View File

@ -710,14 +710,12 @@ env | string match -e __fish_test_universal_exported_var
# If they can be set they can only be set in global scope,
# so they should only be shown in global scope.
set -S status
#CHECK: $status: set in global scope, unexported, with 1 elements
#CHECK: Variable is read-only
#CHECK: $status: set in global scope, unexported, with 1 elements (read-only)
#CHECK: $status[1]: |0|
# PWD is also read-only.
set -S PWD
#CHECK: $PWD: set in global scope, exported, with 1 elements
#CHECK: Variable is read-only
#CHECK: $PWD: set in global scope, exported, with 1 elements (read-only)
#CHECK: $PWD[1]: |{{.*}}|
#CHECK: $PWD: originally inherited as |{{.*}}|
@ -910,8 +908,7 @@ echo $status
set -U status
# CHECKERR: set: Tried to modify the special variable 'status' with the wrong scope
set -S status
# CHECK: $status: set in global scope, unexported, with 1 elements
# CHECK: Variable is read-only
# CHECK: $status: set in global scope, unexported, with 1 elements (read-only)
# CHECK: $status[1]: |2|
# See that we show inherited variables correctly: