Supposing I have two scripts that share variables. What is the preferred way to do this, supposing I wanted to keep the variables only in one place? Is there a way to keep them script-local and not global?
Context: I'm writing two syntastic syntax checkers that both the same errorformat (because underneath they use the same compiler). What would be the preferred way to share an errorformat
variable between the two files of these syntax checkers?
I was later explained by the maintainer that since these variables aren't meant to be changed often, I should just have them in two places. This question is still here because the how-to question is still answerable, although it is no longer relevant in the original context.
errorformat
shouldn't change more often than once in a few years, so who cares. Trying to make it "shared" creates a problem instead of solving one. If you use a global variable, you need to make sure it's initialised before either checker gets to run. If you use a common include you're writing more code than you're avoiding.