title: A semantics for Bash scripts?
body: <p>More than any other language I know, I've "learned" Bash by Googling every time I need some little thing. Consequently, I can patchwork together little scripts that appear to work. However, I don't <em>really</em> know what's going on, and I was hoping for a more formal introduction to Bash as a programming language. For example: What is the evaluation order? what are the scoping rules? What is the typing discipline, e.g. is everything a string? What is the state of the program -- is it a key-value assignment of strings to variable names; is there more than that, e.g. the stack? Is there a heap? And so on.</p>
  
  <p>I thought to consult the GNU Bash manual for this kind of insight, but it doesn't seem to be what I want; it's more of a laundry list of syntactic sugar rather than an explanation of the core semantic model. The million-and-one "bash tutorials" online are only worse. Perhaps I should first study <code>sh</code>, and understand Bash as a syntactic sugar on top of this? I don't know if this is an accurate model, though.</p>
  
  <p>Any suggestions?</p>
  
  <p><strong>EDIT:</strong> I've been asked to provide examples of what ideally I'm looking for. A rather extreme example of what I would consider a "formal semantics" is <a href="http://cs.brown.edu/~sk/Publications/Papers/Published/gsk-essence-javascript/paper.pdf" rel="noreferrer">this paper on "the essence of JavaScript"</a>. Perhaps a slightly less formal example is the <a href="http://www.haskell.org/definition/haskell2010.pdf" rel="noreferrer">Haskell 2010 report</a>.</p>