fix set --show output

I realized I was printing individual var entries using zero based
indexing (like C++) when the indexes should be one based.
This commit is contained in:
Kurtis Rader 2017-08-04 17:08:25 -07:00
parent 9028104536
commit cddc4cfb1d
5 changed files with 29 additions and 29 deletions

View file

@ -544,7 +544,7 @@ static void show_scope(const wchar_t *var_name, int scope, io_streams_t &streams
const wcstring value = result[i];
const wcstring escaped_val =
escape_string(value.c_str(), ESCAPE_NO_QUOTED, STRING_STYLE_SCRIPT);
streams.out.append_format(_(L"$%ls[%d]: length=%d value=|%ls|\n"), var_name, i,
streams.out.append_format(_(L"$%ls[%d]: length=%d value=|%ls|\n"), var_name, i + 1,
value.size(), escaped_val.c_str());
}
} else {

View file

@ -5,23 +5,23 @@
####################
# Testing -V
$foo: set in local scope, unexported, with 1 elements
$foo[0]: length=9 value=|local foo|
$foo[1]: length=9 value=|local foo|
$foo: set in global scope, unexported, with 1 elements
$foo[0]: length=10 value=|global foo|
$foo[1]: length=10 value=|global foo|
$foo: not set in universal scope
$bar: set in local scope, unexported, with 5 elements
$bar[0]: length=3 value=|one|
$bar[1]: length=8 value=|two 2|
$bar[2]: length=1 value=|\t|
$bar[3]: length=0 value=||
$bar[4]: length=1 value=|3|
$bar[1]: length=3 value=|one|
$bar[2]: length=8 value=|two 2|
$bar[3]: length=1 value=|\t|
$bar[4]: length=0 value=||
$bar[5]: length=1 value=|3|
$bar: set in global scope, unexported, with 5 elements
$bar[0]: length=3 value=|one|
$bar[1]: length=8 value=|two 2|
$bar[2]: length=1 value=|\t|
$bar[3]: length=0 value=||
$bar[4]: length=1 value=|3|
$bar[1]: length=3 value=|one|
$bar[2]: length=8 value=|two 2|
$bar[3]: length=1 value=|\t|
$bar[4]: length=0 value=||
$bar[5]: length=1 value=|3|
$bar: not set in universal scope
$baz: set in local scope, unexported, with 0 elements
@ -32,24 +32,24 @@ $baz: not set in universal scope
####################
# Testing -V with changed variables
$foo: set in local scope, unexported, with 1 elements
$foo[0]: length=9 value=|local foo|
$foo[1]: length=9 value=|local foo|
$foo: set in global scope, unexported, with 1 elements
$foo[0]: length=10 value=|global foo|
$foo[1]: length=10 value=|global foo|
$foo: not set in universal scope
$bar: set in local scope, unexported, with 5 elements
$bar[0]: length=3 value=|one|
$bar[1]: length=8 value=|two 2|
$bar[2]: length=1 value=|\t|
$bar[3]: length=0 value=||
$bar[4]: length=1 value=|3|
$bar[1]: length=3 value=|one|
$bar[2]: length=8 value=|two 2|
$bar[3]: length=1 value=|\t|
$bar[4]: length=0 value=||
$bar[5]: length=1 value=|3|
$bar: set in global scope, unexported, with 1 elements
$bar[0]: length=7 value=|bad bar|
$bar[1]: length=7 value=|bad bar|
$bar: not set in universal scope
$baz: set in local scope, unexported, with 0 elements
$baz: set in global scope, unexported, with 1 elements
$baz[0]: length=7 value=|bad baz|
$baz[1]: length=7 value=|bad baz|
$baz: not set in universal scope
Function name1 found

View file

@ -76,12 +76,12 @@ Chunked reads test pass
# Confirm reading non-interactively works -- #4206 regression
$a: not set in local scope
$a: set in global scope, unexported, with 1 elements
$a[0]: length=3 value=|abc|
$a[1]: length=3 value=|abc|
$a: not set in universal scope
$b: not set in local scope
$b: set in global scope, unexported, with 1 elements
$b[0]: length=3 value=|def|
$b[1]: length=3 value=|def|
$b: not set in universal scope

View file

@ -7,14 +7,14 @@
$var1: not set in local scope
$var1: not set in global scope
$var1: set in universal scope, unexported, with 1 elements
$var1[0]: length=5 value=|hello|
$var1[1]: length=5 value=|hello|
$var1: set in local scope, unexported, with 0 elements
$var1: set in global scope, unexported, with 2 elements
$var1[0]: length=7 value=|goodbye|
$var1[1]: length=19 value=|and don\'t come back|
$var1[1]: length=7 value=|goodbye|
$var1[2]: length=19 value=|and don\'t come back|
$var1: set in universal scope, unexported, with 1 elements
$var1[0]: length=5 value=|hello|
$var1[1]: length=5 value=|hello|
$_unset_var: not set in local scope
$_unset_var: not set in global scope

View file

@ -3,7 +3,7 @@
# Command sub just under the limit should succeed
$a: not set in local scope
$a: set in global scope, unexported, with 1 elements
$a[0]: length=511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