Created
May 17, 2014 00:36
-
-
Save major0/0beefd1c701e1a326c8b to your computer and use it in GitHub Desktop.
seq()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# One of two versions of seq() borrowed from shlib and used for some benchmarks of various /bin/sh implementations | |
seq() | |
{ | |
test "$#" -eq 1 && set -- 1 "${1}" | |
test "$#" -eq 2 && set -- "${1}" 1 "${2}" | |
test "$#" -gt 3 && die "seq: extra operand '${4}'" | |
if test "${2}" -gt '0'; then | |
while test "${1}" -le "${3}"; do | |
echo "${1}" | |
set -- "$((${1} + ${2}))" "${2}" "${3}" | |
done | |
else | |
while test "${1}" -gt "${3}"; do | |
echo "${1}" | |
set -- "$((${1} + ${2}))" "${2}" "${3}" | |
done | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment