From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1800 invoked by alias); 7 Dec 2014 00:37:35 -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: 19501 Received: (qmail 20191 invoked from network); 7 Dec 2014 00:37:24 -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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Authority-Analysis: v=2.1 cv=AduIQRnG c=1 sm=1 tr=0 a=+SwvCgffRUjIJVDq/BIVHQ==:117 a=+SwvCgffRUjIJVDq/BIVHQ==:17 a=G8GL833Es-AA:10 a=N659UExz7-8A:10 a=QSMn460dLGdDtlwRbKwA:9 a=pILNOxqGKmIA:10 Message-id: <5483A141.4090306@eastlink.ca> Date: Sat, 06 Dec 2014 16:37:21 -0800 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.2.0 MIME-version: 1.0 To: zsh-users@zsh.org Subject: Re: triviality with prompts 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> <141206132828.ZM2258@torch.brasslantern.com> In-reply-to: <141206132828.ZM2258@torch.brasslantern.com> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit On 12/06/2014 01:28 PM, Bart Schaefer wrote: > 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. Yeah, may as well be strict. I don't want to split hairs too finely tho, and I only know the rules for this in natural language. > 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. You know, once you 'just say it' half the problem goes away. I'm still looking for rigor. Once I just stop looking for it I won't get into a lather nearly so often. > 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. > That, sir, was beautifully written.