Move script detection into a helper function that returns the interpreter.