From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13295 invoked by alias); 6 Mar 2015 04:59:59 -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: 19976 Received: (qmail 26348 invoked from network); 6 Mar 2015 04:59:58 -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-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=H/58zHkVhdSG/xD2tX7VQ17yLrzRPJVnmtwEtQQlc/s=; b=ibwkUjqvxKsFRy44U2dhKvKBPx0Br2hemtgcxsZGgh08SdXpcv2Ucd8Bp0TuIDh2W3 ZZZCtUYIjxSlSnuM1071dDUl++Siuc63VQr9ytd6N8i7z48Uii9nh0/5nBt0QtlxrGMh 3CTAT3f4xZO+DizVQa5QnrYzuGLzKJK5fTlViRAJRg5Td5Kog1oa31/M+Rvmc+S3DhrZ HHFGIONAZDWyg1gZYlVDgGRVcxnbyrXqrRUPIdtBOZobIeHi/DXWov/WapewzY94Kct0 HFrvhISvnG7lKESxodBIlTARE36krKeljJgfBgnsASoYJgqYynC1+SE2NNW/owiRBaZy huCw== X-Gm-Message-State: ALoCoQnLx1sb/sQTw8zVSSVlzb3yHvtXfNmHK1vzqh4LQMZAnSKxpF7Wdg3kPo1soqMKcXGhM1kI X-Received: by 10.182.65.97 with SMTP id w1mr9702493obs.73.1425617994915; Thu, 05 Mar 2015 20:59:54 -0800 (PST) From: Bart Schaefer Message-Id: <150305205951.ZM8811@torch.brasslantern.com> Date: Thu, 5 Mar 2015 20:59:51 -0800 In-Reply-To: <54F73D18.8070801@eastlink.ca> Comments: In reply to Ray Andrews "Re: grammar triviality with '&&'" (Mar 4, 9:12am) References: <54F33934.2070607@eastlink.ca> <13666281425228233@web7o.yandex.ru> <54F345D3.9010204@eastlink.ca> <20150302022754.GA7449@xvii.vinc17.org> <150302005440.ZM16546@torch.brasslantern.com> <20150302103156.GB6869@xvii.vinc17.org> <150302084958.ZM17306@torch.brasslantern.com> <20150304085512.GA3609@ypig.lip.ens-lyon.fr> <54F73D18.8070801@eastlink.ca> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: grammar triviality with '&&' MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Mar 4, 9:12am, Ray Andrews wrote: } } If an extra degree of freedom and capability was possible, and IF it } could be implemented with no gotchas, then why not? Because we don't need the grammar to become any more ad-hoc than it already has? Back in the depths of time, one of the reasons zsh was invented was because csh's grammar was too irregular. Csh scripts originally (I can't speak for how tcsh &c. may be now) could in fact be interpreted one line at a time, and literally were: "while" loop was processed by remembering the file position of the string "while" and then when the "end" was encountered, seeking back and re-reading the lines again. This made it possible to write some really entertaining scripts that edited their own code on the fly, but made it impossible to syntax check a multi-line control structure before beginning to execute it. The Bourne-shell / POSIX shell grammar is at least regular enough to be parsed before it is executed, even with all its other warts. Introducing a case where the command to the left of && / || can be empty if and only if the conjunction is the first token on a line, is the kind of irregularity that should be avoided. Further, in the standard definition of the grammar where pipelines separated by && or || form a sublist, the terminator that follows is syntactically significant to the whole sublist. That is: one && two || three & is parsed as { one && two || three } & which is not the same as one ; [[ $? = 0 ]] && two ; [[ $? = 0 ]] || three & Now, as it turns out, zsh doesn't actually execute "one" and "two" in the background when presented with "one && two || three &" but that is a consequence of other implementation choices and not of the treatment of "one && two || three" as a syntactic unit.