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,HTML_MESSAGE,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 27289 invoked from network); 21 May 2022 06:30:46 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 21 May 2022 06:30:46 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1653114646; b=mGVHIDDwKk55GLZQ89r4ItOt9mqgqDdBCA8pShjNV5EP+IQiqjuE6Fy8EGQ3A1jiykfTNvoXb7 qf7Z6FjPhwuKiIQv4Tpwb8gvx1z7v5lXUJKpBT7EghlG/Gd5/nHIjO2E+Gcs/tEA0+bugfzCKI zuSOpRkyry7VJS9HZKQERlTDM6FE+JBl/+HEM+yAwK4F7x2PYpdJZANNU6exnM3BJEnOI22qa7 /NmYR5R7Jt4qhiwszGsFaAnEXj+nSZVRS+4r3SR4aIuh6V6tbZtVbXkQLsGprgoBPBqAGi2Xu3 Rgs2A5j5Y0UKdJpfFvSSfCNCHJN+HbQr/z5aGhZKVV/7Fw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-wm1-f52.google.com) smtp.remote-ip=209.85.128.52; 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=1653114646; bh=PBKMyDGNswVnPcgrxUXXc674YJYmnsCGUbFV/Wxzlz4=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:MIME-Version: DKIM-Signature:DKIM-Signature; b=pP9ibji7TEXGdbHjBj8dtBSQAHmLcezGA3eqBwKxI3tVw1KRTz9I18Fsl+aPuLLukD2vXsoqIl fkSbFj1TyV7T7M7aWSbdPA8fZJrNopr00A6CrjclpTldxqvVlcQRL+J280fL1O09CZCaBu4d2t uBeWLFl0glHDhlMjKobBcSf2npfAr3jcYmhHbmsrx5rSXj4N0+QyjV9CPrP316FsJBXOlrk1+W eri9qRU29QXpxqPdfk5QMEo1M5Y0KVsDOq3WfTfJpnPX/i0fT04ffBH8ASKXJ5dTaT6QBDj+3s lQFqnSRYlIkqPKOmdYDULojgeY+ZHxxp3NQewV4I8wcSOQ==; 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:To:Subject:Message-ID: Date:From:MIME-Version:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=7Jqr6IbCW37zF9Risgo1XG2u/H4gBGOIjwYMHqcmmAs=; b=gbUI9lH1SO8BRaAI65gQOrDr6B /A0+vayJ5BFcjlZSnANiR4C1qmd9tN/I3AVwrwxlRZk446kWZN14e37FiDVtuZUEu/pLbgAc+4HJm /XdFOBJL1kP3wGGqR+u0u1pyhl4XNm3RjM1CNYbwbaU2XLav86VpW/+9aC8YXOJPwM4ZXXZPdBDA8 l96YRGxGbXdVqBlpXxuSg3/sZG+JxbATIUqIR74NdFAOPgeD0yfY12nqY1oa0/tlI207rmDgQ9rta zacexM+d0tMCMLpVQoTEm1W49PKi1chXwLWhtOs5vb6NfxPLuzJEKf17PUazdoFlqtgyTndmdwKhl Kdbf+O5Q==; Received: from authenticated user by zero.zsh.org with local id 1nsIdS-0006be-1N; Sat, 21 May 2022 06:30:46 +0000 Authentication-Results: zsh.org; iprev=pass (mail-wm1-f52.google.com) smtp.remote-ip=209.85.128.52; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-wm1-f52.google.com ([209.85.128.52]:40799) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1nsIbb-0005Yi-TF; Sat, 21 May 2022 06:28:52 +0000 Received: by mail-wm1-f52.google.com with SMTP id v191-20020a1cacc8000000b00397001398c0so7879298wme.5 for ; Fri, 20 May 2022 23:28:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=7Jqr6IbCW37zF9Risgo1XG2u/H4gBGOIjwYMHqcmmAs=; b=E9zlW+hoRxVWCUeRdxVc2U+diOhig9MUy19slDZCPwUaL3m6lwSMEM9CzDUJb12VVW eoqmGh20w1LehI54m0sTKK5cDtL5atF+3SB4L3X/P51l8QJBkgYqxOkmEnsMLGUd4+7C 32lTrDBLHdiZfXgNWqaPhkUJklkvMSKceQ+IaIgdJ2jERUoitRE0oX6iUIKZDHG3+DmE 3mvIdrQkfgFZpQ1IwBomF66L936Wq1+XGOgBdpi1fBdgQR1bpr5lCsQ0obeCRIQ7ZW49 sGVQELpBL3KZUAXyKCfRvaqevFKtJizWUiXyQAtZ40HNoOYBmaAvb32un0odlbm2Zw59 zYzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=7Jqr6IbCW37zF9Risgo1XG2u/H4gBGOIjwYMHqcmmAs=; b=eufuES1tTaVBVGOlDPUrs8pbrE0zHmpjCN2jVUq4teadhB7ksyjhLexifWHZfK/b92 XwGLrhfgBweJgklnDiRpdwkM/nGMq/P4g30w4ooFfOIYDsn3c3KttIDzx4ck3i52Vbla sxsul1CrzLVpwZpEIRFRUvB2vKsQc3/I0YT1e9uvvvIkJxRGmYEyz9UsVxyZ2uFyJ4wg zHm3UDry8+hfdDNAaFDAghPOC6r9y+D/5AhiujTGHq6HnghWRc0+m9Vm63pI0O0qUbHn /UKU5B/zPmONI/fRXoAMxUaMykwO7j1q+cVS7Y1POsBK+8m2VydLLqibT4NYd0qIHTDW qhrg== X-Gm-Message-State: AOAM530jqPx0s1755O+s5fvT0YLv/btqh5pY+HYZZey6LdN7zjiyULTi qnAJ5D8cTDGaO0vkbb+kq6J+UqdbyDGQdV7qS7N4XSkP X-Google-Smtp-Source: ABdhPJxVDiwLbM5IxVEZOCCJckczjqHU71PtcUXjxoYc53ZOoy37SAFJAIOwY0l+8RkHMLrenLIX9j296W9FQctIzKQ= X-Received: by 2002:a05:600c:1c12:b0:394:6858:526f with SMTP id j18-20020a05600c1c1200b003946858526fmr11361501wms.2.1653114531360; Fri, 20 May 2022 23:28:51 -0700 (PDT) MIME-Version: 1.0 From: Zach Riggle Date: Sat, 21 May 2022 01:28:40 -0500 Message-ID: Subject: Command wrappers in $PATH, and re-executing the "correct" value To: Zsh Users Content-Type: multipart/alternative; boundary="0000000000006a355705df7fb87e" X-Seq: 27775 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: --0000000000006a355705df7fb87e Content-Type: text/plain; charset="UTF-8" I find that very frequently I write a wrapper for some CLI tool, say "foobar". Let's say lives at e.g. /usr/local/bin/foobar, and $path is ( ... ~/bin ... /usr/local/bin ). I have a wrapper script ~/bin/foobar, which will be invoked for the command "foobar". What my wrapper script does is immaterial, but it eventually executes the /usr/local/bin/foobar with some set of arguments. As best I can tell, there are three ways to make this work neatly: - Implement "my" foobar as a function, and use "command foobar" - How do I make this an autoloadable module, which doesn't need to use e.g. "autoload foobar && foobar" - Remove ~/bin from $path, and add it to the end - This might break other things where system binaries take over - Some cool tricks with /usr/bin/env and such I haven't thought of I've already adopted autoloadable functions via $fpath and using "command foobar" inside the function, but I was curious if there's another way. I expect that removing ${0:h} and ${0:A:h} from $path are the most obvious answers, but I didn't know if there's anything easier. *Zach Riggle* --0000000000006a355705df7fb87e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I find that very frequently I write a wrapper for some CLI= tool, say "foobar".

Let's say lives at e.= g. /usr/local/bin/foobar, and $path is ( ... ~/bin ... /usr/local/bin ).

I have a wrapper script ~/bin/foobar, which will be = invoked=C2=A0for the command "foobar".=C2=A0 What my wrapper scri= pt does is immaterial, but it eventually executes the /usr/local/bin/foobar= with some set of arguments.

As best I can tell, t= here are three ways to make this work neatly:
  • Implement &= quot;my" foobar as a function, and use "command foobar"
  • =
    • How do I make this an autoloadable module, which doesn't need t= o use e.g.
      "autoload foobar && foobar"
  • Re= move ~/bin from $path, and add it to the end
    • This might break o= ther things where system binaries take over
  • Some cool tricks w= ith /usr/bin/env and such I haven't thought of
I've a= lready adopted autoloadable functions via $fpath and using "command fo= obar" inside the function, but I was curious if there's another wa= y.=C2=A0 I expect that removing ${0:h} and ${0:A:h} from $path are the most= obvious answers, but I didn't know if there's anything easier.

Z= ach Riggle
--0000000000006a355705df7fb87e--