2019-06-27 00:57:10 +08:00
|
|
|
#RUN: %fish %s
|
2017-07-06 08:22:48 +08:00
|
|
|
# Validate the behavior of the `count` command.
|
|
|
|
|
2019-06-27 00:57:10 +08:00
|
|
|
# no args
|
2017-07-06 08:22:48 +08:00
|
|
|
count
|
2019-06-27 00:57:10 +08:00
|
|
|
# CHECK: 0
|
2017-07-06 08:22:48 +08:00
|
|
|
|
2019-06-27 00:57:10 +08:00
|
|
|
# one args
|
2017-07-06 08:22:48 +08:00
|
|
|
count x
|
2019-06-27 00:57:10 +08:00
|
|
|
# CHECK: 1
|
2017-07-06 08:22:48 +08:00
|
|
|
|
2019-06-27 00:57:10 +08:00
|
|
|
# two args
|
2017-07-06 08:22:48 +08:00
|
|
|
count x y
|
2019-06-27 00:57:10 +08:00
|
|
|
# CHECK: 2
|
2017-07-06 08:22:48 +08:00
|
|
|
|
2019-06-27 00:57:10 +08:00
|
|
|
# args that look like flags or are otherwise special
|
2017-07-06 08:22:48 +08:00
|
|
|
count -h
|
2019-06-27 00:57:10 +08:00
|
|
|
# CHECK: 1
|
2017-07-06 08:22:48 +08:00
|
|
|
count --help
|
2019-06-27 00:57:10 +08:00
|
|
|
# CHECK: 1
|
2017-07-06 08:22:48 +08:00
|
|
|
count --
|
2019-06-27 00:57:10 +08:00
|
|
|
# CHECK: 1
|
2017-07-06 08:22:48 +08:00
|
|
|
count -- abc
|
2019-06-27 00:57:10 +08:00
|
|
|
# CHECK: 2
|
2017-07-06 08:22:48 +08:00
|
|
|
count def -- abc
|
2019-06-27 00:57:10 +08:00
|
|
|
# CHECK: 3
|
2019-02-01 17:58:06 +08:00
|
|
|
|
2019-06-27 00:57:10 +08:00
|
|
|
# big counts
|
2019-02-01 17:58:06 +08:00
|
|
|
|
|
|
|
# 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
|
|
|
|
2019-06-27 00:57:10 +08:00
|
|
|
# stdin
|
2018-01-04 07:42:12 +08:00
|
|
|
# Reading from stdin still counts the arguments
|
|
|
|
printf '%s\n' 1 2 3 4 5 | count 6 7 8 9 10
|
2019-06-27 00:57:10 +08:00
|
|
|
# CHECK: 10
|
2018-01-04 07:42:12 +08:00
|
|
|
|
|
|
|
# Reading from stdin counts newlines - like `wc -l`.
|
|
|
|
echo -n 0 | count
|
2019-06-27 00:57:10 +08:00
|
|
|
# CHECK: 0
|
2018-01-04 07:42:12 +08:00
|
|
|
|
|
|
|
echo 1 | count
|
2019-06-27 00:57:10 +08:00
|
|
|
# CHECK: 1
|