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 3087 invoked from network); 22 Mar 2022 23:38:18 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 22 Mar 2022 23:38:18 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1647992298; b=KV2u67rxIF9pqCaHSkJUmzFxYQM4Wmg+YAZcW7bM8McR6jD+OXeVbROgCiZfJKly6aQmfcf6A8 5D1JP+4lcU/zMJYfnTe5R+J9DikH+kZ1sBgDYjTTQsJtP5pQ/91L+4lY7ruXnjQFVT08ufzJyI /5z48vWvs8IKnlcJ8CUuqaU4VU8GM3VzdHobhFWuw2PGn+be0HxrYcbq9DP1m3McbQg65VflXi RQXJxioh3qQ0VPm8xskRizyx9hOIDOSL0DlSptyEG8DdjGMob6F/qdPVVBkcwLE4h3XnuI+ois nNqc+V/IYN9PcytH8PGn1ekP1umB5QWmk89Dt4RT2a7/zg==; 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=1647992298; bh=3rmsjU6G0RwcVd4dITLHunTgZlR6qLPiYiObbblJ3ZY=; 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=VAghsfXzlQd6CFbcCsnFfg4hbvZ6G3h9Eypq6NCMPOok3H6WEqWg9c0CGP0yYO/w+vsZPg/Bem UCcu+DOD4bs/VxHRgS4ifFf+AIhq7rvxbnJaNDk+d70FCmGWsBZ35BmM6k3WjkhsbIupKZONk2 Z5NEh2PWhZcCvOY0N3hH3DSyUcIFREF1xEMFePyoWRzaMEyW2toNO5Zl7ZJpc4z5wR1UVzpgtM b7x7OdJJ6epVE8tOw609O66I51EpdsX6nMSaebdYIr2pc3pJw74KoO1ZXwWXoESiYBN17M+jAW 3R/ykA5XqpG2FLxUCpgfBgMSTE6pgSCcEq82GJ/CHsPTXA==; 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=baNguFN4tntYBNtzShZ3ulf1JMe/vyH3BVQV6dCzdzY=; b=GXBaRgHmw15EJ2dDKo89SWLZ4I PYuwmxf0Ej4LA6atKmgm+Wo8u175hKUlKnkeFqOQH7aWHxBGXqZ4YKbysQfvA7YQy68x53U3wYvi0 d3qnRraoqiaDwvrmJCcwHSq4vS1C9XI26Es2aIIRAMVnAH4OVHaIFSrKIfyFjVadJC+bA++N8vo3J xPY6Hkvssh5RPkzfF11i77bkNi1X8OX+ObCOZAZ7R+zkkv9cAu1Cot0cIWsnaTg7Y/AYSkj8t1V09 BNCM1DTpLNlt277VQa55wzPcFwt3PUX147F8ieFJQsMolW4HP6Ot2SjIGpaMi1w8FUoLo+L+6leyU CDqWzUyA==; Received: from authenticated user by zero.zsh.org with local id 1nWo4w-000Ano-Nh; Tue, 22 Mar 2022 23:38:18 +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]:41464) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1nWo45-000A5P-Bc; Tue, 22 Mar 2022 23:37:26 +0000 Received: from smtpclient.apple (unknown [216.193.141.189]) by email.dondley.com (Postfix) with ESMTPSA id 19C1420574 for ; Tue, 22 Mar 2022 19:37:24 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dondley.com; s=default; t=1647992244; bh=3rmsjU6G0RwcVd4dITLHunTgZlR6qLPiYiObbblJ3ZY=; h=From:Subject:Date:References:To:In-Reply-To:From; b=qvV4uIbXOxWS4EBmgPloNwO0YW0KPFv9AvpF0LnnxaNRm8NbD13hfaDMHBl9XYzj0 eIq/76XmPcLRmXV5SNWsaPafA5n/Dgs1mDophEZ8c/9/3vfeJzVfhgnEjaeQCmBVGi RQQT1L2yj7zbsgGWoEz/Qmc8DT5MKqRNu4iYrnhDVVXTXeU9EXP5/sxZgvrYZq6hPe 3ipWa4rjekpWulUBJ207bCHBUSBWXoUlE68/L1pNoEfFuKcVefAZQcWcz9ydeGE//G jf4Xj6+OaB7DG3m/o6oy5X0v+X7+yIhw6zcDl8BoC3409UDa4gUxqmdzd0DpheGm2Z JOHeEbqeoLB/Q== 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:37:23 -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: 27606 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: And here=E2=80=99s what I get with `type`: > $ type tbbbc = =20 tbbbc is a shell function from /User/me/.local/zsh/aliases/taskwarrior So the zsh function generated is definitely recognized as a function. > On Mar 22, 2022, at 5:09 PM, Steve Dondley wrote: >=20 > Nice. This looks promising. Thanks! >=20 >> 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 >=20 >=20