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 1887 invoked from network); 22 Mar 2022 23:28:56 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 22 Mar 2022 23:28:56 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1647991736; b=oDW8z009PFmq0Q2JUZ2anYGdSNG5EXKp5zpbNNlINEt2+K+sdwjHyQp5LOJfbk11M3qbEQ9OIp IAaGRVlZFjTfX1RtVr6/j2G+2YCh3J05fjJvZZWAzeRwWoeAt2tLaAMz7kaqmz3tRlKVTglEkR M0AZ9kEhV7iHedZeVYZT8/Ak4MOpWH/He/sBEWUe9qLyR06xiDpT2nv89DKdEifKqv25/DiJym QknKJzqjj14fGVdNTNvYaneuiwMt56jGmVDEknmUaePvtLnM26kTkl5/hst3EPcClvvkJSgXqu +9fwG2ku1GLeq9WrqFD+kfMdWSrctwbrNWAssrZNzfZ+sQ==; 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=1647991736; bh=KBstXSC4ln4JIP20UUqx1sfku65LPnzgco0TOMz3DIE=; 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=T5cBynqftvUmk//KkLa3jou8uPd8iw86NLMhXdqbLnDtmUZk9aJnxmqsDZIRJUvmi8g7dSDK7q 2PCm9riOcniFS+xZ2f7XKH1gutHQHXSnsTqUhWoJhx63fHvatQeEi+Ua1aOQoY1KwkSqhiYddm QhhZXvThoXWPnEOdwKGegm0kwlIlIrIDpDNt41k04fZ/YUQVPRnQq+xCjMJvC5GxenbgiuzNgh xneBi6mH0bLm2ql/U/vNvEiZBFCG4OTaXVjlo6rqYLnWWSWNID6QPHBQ8VH5Qk5TtKIgeKEgt8 GYkwJ2p1+R+3F1sD0/rLaePOVuHqH4oJ5cvE6p38NsDNdQ==; 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=mM6bgFajluzv1SalimkNspwnUrXNjzitNUdjugt8XEA=; b=YzG061Kn9coT32L2LqLAUXijpn MVcinCtBdPqx431YHbP3UUrfwp/UVmygbJ9v6EQ3yodI8MnO9CjUWWr57IojanlqeXggRCsmiAacT iF0X15TI1U1WXBEH5GQ2mwygXoaSwDk3ErOuiMBJmWbBR1oGg6okhS9LieNzP4fGXd4H1Jwwh0zH8 puITdNRj86IHyFscTt1LG1yyI3TVerYcJN/ZVHdTICLGfJ0cMihkWsN99EMBLNwPXYZ9sFKsdSPD3 7l94PfTikodLA16wMPmS6A+lZ1tNREFWMMdo/nrUrpJ4bt2h3LjV8DHBMoQQ3x2+QPzalUnKMsX/3 gHOnTLnA==; Received: from authenticated user by zero.zsh.org with local id 1nWnvr-0009Q0-GL; Tue, 22 Mar 2022 23:28:55 +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]:41230) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1nWnvA-0008in-Sm; Tue, 22 Mar 2022 23:28:13 +0000 Received: from smtpclient.apple (unknown [216.193.141.189]) by email.dondley.com (Postfix) with ESMTPSA id D79F520580 for ; Tue, 22 Mar 2022 19:28:08 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dondley.com; s=default; t=1647991688; bh=KBstXSC4ln4JIP20UUqx1sfku65LPnzgco0TOMz3DIE=; h=From:Subject:Date:References:To:In-Reply-To:From; b=RoKwPr3v/p4055d8qsqLaJ/3JuKAgLdjAr+V0rQxlC9BZEuxw/X9NvNc7/xMewxM9 u7R6kVUSAOxydqfuCaDxn/kjs+DYsz2XyWnrCqemnne5LhYPP03K0uxQfF51rpq99V HusT1rqohXDu7e3JPghOxAUpF1iCsQY3/QRsRb03DzZzaWwjMU6vSsI7kTWJICRAKj xTVmsGdszagCmynNzO5mD07SJ0fwk0XwC7q5WR0E9EqxCXEaJs8hKR9c9wI0Ndg1sl y9JRLjCDCAHPFII6zLniqdbAEB8y/0ARw0mtWSKCP/czQ38+w4+43gy+mJ71sc4M6i B/Igy6gPuVrfg== 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 19:28:08 -0400 References: <38A2973E-E198-4E15-8DCF-C4C72EBC2B58@dondley.com> To: zsh-users@zsh.org In-Reply-To: Message-Id: <63903B76-9716-44A9-ACAF-788F61A0E6DE@dondley.com> X-Mailer: Apple Mail (2.3696.80.82.1.1) X-Seq: 27605 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: OK, this is semi-working. The corresponding perl function is definitely = getting called. If I it has a syntax error, STDERR gets output to the = screen. But for whatever reason, I can=E2=80=99t get any output on STDOUT with = something as simple as: sub blah { system('echo', 'hi'); } > 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