tests/seq.py
author Danek Duvall <danek.duvall@oracle.com>
Mon, 20 Jul 2015 15:33:20 -0700
branchstable
changeset 25861 11ab8714f529
parent 24360 f554f89a2038
child 28721 ff3be5a325bc
permissions -rw-r--r--
tests: use egrep with regular expression branches for compatibility GNU grep allows you to use "a\|b" in a regular expression to match either "a" or "b", but at least Solaris grep does not; only egrep allows for that. And egrep considers "a+" to be "a{1,}" instead of an "a" and a literal plus sign, so escape that as well.

#!/usr/bin/env python
#
# A portable replacement for 'seq'
#
# Usage:
#   seq STOP              [1, STOP] stepping by 1
#   seq START STOP        [START, STOP] stepping by 1
#   seq START STEP STOP   [START, STOP] stepping by STEP

import sys

start = 1
if len(sys.argv) > 2:
    start = int(sys.argv[1])

step = 1
if len(sys.argv) > 3:
    step = int(sys.argv[2])

stop = int(sys.argv[-1]) + 1

for i in xrange(start, stop, step):
    print i