Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: autoload variables




On Mon, 30 Aug 2021 at 12:40, René Neumann <lists@xxxxxxxxx> wrote:
Am 30.08.21 um 17:22 schrieb Anthony Fletcher:
> For instance, one variable is to identify the default uplink
> interface
>
>     export UPIF=$(ip -4 r | sed -n -e '/^default/ s/^default.*dev //; s/
> .*// p;q' )
>
> Useful when I'm debugging the network but not needed otherwise.

Is there a reason you need this as a variable? Would a function

upif() { ip -4 r | ... }

not suffice?

- René

A function would work but then you need to run it every time to get the same value..... and of course the variable is for other commands. Thus
       systemcommand $(upif)
In this particular case anything to do with the uplink interface (eg dump_dhcp6). I guess the function could cache the result for speed.

Anthony.
 


Messages sorted by: Reverse Date, Date, Thread, Author