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,HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21958 invoked from network); 31 Aug 2021 00:11:19 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 31 Aug 2021 00:11:19 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1630368679; b=DpMrLTepblXuokORN3uOLXv/TadjyUjfB/OnIKLfda97d7+P9XxjjQ9ipbgVGtdqRJFMkf43Jd osjomTEAi9JXKNUrLhwoSMMatnPvUta+HDsyIGrpKxlQsWX6wF43vE38vViWCTK3tK/oJoGr2X O3X4LPGIekcmlChZRAMycwOi0JMzpfIwN4mivc9bP4R0Ud58fceYHWCO9Bj5gcGu3MFeTN6LKq eqF7H9XpMwVFk14I2bTPk5AT0TuKTxJLJpxPZU1HDS57vfgh+CPBekr/NyzWGvzbJIAxRFGIOM +ShOjb3axr1FWiALymmGx+ZCP4ocX80dnNZtlbbvdSdKwQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-io1-f50.google.com) smtp.remote-ip=209.85.166.50; dkim=pass header.d=bifb.org header.s=google header.a=rsa-sha256; dmarc=none header.from=bifb.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1630368679; bh=xmYMwJpAh6xvz045H9jAz54ooO0pNsCjf63qmbiF3hE=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=Lot+FdaYS3lIm8qj3TsGq/NKTZsozCbL+Ewi4B7gAJJUSm3RivgL8JymbRF3WjawDzq3uBcZkd e7Ev5KCPoJRrCIBrMHwLKPtDLVvegTGczXAV5I0e/3uXR3nwd0dTKCicKrG5jvSlXARObLtdF+ gKLpR/E7ftJkyhjHjTIJ941lGz4j/dXalO11ugZnNMyeEpanwx1OgRrwad1WR5UrOFB6SzHHYP bSnxOIjXUmKaat6AQOn25XO1TDOXXnLahs7o7tbDkFD6cpbZj/DdRxHL4vCtTCfq/krjFr3pZ1 9hByM2lmkbq3s2A5Uj3n8l8duz/CaE1mtAkSpVdL30PWAg==; 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:In-Reply-To:References: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; bh=P8qrS/59qffcgjO1mgf6DYiorHlpe5tzjk5pXCRtR14=; b=WDKglsVES0qhfZZc+q9N5Yi5C8 RsKopeL6jdb9Fzb+jZkpy5sJ2aO50Dr1SZtV4tsXbQAlEYHp3ZhFryvENAx4MKPyI7cceFtjyqfLB ioXWb6vyRh7pmy0MMRoORvz/CbxFrjY+mxv0Zk5Ek87B8twB5NujNxEg/tmlac5oDrdvFUdUbEVKw 4CxlKqATmTpWlf/uL5m0D05oShZP9pQMoyuaFGP55n7fgrwVCG5kcILICkdJy1eO3vDJBKRXKuOxx tSxG63+vrhzBH2C7GyUUcMv8zYMum8UjlpmiDzAiJz6Xpa7Q2JUfEu2uoYXPt+yxd6AXHwQMfhGdb zD4zFD6g==; Received: from authenticated user by zero.zsh.org with local id 1mKrMz-000J4S-6z; Tue, 31 Aug 2021 00:11:17 +0000 Authentication-Results: zsh.org; iprev=pass (mail-io1-f50.google.com) smtp.remote-ip=209.85.166.50; dkim=pass header.d=bifb.org header.s=google header.a=rsa-sha256; dmarc=none header.from=bifb.org; arc=none Received: from mail-io1-f50.google.com ([209.85.166.50]:45814) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mKrMU-000IMS-OK; Tue, 31 Aug 2021 00:10:47 +0000 Received: by mail-io1-f50.google.com with SMTP id e186so22497216iof.12 for ; Mon, 30 Aug 2021 17:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bifb.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=P8qrS/59qffcgjO1mgf6DYiorHlpe5tzjk5pXCRtR14=; b=SmjTQ+Zs84Eg2AOwtpDOxqTPp/tUph+eGSqK0CzLE24RwqZhTo27xu4kxOW3y6jQgM HYzl+Q8wir0h4vEBzl0vLusXkCknH5q1JsnouoVvAZ/zrS48IuYHuiP1OhUWiETJvyCc bQhyXdCMsd8FaWOo45cpk7mrw7cTsnz5VgdjL0QrWd63GW9skB70CAWERku2+3tHtQhY zYtcz9cHdczcmjeege0rVLjmvY3JYui4l8CFJqoDANrLoDjcur6VcFirKwNoleU7N8jQ orr8pzSVWcAWpRul8YgYmCp9CyqjzlvuPsgLLkAOocXQrf5vETJ521dB/1usvjkGe0ja I6vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=P8qrS/59qffcgjO1mgf6DYiorHlpe5tzjk5pXCRtR14=; b=hbhvkrOv1UdaxhS6QKWVAJNwTGg1XbZNt5mJ/ehasyVaGCu7mt4RiOIBSvVFf1NlBU mBVZXulJZp1jhhoxVmNVZ6UJHqLcsC0+781D6ZVWXPr1RGqdLC/RG5D0pFN/5Vvjgdsg QfhbM0e2L479Gt0/+nnT/dGIkQ7uddDNO/i/1P2nF2SXAeEPDdO0KEy2qyC8/aLdggy/ MWV3esrhZ4b0p91LvS7RMFYTBVk1kUvE4zoEU9SfT964bYCbENrNCp+sZOSbNm0EsBnY 9AIpOjTYiSQd7K/yKmfTPb0byRXvrH4h8EXXtwby0QcHiiWMabppn8ssJImQ2TnN3Ylo tIcw== X-Gm-Message-State: AOAM531TqXb1HEsmZuodmT8TS7R1WHeZVcfUpqf/szTCRXZMhEMS3kyc fV0aK2jD+3iiD+zOMnS7z/YTeq5YKlu5xwxZKoFo0B1MM+sI0Q== X-Google-Smtp-Source: ABdhPJyTyMIuFggW1pW2W/mFP+bh+6NFQW+9tzgXFBrGjELbULUafpoCF5ZY5WnJxwPgCwcIaNNJhvfbAhtf1o/wSEA= X-Received: by 2002:a05:6638:2493:: with SMTP id x19mr194272jat.57.1630368645268; Mon, 30 Aug 2021 17:10:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Anthony Fletcher Date: Mon, 30 Aug 2021 20:10:34 -0400 Message-ID: Subject: Re: autoload variables To: Zsh Users Content-Type: multipart/alternative; boundary="000000000000f45b8e05cacfc777" X-Seq: 27007 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: --000000000000f45b8e05cacfc777 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, 30 Aug 2021 at 17:46, Bart Schaefer wrote: > On Mon, Aug 30, 2021 at 2:34 PM Ren=C3=A9 Neumann wrote= : > > > > As always: the tradeoff between having everything loaded "just in case" > > vs the "doing extra work when I need it". > > As Roman said, "Zsh doesn't know which commands respect UPIF > environment variable". If you can easily enumerate them, you could > write > > function $(list of commands using UPIF) { > export UPIF=3D$(....) > unfunction $(list of commands using UPIF) > command $0 "$@" > } > > This could be combined with autoloading to keep the function bodies > out of shell memory until one of them is executed. > > Thanks everyone for the suggestions. Yes - I'm often a "jack of all trades". I debug networks more often than I'd like and then off to work on something else. But it's always a balance to remember the recipe to eval whatever variable is standard for that command on that Linux system in that VLAN. Easier to have them all in my zsh rc files but it slows everything down. I think that using a function that caches the value and then invoked via $(upif) is easiest. Something like upif () { export UPIF; echo ${UPIF:=3D$(ip r | ....) }} tcpdump -i $(upif) ....... Lots of good ideas. Thanks Anthony. --000000000000f45b8e05cacfc777 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, 30 Aug 2021 at 17:46, Bart Schaef= er <schaefer@brasslantern.c= om> wrote:
On Mon, Aug 30, 2021 at 2:34 PM Ren=C3=A9 Neum= ann <lists@necoro.e= u> wrote:
>
> As always: the tradeoff between having everything loaded "just in= case"
> vs the "doing extra work when I need it".

As Roman said, "Zsh doesn't know which commands respect UPIF
environment variable".=C2=A0 If you can easily enumerate them, you cou= ld
write

function $(list of commands using UPIF) {
=C2=A0 export UPIF=3D$(....)
=C2=A0 unfunction $(list of commands using UPIF)
=C2=A0 command $0 "$@"
}

This could be combined with autoloading to keep the function bodies
out of shell memory until one of them is executed.


Thanks everyone for the suggestions.

Yes - I'm often a "jack of all trades"= ;. I debug networks more often than I'd like and then off to work on so= mething else. But it's always a balance to remember the recipe to eval= =C2=A0 whatever variable is standard for that command on that Linux system = in that VLAN. Easier to have them all in my zsh rc files but it slows every= thing down.=C2=A0

I think that using a function th= at caches the value and then invoked via $(upif) is easiest. Something like=
=C2=A0upif=C2=A0() { export UPIF;=C2=A0echo ${UPIF:=3D$(ip r | .= ...) }}
=C2=A0tcpdump -i $(upif) .......

Lots of good ideas. Thanks

Anthony.
--000000000000f45b8e05cacfc777--