remove half-baked seq(1)
This commit is contained in:
parent
05954076d2
commit
e788eec085
52
bin/seq
52
bin/seq
@ -1,52 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# There are many bugs and limitations with this implementation as opposed to
|
|
||||||
# others, particularly NetBSD's. This should probably be rewritten in C.
|
|
||||||
|
|
||||||
argv0="$0"
|
|
||||||
|
|
||||||
doublecheck() {
|
|
||||||
! str isdigit "$1" \
|
|
||||||
&& printf "%s: %s: Not an unsigned integer.\n" \
|
|
||||||
"$argv0" "$1" 1>&2 \
|
|
||||||
&& exit 1 \
|
|
||||||
|| return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
error() {
|
|
||||||
printf "%s: Internal error.\n"
|
|
||||||
"$argv0" 1>&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
printf "\
|
|
||||||
Usage:
|
|
||||||
%s [last]
|
|
||||||
%s [first] [last]
|
|
||||||
%s [first] [increment] [last]
|
|
||||||
" "$argv0" "$argv0" "$argv0" 1>&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
test -n "$1" && test -z "$4" || usage
|
|
||||||
|
|
||||||
test -n "$3" && doublecheck "$3"
|
|
||||||
test -n "$2" && doublecheck "$2"
|
|
||||||
test -n "$1" && doublecheck "$1"
|
|
||||||
|
|
||||||
# all args are guaranteed to be positive integers; no need to quote variables
|
|
||||||
|
|
||||||
if test -n "$3"; then first=$1; increment=$2; last=$3
|
|
||||||
elif test -n "$2"; then first=$1; increment=1; last=$2
|
|
||||||
else first=1; increment=1; last=$1
|
|
||||||
fi
|
|
||||||
|
|
||||||
i=$first
|
|
||||||
while true; do
|
|
||||||
printf "%s\n" $i
|
|
||||||
i=$(printf "%s %s + p\n" $i $increment | dc)
|
|
||||||
printf "%s %s - p\n" $last $i | dc | grep '\-' >/dev/null 2>&1 \
|
|
||||||
&& break \
|
|
||||||
|| continue
|
|
||||||
done
|
|
Loading…
Reference in New Issue
Block a user