Skip to content

Instantly share code, notes, and snippets.

@major0
Created May 17, 2014 00:36
Show Gist options
  • Save major0/0beefd1c701e1a326c8b to your computer and use it in GitHub Desktop.
Save major0/0beefd1c701e1a326c8b to your computer and use it in GitHub Desktop.
seq()
# 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