From e38c9bb062edb84f31c81d269b19cce5b6492c86 Mon Sep 17 00:00:00 2001 From: Aaron Gyes Date: Sat, 12 Nov 2022 06:18:58 -0800 Subject: [PATCH] builtin set --show: put read-only part on same line. --- src/builtins/set.cpp | 5 +++-- tests/checks/set.fish | 9 +++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/builtins/set.cpp b/src/builtins/set.cpp index 1adae234b..15375dab1 100644 --- a/src/builtins/set.cpp +++ b/src/builtins/set.cpp @@ -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) { diff --git a/tests/checks/set.fish b/tests/checks/set.fish index db936a54d..6d99ecd42 100644 --- a/tests/checks/set.fish +++ b/tests/checks/set.fish @@ -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: