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,FREEMAIL_FROM,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 16159 invoked from network); 22 Mar 2022 21:07:58 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 22 Mar 2022 21:07:58 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1647983278; b=pWiGX1b8aHPFY4yi2E9Q8Stl4C1aHns1mBqm5ONWbbXv5ltZFOgaC4IzcIput5DLwkrBvbtRuZ rHDfkqp1+X8c9HOw5iJFBW9L4kQ5bbYYMa1O8d5SREu4sU8eqB7yQx9mxDbW6uSp0A03I9cv8H IYzl+diwf2JyC1OwuzrQxwI19+U9Tx10iqVsisbJap1kHP7GQJKcAs8MbZ9KKrBwSKVBBrvliz nM/Oafo4mwbwDXvfSKFIQoKZmcpr4xIf4SlxXVb+cy5q9+ouseDT/5RvxpKGqFA+xk0lp6WIHA Ai9s7FZHWS832wxuvCCFAlHFMtGai5p9Oqg5AUnrdQxjzA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-pj1-f46.google.com) smtp.remote-ip=209.85.216.46; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1647983278; bh=l5PsYyK+w+XYiB74QM8r/1TW1UYn8C4J++yITbbYbMk=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:References:In-Reply-To:MIME-Version:DKIM-Signature: DKIM-Signature; b=ERYa4zRpVRVia0gkRKWoAMf0cDh40NK5Vtr9quoIcyIvOxSf4LORExDcaMC8jDbBeGduaQ7xea IWqO0W+FQPrOxGq85mTMz4RNiMk5PjZatIlg1d4YdWvP75hvONoMhKYkpk91OJ/QRp+8e4k+Jo s9MrrzIb7d4XxbgVkigYC5xF+0aVuXcsgYtAEvFOWQa3DblTbArrt2qf5hSpSgeRBYwhH7d/kh Ye7qhQNB3URIE+EHT4LjL1I3nA26+ii8M1bZDJpr7IGSU6KgoPjoBpllac24pDEf9iE7ro+Jrp tbnYKyJawTWraN6yZU2EcSib4QiooWI07ckPaFSmKOum0g==; 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:Cc:To:Subject:Message-ID:Date:From:References:In-Reply-To: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=fIvGCMxVDruMYDlyjI11v78yFYheIJoc8ggMZ8SW5zc=; b=J//Vy3omrSdJpyXx5N1v5IzE3e eZBL+OqA9h0s3cyYxbpvw20MxdszLcsMkFEWFUe29ACFfbXr9n5riO5LiRyUtHalH1NwdZiyJPMnv LC3u27hOc/EEVR4GuFaFbgXXLJLrdcbm6BNgcD5F40vOUheOagbLWiGV/usruRjksOUF4c8gXy7GM n769M376kNPUdwLwkuD68m8cRLoR3qQdm2zl+eZHaC9eD0oTjj2wG8JRNXLdtcYL4d1N2dEklP800 60P6rdvHQ9Z3+kfP3xfoNUVmBpWqEZf434DBBPKBC77gj34GBhFffg4A1jzYmmiH0m4Y1QWRKs+hR jouYWMyw==; Received: from authenticated user by zero.zsh.org with local id 1nWljS-00027v-03; Tue, 22 Mar 2022 21:07:58 +0000 Authentication-Results: zsh.org; iprev=pass (mail-pj1-f46.google.com) smtp.remote-ip=209.85.216.46; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-pj1-f46.google.com ([209.85.216.46]:37667) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1nWlfZ-0000Or-9s; Tue, 22 Mar 2022 21:03:57 +0000 Received: by mail-pj1-f46.google.com with SMTP id mz9-20020a17090b378900b001c657559290so4371835pjb.2 for ; Tue, 22 Mar 2022 14:03:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=fIvGCMxVDruMYDlyjI11v78yFYheIJoc8ggMZ8SW5zc=; b=K/xSrsMXfisSjJZL36nEZ7eMiVSyfuLkDwQDvAANFNRAUMbzYBk1UjLxSOnDVoqcik 4AYU9hdV2lbpJLzAIO2PYTRZdSs7e45+iXRkVsi3hWLm55wE8l1YC4VrBYB/oSj5djdr PQOvNRSfh9OvsyTtMt/jJyknIKRN71OMQjPn2pt+EyOhrRLxoipZ5Daa//fYEDhb9Upp l1GPGOIg0E/SNkaP6vkcBRh5031jZztKQXLH2RMkDwI7oDJr2/yRD5v85Mkd4YukWITu xpOxBz/1o0mjXiWS9/y2SNG8ILNVEbSggl3LdKycOKho+nDcRi9+q4ePBREmdzG9DMfE CLCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=fIvGCMxVDruMYDlyjI11v78yFYheIJoc8ggMZ8SW5zc=; b=42vXmfCtxqLWjc9CQmGbJ/URMumE1gcbc0TlflJYKmuT/3SH+2Uo65SE2OSUcN66un 2fw6w7QgRKriur4+Wpj0RA+8wj3N7MMIlxt3uPrP3eQ4zOVVIRDQXgIJDXAW/aYgXaUi FRyfUnDrEXeIeRabNTWbMD/rnuQxuo9GKsX7P8xO7EYbCahp5zw6prq6Olh/NiHWh3PX 14niS6+oC4KHMhN04fsyKuhsjVfqFpOAMHJOCU8Lvn9OKMma/tqt0hCfRu96rLYId3yL kWNc5EhrfSLAzJP1khKyTLkx91h3+8hZLQV3WpHGvK90poVTrFKFTeo1izvbAK7V7hdK sURA== X-Gm-Message-State: AOAM533Yb2vFpO636jK0C4jGs+dVTLKpeFnihhSizMtNQ7r4SYNTLjcr spa1FlhVxJezHwPnewVF10xXe73jGrJmr17HcvE5AQcn X-Google-Smtp-Source: ABdhPJwh75VN+16uoHzXTqH/xRaFESSNwYrOXrxgCcBdA9kVOu/aecJ47dPSqXzglXsPPyIAsMna/pukWUZ/imarQ5U= X-Received: by 2002:a17:902:700b:b0:148:ee33:70fe with SMTP id y11-20020a170902700b00b00148ee3370femr20285125plk.38.1647983035839; Tue, 22 Mar 2022 14:03:55 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:6a10:466:0:0:0:0 with HTTP; Tue, 22 Mar 2022 14:03:55 -0700 (PDT) In-Reply-To: <38A2973E-E198-4E15-8DCF-C4C72EBC2B58@dondley.com> References: <38A2973E-E198-4E15-8DCF-C4C72EBC2B58@dondley.com> From: Mikael Magnusson Date: Tue, 22 Mar 2022 22:03:55 +0100 Message-ID: Subject: Re: Suggestions for autogenerating function names to wrap the same code? To: Steve Dondley Cc: zsh-users@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 27602 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: On 3/22/22, Steve Dondley wrote: > So I have these two functions: > > function task() { > task_wrapper.pl $funcstack[1] "$@" > } > > function tc() { > task_wrapper.pl $funcstack[1] "$@=E2=80=9C > > } > > They are both wrappers for the same perl script which does its thing base= d > on the value of $funcstack[1]; > > Works, but I=E2=80=99m wondering if I can spare myself the job rememberin= g to create > a new function for each and every new perl function I want to write. > > I could write a little script to pull out the subroutine names from the p= erl > script and dump them into a file sourced by zsh and then reload zsh. > > 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. You can define multiple functions like this: function f1 f2 f3 f4() { this body is shared by functions f1 f2 f3 and f4 } and you can copy them like this (somewhat newer feature) functions -c f1 g1 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 Mikael Magnusson