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, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20769 invoked from network); 22 Mar 2022 21:43:15 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 22 Mar 2022 21:43:15 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1647985395; b=MjcIiJF9YHQ7iNDFVXB57bl13GxVo/HMXDi1kpJQuWevLO/c9mecVbLJU/qnz4sLtO6i/6boyQ x5KM4kXHgbO7RxuPtmT9Na3zSI6r3NMrxCWT8BBKKNGRdbakGEUhUn3srWwfeTLSc3qaamZsR0 QBGoo+fQDmZ5X3tcptYHTR7fMOGkmh3/qRiATMvrADwRQGghKo6PljZWmGVK6816raP8F9DjNX MXohbBnGSRZOk/AN+J7OS3hvguth/O6mXu1ZYt6U+kb/pYgGK1Xrav81BwR1aH/l4HptZkG2VC BkzDi1ej+bPIct+9wUIuHDccnzpi7r6W0o2hv3w/94TXNg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (email.dondley.com) smtp.remote-ip=34.203.132.18; dkim=pass header.d=dondley.com header.s=default header.a=rsa-sha256; dmarc=pass header.from=dondley.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1647985395; bh=S2RLSHTtiVqrRTSQQyR4aX1CkZ4PIhzI/BmbtbEmNW0=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Message-ID:In-Reply-To:To:References:Date:Subject: MIME-Version:Content-Transfer-Encoding:Content-Type:From:DKIM-Signature: DKIM-Signature; b=DdHuKkwE+WjGVOnBENQ1NTHgos0fe2C7mKVsji1Ch9lDWFYZ5FLjW6GuhpBIMEUgPfZ7KOOgBf kv48fy23dNpp6cf52PNWviRy3TbqkHFhicHkaBokQMKSDybKRh+9RIQtJl+uZBcHiPvjxopbI6 NCLglDkRFllwBmJgnemK/emMfzDlPsZCDJOOXyRCAl7pGANpWIio58PZkH1/3kixRXQnebZ/n0 bSwdZT5c9fk216+FFMuI9PlzL5SHKnELkNhZTpeXIqEHLgFrU2D34iBPyieb5yB8ub0UWZ6XB/ W54uyUJSCmHFBzXems5bTdrbjm8a/d7zp5ccZNllkHm0Bw==; 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:Message-Id:In-Reply-To:To:References: Date:Subject:Mime-Version:Content-Transfer-Encoding:Content-Type:From: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=nkAFXAa4xkKvLyQXS93DjsEexlUQ8OqWp7ojYNlYSgw=; b=Xf6eZtPvK4AahTDFLH0Oko1ph+ lZBuBJmDv5Q3yONMdBEuVTMuCMeK5x5aS5VqseaN4lECfkBpWi1Iayy9dCshYfa38m6Ozt6ysxbGs SnK7UchOLgElQgsAjtC9KTpMm1HRhyyndZwZKnNR56ktWvN54oG1cjcfzvVTVTumybG/4eS3V9yIF AO3DzBkLd2Ij/FpsZyMA79KyGbEdoht1+9T5MrhjticaieWEWcfTzg+alsvC3BmtjzHDV2rvBOKqy H1vxMAiUhotiz9Ya9hoLvbmw4y5nAbEPeNG4/IH1gRgRbyTDeuYacbZoLsMYKsOnZk/DRLr1a+zxF aKNUp+/Q==; Received: from authenticated user by zero.zsh.org with local id 1nWmHa-0004iu-Tc; Tue, 22 Mar 2022 21:43:14 +0000 Authentication-Results: zsh.org; iprev=pass (email.dondley.com) smtp.remote-ip=34.203.132.18; dkim=pass header.d=dondley.com header.s=default header.a=rsa-sha256; dmarc=pass header.from=dondley.com; arc=none Received: from email.dondley.com ([34.203.132.18]:38556) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1nWllO-0002Oj-QX; Tue, 22 Mar 2022 21:09:59 +0000 Received: from smtpclient.apple (unknown [216.193.141.189]) by email.dondley.com (Postfix) with ESMTPSA id A99DA205A5 for ; Tue, 22 Mar 2022 17:09:56 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dondley.com; s=default; t=1647983396; bh=S2RLSHTtiVqrRTSQQyR4aX1CkZ4PIhzI/BmbtbEmNW0=; h=From:Subject:Date:References:To:In-Reply-To:From; b=Qr/z6R5OXeSSp+ismndmfnt+b+rTW9IF7mbGv8OHaFWL8vuaNtwe3zCBpM2Z/PD2m IqLjKZrqurOfAEfZMRMS9BD1lQg0k/0147HEE2xWuk94SuvXOwYY2NKLpqiF5/s9ZQ aPVj19JdadlgY/pIEi3E9BhtC36eb3TBezOd0Q1ORGYEIdOqaKhJUirTPy6FFFWa0z 3wTkjyyHWM7PbV6Vg7DD9SSpKd/emV1R59zT4InR2V6NngUVKbQi8OyYFXIeNY0Bwe CKkLuF+xzFGk64/LT3mZAhUKyp3xFMXr4gA+tEmm/Qej2kHwnjOSUwlGrARVjgRHg7 RLvOiESvaLsrQ== From: Steve Dondley Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.80.82.1.1\)) Subject: Re: Suggestions for autogenerating function names to wrap the same code? Date: Tue, 22 Mar 2022 17:09:55 -0400 References: <38A2973E-E198-4E15-8DCF-C4C72EBC2B58@dondley.com> To: zsh-users@zsh.org In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.3696.80.82.1.1) X-Seq: 27603 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: Nice. This looks promising. Thanks! > On Mar 22, 2022, at 5:03 PM, Mikael Magnusson = wrote: >=20 > On 3/22/22, Steve Dondley wrote: >> So I have these two functions: >>=20 >> function task() { >> task_wrapper.pl $funcstack[1] "$@" >> } >>=20 >> function tc() { >> task_wrapper.pl $funcstack[1] "$@=E2=80=9C >>=20 >> } >>=20 >> They are both wrappers for the same perl script which does its thing = based >> on the value of $funcstack[1]; >>=20 >> Works, but I=E2=80=99m wondering if I can spare myself the job = remembering to create >> a new function for each and every new perl function I want to write. >>=20 >> I could write a little script to pull out the subroutine names from = the perl >> script and dump them into a file sourced by zsh and then reload zsh. >>=20 >> Wondering if there might be some cool feature of zsh I don=E2=80=99t = know about to >> assist with creating these functions on-the-fly. >=20 > You can define multiple functions like this: > function f1 f2 f3 f4() { > this body is shared by functions f1 f2 f3 and f4 > } >=20 > and you can copy them like this (somewhat newer feature) > functions -c f1 g1 >=20 > so if you can get all the function names in an array, you could just = say: > task_func_names=3D( $(script to pull names out) ) > function $task_func_names() { > task_wrapper.pl $funcstack[1] "$@" > } >=20 > --=20 > Mikael Magnusson >=20