 dashArgRegExp = /^-([a-zA-Z]{2,})$/
 
 inputCache = new Map  # maps filenames to previously loaded `Input`s
-currentInits = []     # array of currently initialized `Input`s
+currentInits = null   # array of currently initialized `Input`s
 
 class Driver extends HasSettings
   constructor: (@parent = getDriver()) ->

    ###
    @settings = cloneSettings @parent?.settings ? defaultSettings, true
    @inits = currentInits = []
    delete globalShare[key] for key of globalShare
  loadMaketile: ->
    return @maketile unless @maketile == undefined

      else
        null
  addInit: (input) ->
    @maybeInit()
    ## Now @inits == currentInits and @initsLength == currentInits.length
    @inits.push input
    @initsLength++
    input.doInit()
  maybeInit: ->
    ###
    Check whether @inits list changed and (re)initialize if so.
    If the list changed by appending items, just initialize new items.
    Otherwise, reset global `share` object (without changing object identity)
    and re-initialize all items from scratch to restore side effects.
    ###
    ## If @inits has grown without our knowledge, de-alias init lists.
    unless @initsLength == @inits.length
      @inits = @inits[...@initsLength]
    ## Cheap case: init lists are (still) identical.  Nothing to do.
    return if @inits == currentInits
    reset = (currentInits.length > @initsLength)
    unless reset
      ## currentInits is shorter or equal; check for prefix match
      for init, i in currentInits
        unless init == @inits[i]
          reset = true
          break
    if reset
      delete globalShare[key] for key of globalShare
      start = 0
    else
      start = currentInits.length
    for init in @inits[start..]
      init.doInit()
    currentInits = @inits
  main: (args = process.argv[2..]) -> runWithDriver @, =>
    @reset()
    showHelp = 'No filename arguments and no Maketile to run. Try `svgtiler --help`'
