diff --git a/src/builtin_set.cpp b/src/builtin_set.cpp index 41ab75aeb..9d45f9e80 100644 --- a/src/builtin_set.cpp +++ b/src/builtin_set.cpp @@ -539,7 +539,7 @@ static void show_scope(const wchar_t *var_name, int scope, io_streams_t &streams const env_var_t var = env_get(var_name, scope | ENV_USER); wcstring_list_t result; - if (!var.empty()) var.to_list(result); + var.to_list(result); streams.out.append_format(_(L"$%ls: set in %ls scope, %ls, with %d elements\n"), var_name, scope_name, exportv, result.size()); diff --git a/tests/set.in b/tests/set.in index 74ddb9232..46415de69 100644 --- a/tests/set.in +++ b/tests/set.in @@ -4,6 +4,9 @@ logmsg Verify behavior of `set --show` given an invalid var name set --show 'argle bargle' logmsg Verify behavior of `set --show` +set semiempty '' +set --show semiempty + set -U var1 hello set --show var1 diff --git a/tests/set.out b/tests/set.out index b094b0107..561d24cea 100644 --- a/tests/set.out +++ b/tests/set.out @@ -4,6 +4,11 @@ #################### # Verify behavior of `set --show` +$semiempty: not set in local scope +$semiempty: set in global scope, unexported, with 1 elements +$semiempty[1]: length=0 value=|| +$semiempty: not set in universal scope + $var1: not set in local scope $var1: not set in global scope $var1: set in universal scope, unexported, with 1 elements diff --git a/tests/test_cmdsub.out b/tests/test_cmdsub.out index 26011ce4b..53872dc00 100644 --- a/tests/test_cmdsub.out +++ b/tests/test_cmdsub.out @@ -17,7 +17,8 @@ $b: not set in universal scope #################### # Command sub over the limit should fail $c: not set in local scope -$c: set in global scope, unexported, with 0 elements +$c: set in global scope, unexported, with 1 elements +$c[1]: length=0 value=|| $c: not set in universal scope