From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 3433 invoked from network); 12 Oct 2021 08:31:45 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 12 Oct 2021 08:31:45 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1634027505; b=M2i4tjxnRA42I2gNe95oeLbpCYJI8jYG4hy6yR6z8sJVc5YbolOlUTwZ6SqtAvEatJEP72zcWK aAecNceIkzC8Oyc7UbU3pqNvvvqCnhUyNRv6WkVjU5oXNoYo22e6fhkxTy2NRzZjN7e+3F9jij BsdogUZKeo3tSaWufjhajTSSmUJP9LqMcnMTSOrIFZ9ttQDBwbyZksIQ9YBKlHrmUOSGX6kRM+ kL+Nh2qrWcL2clCdvrt+78ZO0rYMnxtsdWMq4f8wa8BWE+I8f3xPhAbtkx41TY3Ox4R+FcANsX HD5kCLbOzxvzbnVPEnPOV58gu+B7Ep8DLh4tNjbFnxNSpg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (smtpq1.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.96; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1634027505; bh=01WxNCNtIFXu7wIzByyXlHS4eMRBcXn8TsOSZZHiBYU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject: References:In-Reply-To:Message-ID:To:From:Date:DKIM-Signature: DKIM-Signature; b=sZtkbD1l2/fAXs5mapmRRf5MK+WxrwwRZSPrEBSyEV4QVV6TevqvWPjgSulN9z4DIhKKRyfzoT Ds3DS6xcgJ4PRj5zn+CrXgvWHRqrUzRvE0m/EU6yxO3LS7BAViydU0KZJtbDk1RMuYUXKPNyNQ EAXBCJT5vbC/lHUvkq1imYNm7fUjJFEpGqMOT331F70vFCLTOoxvYCDiCkez1e416KjRfZqmNI 5eEK08lRrcTKpc5osRHWHsB4EhxvORfkX77JHrqvvDbxqvQBbMgOL3agPNokUugFKVbrprVJfb n4egPH0Pef+lUbts6GUQJx1rHFzWB82BwDPt0Tawmyy5Gg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:References:In-Reply-To:Message-ID:To:From: Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=uHyD4xuCqbCXPQLkTfW+VGU9IOyF0OmhSxHyhS9JigI=; b=Vc2RjXi2e4PpRFFkMpmy+kfXaD bsOenvKhZkPOwxOW7vqmHXw1Qn0KmRrOVLW1CELEjCV6EaN5J5f5Gtfvb/xD29WLAi8ssL8J2i10o LOtnOHdN+dTnwtV32VRWSNquJXKG5z4oFMQplEHk0w4ZLFUBbUKN1CrWf+mPB+5DsqqaAqoQPCpB4 QJdA8a5MRgsXu9zbmNnVYVAFpuqNoNr1VW7TaC+zazQ3K0K9bOtm5GSkiTaZTxxPihIskDVlPB8Ch 7AOKqKeJyKUTOR/1o10lvIiMK2HRi0Uj1ifNxTVISNJXRCJZuUVmA2t5V4dgNmTFQPWNkrGCVwr4k fX/I9lmg==; Received: from authenticated user by zero.zsh.org with local id 1maDCJ-0003Eb-Mh; Tue, 12 Oct 2021 08:31:43 +0000 Authentication-Results: zsh.org; iprev=pass (smtpq1.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.96; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none Received: from smtpq1.tb.ukmail.iss.as9143.net ([212.54.57.96]:44278) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1maDC1-0002vY-Re; Tue, 12 Oct 2021 08:31:27 +0000 Received: from [212.54.57.82] (helo=smtp3.tb.ukmail.iss.as9143.net) by smtpq1.tb.ukmail.iss.as9143.net with esmtp (Exim 4.86_2) (envelope-from ) id 1maDC1-0005z7-Lj for zsh-workers@zsh.org; Tue, 12 Oct 2021 10:31:25 +0200 Received: from oxbe8.tb.ukmail.iss.as9143.net ([172.25.160.139]) by smtp3.tb.ukmail.iss.as9143.net with ESMTP id aDC1m31KjzUs1aDC1mrxAK; Tue, 12 Oct 2021 10:31:25 +0200 X-Env-Mailfrom: p.w.stephenson@ntlworld.com X-Env-Rcptto: zsh-workers@zsh.org X-SourceIP: 172.25.160.139 X-CNFS-Analysis: v=2.4 cv=Zr2Ol/3G c=1 sm=1 tr=0 ts=616547dd cx=a_exe a=pgSR3NrKiwmx/6vnWRL19w==:117 a=JHxdR_ueUdoA:10 a=IkcTkHD0fZMA:10 a=pfAyaZmUD_0A:10 a=Jynbhx73gL5GSzbJOGEA:9 a=QEXdDO2ut3YA:10 X-Authenticated-Sender: p.w.stephenson@ntlworld.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntlworld.com; s=meg.feb2017; t=1634027485; bh=01WxNCNtIFXu7wIzByyXlHS4eMRBcXn8TsOSZZHiBYU=; h=Date:From:To:In-Reply-To:References:Subject; b=gUWmZv6sit/Fl62NMp4DRknCpLp0w/oj2bAJK2nUXuxY7TmDKITLAqzV/LLMAreQZ ujwJtjH1yEZDIrtntVoFgmW3lK3QGycrY56eTZMQ/cTMOwXD90+nG5PmVvgdIaThqU 5b1jL4WhrDv5rkBW/AzoIBX6oXlPaD9zf4T5Zo2Q+HU7DAp/uxN2zAxOFY5tSoiWVw +9+9wOEqHa3VpXHgIKbDphhmS+ccevAmZC5FlZjTDQjxLI9u2NeGu38Eys8/9fag84 ly46FPJmAenKsTKzfOhMUg8iS/mMbo2nBf7k/qp0SHa9WNcGRtLMxR24ZNXz6O6yJG 06Z2y0qF3zxSw== Date: Tue, 12 Oct 2021 09:31:25 +0100 (BST) From: Peter Stephenson To: Jett Husher , zsh-workers@zsh.org Message-ID: <917132892.507659.1634027485386@mail2.virginmedia.com> In-Reply-To: <78LG0jAMo3FtN941LSwAK1kIhfcF6dszDg8-71F1TxHB3vKubQBIIAWx8yujorTI1mEI8iq4Rsahakh7IfgcNXdq2KMviv805m0imzBh5Sk=@pm.me> References: <78LG0jAMo3FtN941LSwAK1kIhfcF6dszDg8-71F1TxHB3vKubQBIIAWx8yujorTI1mEI8iq4Rsahakh7IfgcNXdq2KMviv805m0imzBh5Sk=@pm.me> Subject: Re: Question on unintuitive behaviour for function execution and parameter assignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v7.8.4-Rev72 X-Originating-IP: 165.225.81.18 X-Originating-Client: open-xchange-appsuite X-CMAE-Envelope: MS4xfMpJ4RJHfz986bQnk+rNfLOIj26/r3rwepHfamD2tX5PfyCpiFNXEKY6Z8gd4hv00zyJD4K18ln3HA7AsNk96lU/IBVTIq5eDZUQBlMY5Ez5A6DvwG2x b1CqS8SMLzz6HFnIHg+YImCLnwVcZLCfeAF/8kyfoT4BLgVuaItkjbpRIKhP8NennFGtcdUS3CqO+0uC406cUiC7mR2uEfgtf4Eq2/DsSGUmlaKGmiDCSRf4 zEgMloTqwkgeh5qaRfxL6Q== X-Seq: 49472 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: > On 12 October 2021 at 09:20 Jett Husher wrote: >=20 >=20 > Good day! >=20 > Does a function `assign-hello` treat parameter assignment on simple comma= nd as local parameter in the following code snipped? >=20 > ``` > HELLO=3DWORLD >=20 > function assign-hello() HELLO=3D$1 >=20 > assign-hello THERE > echo $HELLO # Prints 'THERE', as expected >=20 > # This part trips me up > HELLO=3D assign-hello WHY > echo $HELLO # Why does it still print 'THERE'? > ``` This is covered by the POSIX_BUILTINS option. Generally, the POSIX_* optio= ns are the place to look for this sort of think --- granted that can be a bit of h= unt. Usually an easy test to see if zsh does have the POSIX behaviour available = is to start a new shell as ARGV0=3Dsh zsh and see what behaviour that gives you. That should be maximally compatible= , although it doesn't help you find which option controls the behaviour. POSIX_BUILTINS When this option is set the command builtin can be used to execute s= hell builtin commands. Parameter assignments specified before shell funct= ions and special builtins are kept after the command completes unless the = spe=E2=80=90 cial builtin is prefixed with the command builtin. Special builtins ar= e ., :, break, continue, declare, eval, exit, export, integer, local, reado= nly, return, set, shift, source, times, trap and unset. pws