modify show test helper to work around BSD quirk

The BSD `seq` command handles `seq 0` weird.
This commit is contained in:
Kurtis Rader 2017-07-19 23:14:37 -07:00
parent 627ce4ea34
commit 2c77b24ced

View file

@ -4,9 +4,13 @@ function show --no-scope-shadowing
if set -q $v if set -q $v
set -l c (count $$v) set -l c (count $$v)
printf '$%s count=%d\n' $v $c printf '$%s count=%d\n' $v $c
# This test is to work around a bogosity of the BSD `seq` command. If called with
# `seq 0` it emits `1`, `0`. Whereas that GNU version outputs nothing.
if test $c -gt 0
for i in (seq $c) for i in (seq $c)
printf '$%s[%d]=|%s|\n' $v $i $$v[1][$i] printf '$%s[%d]=|%s|\n' $v $i $$v[1][$i]
end end
end
else else
echo \$$v is not set echo \$$v is not set
end end