def mutateScript(context, script, mutator):
    """Apply `mutator` function to every command in the `script` array of
    strings. The mutator function is called with `context` and the string to
    be mutated and must return the modified string. Sets `context.tmpBase`
    to a path unique to every command."""
    previous_tmpbase = context.tmpBase
    i = 0
    mutated_script = []
    for line in script:
        number = ""
        if len(script) > 1:
            number = "-%s" % (i,)
            i += 1
        context.tmpBase = previous_tmpbase + number

        mutated_line = mutator(context, line)
        mutated_script.append(mutated_line)
    return mutated_script