Shorten set --show output

Changes it from

```
$fish_color_user: not set in local scope
$fish_color_user: set in global scope, unexported, with 1 elements
$fish_color_user[1]: length=3 value=|080|
$fish_color_user: set in universal scope, unexported, with 1 elements
$fish_color_user[1]: length=7 value=|brgreen|

```

(with the trailing empty line - not just a newline)

to

```
$fish_color_user: set in global scope, unexported, with 1 elements
$fish_color_user[1]: |080|
$fish_color_user: set in universal scope, unexported, with 1 elements
$fish_color_user[1]: |brgreen|
```
This commit is contained in:
Fabian Homborg
2020-04-25 18:33:47 +02:00
parent feb40f0cd6
commit 6990c44443
6 changed files with 70 additions and 145 deletions

View File

@@ -575,7 +575,6 @@ static void show_scope(const wchar_t *var_name, int scope, io_streams_t &streams
const auto var = vars.get(var_name, scope);
if (!var) {
streams.out.append_format(_(L"$%ls: not set in %ls scope\n"), var_name, scope_name);
return;
}
@@ -595,8 +594,8 @@ static void show_scope(const wchar_t *var_name, int scope, io_streams_t &streams
}
const wcstring value = vals[i];
const wcstring escaped_val = escape_string(value, ESCAPE_NO_QUOTED, STRING_STYLE_SCRIPT);
streams.out.append_format(_(L"$%ls[%d]: length=%d value=|%ls|\n"), var_name, i + 1,
value.size(), escaped_val.c_str());
streams.out.append_format(_(L"$%ls[%d]: |%ls|\n"), var_name, i + 1,
escaped_val.c_str());
}
}
@@ -613,7 +612,6 @@ static int builtin_set_show(const wchar_t *cmd, const set_cmd_opts_t &opts, int
show_scope(name.c_str(), ENV_LOCAL, streams, vars);
show_scope(name.c_str(), ENV_GLOBAL, streams, vars);
show_scope(name.c_str(), ENV_UNIVERSAL, streams, vars);
streams.out.push_back(L'\n');
}
} else {
for (int i = 0; i < argc; i++) {
@@ -634,7 +632,6 @@ static int builtin_set_show(const wchar_t *cmd, const set_cmd_opts_t &opts, int
show_scope(arg, ENV_LOCAL, streams, vars);
show_scope(arg, ENV_GLOBAL, streams, vars);
show_scope(arg, ENV_UNIVERSAL, streams, vars);
streams.out.push_back(L'\n');
}
}