From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11652 invoked by alias); 6 Dec 2014 21:28:44 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19500 Received: (qmail 24418 invoked from network); 6 Dec 2014 21:28:40 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=MJ3XQ3dg c=1 sm=1 tr=0 a=FT8er97JFeGWzr5TCOCO5w==:117 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=A92cGCtB03wA:10 a=GVae6gwXEk1_p0k-1kEA:9 a=CjuIK1q_8ugA:10 From: Bart Schaefer Message-id: <141206132828.ZM2258@torch.brasslantern.com> Date: Sat, 06 Dec 2014 13:28:28 -0800 In-reply-to: <5480AB10.4010209@eastlink.ca> Comments: In reply to Ray Andrews "Re: triviality with prompts" (Dec 4, 10:42am) References: <547E568C.6070607@eastlink.ca> <141202190200.ZM31930@torch.brasslantern.com> <547E9158.6050103@eastlink.ca> <9CD0DDE8-21AB-4EA3-A69F-9B338ECC83F1@macports.org> <547F385B.3070405@eastlink.ca> <20141203164353.GO23965@isis.sigpipe.cz> <547F441E.6060606@eastlink.ca> <547F9939.9060303@eastlink.ca> <141203210607.ZM7622@torch.brasslantern.com> <5480AB10.4010209@eastlink.ca> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: triviality with prompts MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Dec 4, 10:42am, Ray Andrews wrote: } Subject: Re: triviality with prompts } } On 12/03/2014 09:06 PM, Bart Schaefer wrote: } > } > $( ) is substitution, not quoting. } } Thinking about all that, I find my self still fuzzy. What do we really } mean by 'quote'? It's a delineated block of characters in which some } prescribed semantics will apply. Not exactly. It's a delineated block of characters in which a defined syntax will apply. Of course in the colloquial sense the meaning of an individual grapheme in a syntax is its "semantics", but in the computer science sense the syntax and semantics of a language are distinct. Quoting defines the meaning of individual characters, e.g., transforming the digraph \n into something else -- either a literal "n" or a newline, depending on the interpretation of the backslash. Quoting also creates a syntactic unit, affecting how a collection of graphemes is assembled into tokens (most often, resulting in a single token instead of many, and usually resulting in tokens that are treated as plain strings and not as having any particular higher-level meaning). Constructs like $( ) define the meaning and higher-level structure of the language tokens that came from interpretation of the syntax. The shell language is unusual among programming languages in that it allows certain semantic constructs to be interpreted even when inside certain syntactic constructs (double-quoting, mostly), so that it's necessary to interleave syntactic and semantic analysis (and even execution of the code resulting from the latter) to arrive at a final tokenization. Most programming languages force you to make that explicit, but the shell is all about building up or cutting up strings by implicit con- catenation and delineation, so it takes all kinds of shortcuts that make the language ugly to formally define but faster to interact with in the common cases. E.g. in '$(echo foo bar)' the definition of single quotes means that none of $ ( or ) is special, and results in one plain-string token made up of the characters between the single quotes. Conversely in "$(echo foo bar)" the definition of double quotes means that $ is special, which in turn means that the digraph $( introduces a subexpression that has to be interpreted using the higher-level rules of command substitution, which consumes everything up through the closing paren. The final token can only be generated after the command inside the parens is executed and its output captured, but it still results in only one plain string. Compare to $(echo foo bar) without the quotes, which normally results in two string tokens foo and bar, or to "\$(echo foo bar)" where the definition of backslash means that the digraph \$ transforms into a non-special $ which therefore is NOT part of a $( digraph and therefore does not introduce command substitution. } Maybe what I'm reaching for with the list above is a complete list of } 'delineators'. So, if one had such a list, one could learn the syntactic } rules inside each one in a tractable way. In zsh's info doc, sections 6.9 (Quoting) and 14 (Expansion) together make up that list.