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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 14852 invoked from network); 20 Dec 2022 01:01:54 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 20 Dec 2022 01:01:54 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1671498114; b=fZo3ZoWeVXSh9VGhf8oUR0AOMZBBk0DSO8uzJ6Dr1c44FM6OXzQKtlKpDisn1g3FHQegFCTwlF XzdJg78ZjvchLcYnlHrGQr1ZGDbHvx4D9HV9m9Je54y/lNrjPR8DIYJZgy3FWIyfn/qWApmyMV X/9aDee+Fwas0gqqKF8kDr1IUdOM6qt1BGY8c/GjYt9rq6npWYjRb+NeWQ+eR3cQWacBFvAAgy p2zp2k53bpWAsTvISKLzIMiN28I4oI3woX26K856gSOmvJS/w/sT5JsBOox1xMMQHgCK1r6e5p BpMqb5GvOQC25i/MkC6AMDm4zambea4CGVxEM7cA43gq5A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f48.google.com) smtp.remote-ip=209.85.218.48; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1671498114; bh=GaQwcU3ZX2QOyh0zynXGPE4VBSyoKW4f6t2hwwrFSQQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=g2cfHtL4jCNJ8RzBeWPXSpcmqeqJj3DHOu3G56RPDKHhsBUv35VYR+AyDQeTv1IV5Tj2pcD/0t hbc+GjXNvlXBVN7eks7Z+vA+xdz+Pi7DKv3YHeY3nD+kjX3NvbLF+2YT41CuuQENltx5ygrHn+ u0dEDjFDgEP5dqt+NUpDdfV+5Mi2iitSUkvA2J2EtXnDrOmM7X+g8XDkSWaI+i+Ei/6vjP0xie uCMCS+rOiuf7k/yVyZ6/pxmYafFzP/P4LULnNqcMY5SN8JStRktzrJBgqRk0HNM5Dn8MevR36U JG1hHiTC9h8Td+FwqVIQ+7AlKpadA1bICP/386/khFoncg==; 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-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=K0wUGj7f/7g/PjGPNGMKVoP2JIWCdHlNS1dIsos7stk=; b=j+fgWhxCYRoC6Hm/Jrv0ezRW/s L8z6R9em0BcaIhtWY/TWPtjUqWsP7X4C8jQC4Z8v66s/OrLhoN4zJoc/i4hK7GM4Hu4VfAN5N/me0 22EK0WUxIPniZqrg71i24nlWgNKApY0DTXQD1gWSVDjtptV5Fsnp1wSwnwxlj5r1Wu3nEbTn2Mh0I zE9mrS5deJNK9Ors3Qy9FZmbHyL7S80547yMOD9w19mrUmifViAyJ4aDxzO3O4Ozxu6xHEreWemgd FRdJ1ZfsGwe4r7H/2blY7PYLJ9feZWh20JS6T+h232AAVf7Qr5q8Iv/9XkphNMZ0kC5RJaecupDkq b3k5kChA==; Received: by zero.zsh.org with local id 1p7R0y-000N8T-9b; Tue, 20 Dec 2022 01:01:52 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f48.google.com) smtp.remote-ip=209.85.218.48; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f48.google.com ([209.85.218.48]:34781) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1p7R0D-000MSE-6T; Tue, 20 Dec 2022 01:01:06 +0000 Received: by mail-ej1-f48.google.com with SMTP id t17so25745213eju.1 for ; Mon, 19 Dec 2022 17:01:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=K0wUGj7f/7g/PjGPNGMKVoP2JIWCdHlNS1dIsos7stk=; b=HML9yDw8t9k6/Ng/2Nn4hb//OHgOshxnqrM2Ze1J18CWAk4Gx5Q12OV5otX3HTcXy+ bjqn8tFbHx7zNd3PDsJRBLarg2tnexEzeUdt2JEWPVyP52yh/YoPo21agb2HR9Kp9qwc yYB3w0BCZ4jhKR037kIhf4p/bEq3EyojSPimPzJD1Oju17E02n0m5do6PfMmiJKp8k5w xkaliXeWsQYJijxt23hQ8RI7Q6x/9zItGbFETfX8Znhpr42SVhLE3yEjZCo8UUVZDQ6W /Ac3Q/r6sc0s6PJvCgrE1liV7V3P3i75pfV0E+deqNdYMcLTgn1gR6vXkuLKFiJ2WxkB WPFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=K0wUGj7f/7g/PjGPNGMKVoP2JIWCdHlNS1dIsos7stk=; b=A6/nLmHLWjrMyPZ6JD97DO7q/e00USLNiXYOmZ1Guq/Hkcu+yowAYAPR3R5OVohDd8 7/zwNmR0DWab7aeI5R1YtFfsd9Nj+2O2uejAY6/tEktowy14c3TTHLs/lzyiNW2tIbsO eL4IaJPj20Iiy5phEPLsR+d0e5a5lJYfQJkxwewMKxf1oW9IKGm4gHl0mHDilvUqIIR0 gLEvgTIPFl0wk2ej0QJkHe6qUVKJV6KutPyyO8UzCcDM5RgHRFp22IkfMZh9nFlRl+H5 1h3Y0w3AyNe9sDB7ayH3ggOmkUSt0KqbiY46rbjjGyiKNYm+dPuDAnfG3Bg4U+FyORiV JzeA== X-Gm-Message-State: ANoB5pkW8qybsNf76sQ23nWXShZgeLyl4LUMJOEe8hLXWxiOWudFUr3y YpmIjEYDd05RVTDAJzUBQy2XMKwtS1ikeS5O+3PVsg== X-Google-Smtp-Source: AA0mqf4zwpEzRZwQhEjmmfOHdi44CYKEChGCfG53+b3XTqHWdcHNli9Cuh+Rps2GReTHzkOy0p3FyqFKprLFn1TeLr4= X-Received: by 2002:a17:907:1627:b0:7c1:413d:5ac with SMTP id hb39-20020a170907162700b007c1413d05acmr2735374ejc.699.1671498064585; Mon, 19 Dec 2022 17:01:04 -0800 (PST) MIME-Version: 1.0 References: <62a2b6f4-9b30-1f6e-0aba-47d76dde8be6@eastlink.ca> <4ffaaa6a-d276-7715-a62f-fbd9bf880968@eastlink.ca> In-Reply-To: <4ffaaa6a-d276-7715-a62f-fbd9bf880968@eastlink.ca> From: Bart Schaefer Date: Mon, 19 Dec 2022 17:00:53 -0800 Message-ID: Subject: Re: local functions To: Ray Andrews Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 28594 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: The current git head has a new utility function Completion/Base/Utility/_shadow that can be used to simulate local function names. You write { _shadow myfunc function myfunc { # Do your new thing } # call myfunc as needed } always { _unshadow myfunc } If there is already a function named "myfunc" it gets moved aside and replaced by the new one, and then moved back by _unshadow. This can also be used to temporarily replace a builtin. The functions aren't really local -- they exist in the global scope, so there's still a chance that something that wants to call the original one will get the newer one by mistake -- but that's pretty similar to what happens with local parameters.