Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :content-type;
        bh=u/DrYVUhZ3DZw8c+ix+v6v6Hb1QWeqNcnNlTntePvM0=;
        b=drzVpPUqReKVjIrHYh4egC7wqswLMLpwuSnrvxlgTjmccATgvxaScjPbp/OHyWFr+d
         L8Rnk7cVcevCK3/wKlvqpRZjTY3JeYlKvvr7oS6eaBee86EJ+N+GJOdHjThmPkLrEhhC
         dpworQCCLLzkhriYqVx0/XRafnBskIhJQvm1U3UzHOfPxFLhIY7ZTs7CIAd34Bj+qsUj
         aejSOMSPwJxXOEEK5o5ilC1QkEtd3KfuWILKDRagzlysFJzwXbVidT2o9Wurm8u2eIlQ
         0MwA2Nhx1K91KFyWIYJMOxAblg14EJXwmaLfQuKaG5EzNeVGk4KwRcYms75vKjOW3bBP
         DhXw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:date
         :message-id:subject:from:to:content-type;
        bh=u/DrYVUhZ3DZw8c+ix+v6v6Hb1QWeqNcnNlTntePvM0=;
        b=Lwv83ne0Pbw/EOlEPX6FeqyJ3c21wVLqcFo/NFUDYCZWpuVf403V1ap9qxE7M5pc2p
         3wkjKSnp+QF3i6sUqP0S6UMo7WohDNJWI4eSgt/UvZTcSgRv4siOjWjqXNIgtCiK5h7+
         jV0wpMzBBoIcjY65pj0HSV7eBoF49hOpfQR+MIAhjeVMcUw+u/7A6E2obzFKuSuNjs95
         XeLc7tKL2+hW5Ws0xYQVsPRGDruWv+VD9Hxr7Xb7AkABW/9y7va/saplbkg7JkH2JQKL
         0zzKyJyGpNhqTYpOovg/GDkGaZ48MB0jFzNnAUy+842yDfANBT8LZ3sIRCxmPuq/zKxw
         nbWA==
X-Gm-Message-State: ALoCoQmCC1ByMaUp/YP8QrNwtWiMb87QVsvyEinX+DjYjk55Nk7QS9SliIzCqBnqEQx+j/PnMGDfseDYtlKYVc5WCXetX1b4Ug==
MIME-Version: 1.0
X-Received: by 10.140.100.141 with SMTP id s13mr30149311qge.25.1453124013009;
 Mon, 18 Jan 2016 05:33:33 -0800 (PST)
In-Reply-To: <CAHYJk3T6hkQez_zUsRKngRoAm80Xr5Od-=51KWGf9bRWkmRqaA@mail.gmail.com>
References: <20160114001336.GA11173@tarsus.local2>
	<56973114.90807@gmx.com>
	<20160115062645.GB12223@tarsus.local2>
	<CAHYJk3QLCCVmZf4efzQgxs3haKv2mssQk3cGQXd5fm7DK7dgGg@mail.gmail.com>
	<20160118022557.GE3979@tarsus.local2>
	<CAHYJk3T6hkQez_zUsRKngRoAm80Xr5Od-=51KWGf9bRWkmRqaA@mail.gmail.com>
Date: Mon, 18 Jan 2016 14:33:32 +0100
Message-ID: <CAHYJk3SU6dcOwwUe90ib1RDzhUiLo_xrvgz=0-rFwTRLcidxiA@mail.gmail.com>
Subject: Re: [PATCH] typeset: set $? on incidental error
From: Mikael Magnusson <mikachu@gmail.com>
To: Daniel Shahaf <d.s@daniel.shahaf.name>, zsh workers <zsh-workers@zsh.org>
Content-Type: text/plain; charset=UTF-8
X-Seq: zsh-workers 37673

On Mon, Jan 18, 2016 at 5:38 AM, Mikael Magnusson <mikachu@gmail.com> wrote:
> On Mon, Jan 18, 2016 at 3:25 AM, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
>> Mikael Magnusson wrote on Fri, Jan 15, 2016 at 15:46:09 +0100:
>>> On Fri, Jan 15, 2016 at 7:26 AM, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
>>> > Eric Cook wrote on Thu, Jan 14, 2016 at 00:24:36 -0500:
>>> >> On 01/13/2016 07:13 PM, Daniel Shahaf wrote:
>>> >> > The 'typeset' family of builtins doesn't set $? when one would expect it
>>> >> > to do so:
>>> >> >
>>> >> >     % x=$(true) y=$(exit 42); echo $?
>>> >> >     42
>>> >> >     % local x=$(true) y=$(exit 42); echo $?
>>> >> >     0
>>> >> >
>>> >> > This patch makes 'typeset' behave as ordiary assignment does.
>>> >>
>>> >>
>>> >> But who expects that?
>>> >
>>> > I did.
>>>
>>> local/typeset is a command, and it was successful, so I don't see why
>>> $? should be set to anything else than 0.
>>> % true x=$(false); echo $?
>>> 0
>>> is technically exactly the same situation as your above second command.
>>
>> I wouldn't call it successful: I asked for the parameter x to be created
>> as a scalar and assigned a value and only part of my request was
>> accomplished.
>
> That's not true, the parameter is created and assigned the value you
> asked for (your command subst had empty output so the parameter is ""
> but if you did local y=$(echo hi; exit 42) it would be "42".)

It would be "hi" rather, of course.

-- 
Mikael Magnusson

