From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11378 invoked by alias); 21 Dec 2016 22:10:45 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 40224 Received: (qmail 12152 invoked from network); 21 Dec 2016 22:10:45 -0000 X-Qmail-Scanner-Diagnostics: from mail-qt0-f171.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.216.171):SA:0(-0.0/5.0):. Processed in 1.019788 secs); 21 Dec 2016 22:10:45 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.216.171 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=z0/pE27or5rH/TCRXX1FMVTXr6O3N3NWhdtNXYKE1tA=; b=lfrAj04Ea7wjgHJng++6vwv2vYyy1ibqvtSY+3mqW4OQwMynCAA7GFYOVTN+B4J6ET 8s8jP4J5qjdbrldmktRhzhmUIuxC9PiuOLlYxgBagXBoKht4vhRXjWhDRaIDH0IOgKsh LmlY3Cm48kDG+0q2hcm8fetbWJyfkjtrnMqEYGcDPmUCkMxrSqRTa/TBCllTKj7g6ILb hBU1b7b5AMpV9wQRRjSavqMhvuicDWbyiDWqT9Zp9yhVaNdLUCO1Lkn05+0ac9KLwREl byEnYDnCDvOHmzHZgQez3aCxjfvXzGzDgibgzggHhUozXwfLfXkFucbNTcHfQCXiuByS rGVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=z0/pE27or5rH/TCRXX1FMVTXr6O3N3NWhdtNXYKE1tA=; b=Ei+ScVimYwsPWiKs6s/C9gRJ4uECyQUOrAfrQkpANtNsP+ze2ilMKH27d+u4tuAp0W Yzd3BKpxC1+oF11mLqyXb5AKp7PFe0CChK8iVKmrgtU4NS/lrbnO8a4e/r3MPSyfPDPd JModHn2QljIFBT/VEkN/zuzTTdGIWm40JQPX2LT+E4TdPtc2/TF/LQYU8GmQm1yfigyl iemE3xmjVY93ya/mnf8TBWM9M8seqCnI0bwHMSGprnX4Z4K226VojvI1w1GZq64sBqTP 2Kb14VcCZ3y7I98/0+IuYOE7zHFWLMU9CAYHO/QrFMBWEC/swj4stmfl0uwMAtmXGJCr n4Hw== X-Gm-Message-State: AIkVDXKq1fuIlGEyzKPqVL6PrPpzN6oT6G8nfFO35VE/20tORJT6m498K5hzQq0MPqIJ38mNz+daPAiZRRI+og== X-Received: by 10.237.56.40 with SMTP id j37mr7334375qte.134.1482358237816; Wed, 21 Dec 2016 14:10:37 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: From: Bart Schaefer Date: Wed, 21 Dec 2016 14:10:37 -0800 Message-ID: Subject: Re: indented heredocs To: Dave Yost Cc: zsh workers Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, Dec 21, 2016 at 11:29 AM, Dave Yost wrote: > > Surely people have thought of this (Alternative 1): > > 0 Wed 10:53:53 ~ > 205 Z% cat < foo > bar > xx > foo > bar > 0 Wed 10:53:53 ~ > 206 Z% > > but shells don=E2=80=99t do that. [...] > I suggested this (Alternative 2), which [Bourne] liked: > > 0 Wed 10:53:53 ~ > 206 Z% cat \ > < foo > bar > xx > foo > bar > 0 Wed 10:54:10 ~ > 207 Z% I'm not thrilled with this idea because it gives special semantics to backslash-newline (as well as to leading spaces before "<<") which do not currently exist. In existing syntax, backslash-newline can simply be discarded without changing the meaning of the command line, I think even before tokenization. I would propose instead something similar (read on below) to this: % cat <<-' xx' foo bar xx foo bar % This explicitly quotes the leading space that is to be stripped, so there is no parsing ambiguity, and it piggybacks on the existing <<- syntax, merely changing the expected leading space from "all tabs" to "the leading whitespace on the end marker". > I don=E2=80=99t think that would help anything. If the parser doesn=E2=80= =99t know how to do > the new syntax with the existing << operator, you=E2=80=99ll get an error= , and if the > parser doesn=E2=80=99t know the new operator, you=E2=80=99ll get an error= . Same difference. It is a consideration that we might prefer that older shells choke on the new syntax. I think having them choke by failing to find the end marker is rather worse than having them choke by failing to recognize the operator -- something that wrongly appears to be the end marker might appear later in the script if we go your "Alternative 2" route. Taken literally, my example above would be accepted by an older shell and processed without stripping the leading spaces. If that's unacceptable, we need a different (and currently invalid) replacement for "<<-" (the only thing that comes to mind is "<<|" which seems a bad choice).