On Sat, Feb 14, 2015 at 11:28 AM, Les Mikesell <lesmikesell at gmail.com> wrote: > On Sat, Feb 14, 2015 at 1:13 PM, Robert Nichols > <rnicholsNOSPAM at comcast.net> wrote: >> >>> But it is not 'just' expansions. You need to know the full order of >>> operations with all the steps - word splitting, quote removal, i/o >>> redirection, groupings, etc., some of which is repeated over the line >>> after some of the other steps happen. I think I saw this in an >>> understandable form for the bourne shell back in the 1980's but can't >>> remember it well enough to describe and all the bash docs I've seen >>> are way too convoluted to just see the order of operations as a simple >>> set of steps - that you need to know before any of the rest will make >>> sense. >> >> >> It's the 4 paragraphs at the start of the "EXPANSION" section: >> >> Expansion is performed on the command line after it has been split into >> words. There are seven kinds of expansion performed: brace expansion, >> tilde expansion, parameter and variable expansion, command substitution, >> arithmetic expansion, word splitting, and pathname expansion. >> >> The order of expansions is: brace expansion, tilde expansion, parameter, >> variable and arithmetic expansion and command substitution (done in a >> left-to-right fashion), word splitting, and pathname expansion. >> >> On systems that can support it, there is an additional expansion avail- >> able: process substitution. >> >> Only brace expansion, word splitting, and pathname expansion can change >> the number of words of the expansion; other expansions expand a single >> word to a single word. The only exceptions to this are the expansions of >> "$@" and "${name[@]}" as explained above (see PARAMETERS). > > I think that is still an oversimplification because more than > expansion is involved and the order related to other steps. When does > it do i/o redirection; which things happen before/during starting > subshells/pipes; what if you use 'eval', etc.? > > -- > Les Mikesell > lesmikesell at gmail.com On my bookshelf is a copy of "Learning the bash Shell" by Cameron Newham & Bill Rosenblatt, http://shop.oreilly.com/product/9780596009656.do ISBN 10:0-596-00965-8 I admit I have not completed reading it for the first time, but it has taught me what I DO know about bash. I would love to compile a list of books others have used to learn what they know about bash. Even if you no longer regularly use what is on your shelf, new community members may be able to locate a copy in a public library and advance their knowledge.