2017-07-06 08:22:48 +08:00
|
|
|
# Validate the behavior of the `count` command.
|
|
|
|
|
2017-08-05 02:41:51 +08:00
|
|
|
logmsg no args
|
2017-07-06 08:22:48 +08:00
|
|
|
count
|
|
|
|
|
2017-08-05 02:41:51 +08:00
|
|
|
logmsg one args
|
2017-07-06 08:22:48 +08:00
|
|
|
count x
|
|
|
|
|
2017-08-05 02:41:51 +08:00
|
|
|
logmsg two args
|
2017-07-06 08:22:48 +08:00
|
|
|
count x y
|
|
|
|
|
2017-08-05 02:41:51 +08:00
|
|
|
logmsg args that look like flags or are otherwise special
|
2017-07-06 08:22:48 +08:00
|
|
|
count -h
|
|
|
|
count --help
|
|
|
|
count --
|
|
|
|
count -- abc
|
|
|
|
count def -- abc
|
2019-02-01 17:58:06 +08:00
|
|
|
|
|
|
|
logmsg big counts
|
|
|
|
|
|
|
|
# See #5611
|
|
|
|
for i in seq 500
|
|
|
|
set c1 (count (seq 1 10000))
|
|
|
|
test $c1 -eq 10000
|
|
|
|
or begin
|
|
|
|
echo "Count $c1 is not 10000"
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
2018-01-04 07:42:12 +08:00
|
|
|
|
|
|
|
logmsg stdin
|
|
|
|
# Reading from stdin still counts the arguments
|
|
|
|
printf '%s\n' 1 2 3 4 5 | count 6 7 8 9 10
|
|
|
|
|
|
|
|
# Reading from stdin counts newlines - like `wc -l`.
|
|
|
|
echo -n 0 | count
|
|
|
|
|
|
|
|
echo 1 | count
|