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, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 15200 invoked from network); 13 Aug 2021 02:30:10 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 13 Aug 2021 02:30:10 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1628821810; b=cu9BXvkMc0/GZ7ozXlc1nhzZOo1O/BSlgVJUOt9GluleYKaYb47z4sx9i7tSR+Gu5OSFf3xqJJ 329SkjW4JuxN8/ot2ree7LeTmh0CRsTos2cYoQbrKgQEVbhmz+tBazMN/5gAk+DnsK8lo/8kK3 S1aAkgIx3UYYkR7HFr3F24stSzOUJtUL5i+fKs3ZmeXmVFypD07LBJn0OOU8aJZfklNgNmoFNQ WYEogv26S5w/OphifByUhfD4DUEPMRytUZf6TbUsHY9r8sOufsRktMs8EdH4TiVz+1gf946c9k 7eZ58q9LvbU3iYTNUcpgeWzpeCSjVKQle4zkdLHrt2ZDdw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ua1-f49.google.com) smtp.remote-ip=209.85.222.49; dkim=pass header.d=gmail.com header.s=20161025 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=1628821810; bh=uL5AdXZCGicFf8tY+lpowJRqkvU/erbAUn1Df4toPok=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:References: In-Reply-To:MIME-Version:DKIM-Signature:DKIM-Signature; b=SU0kC8Pz81wWJUYs4gN/sSo98wFf40imfk+WYuDP9hpe2Nfnnx0f7sfWEOsxzj5QH4PcpBmm3W /g9cXPYqF1tMQCdnzVvlts62NtRCuB7HBY6HsYXDnqOByfKoQhrcYKFJrilbw2qj+6JWTFHAwG QucuTZ2t0WsnMvDUhmn/hOuFOEtfztBY1O7SkSihQX8ttFyL4DcSwIEfFieO6HEzfiHXqTc5R8 p3kM2rWH4c0OPr5hpDXkZkJxChhTh/TlkW9hZzdMMZRp6nQQjtmJGK6rxYL4I5OBSF6OdActmK 6l1Ql4Imp+6dmim0dNnYaXqgk5kzhdtItqZk8y51PX5zAw==; 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:Cc:To:Subject:Message-ID :Date:From:References:In-Reply-To:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=mUQuA7YCX67aeyzCALkLYqDUIelCQ5XGAsEDT6GMorY=; b=l9jAuE5FD8H/yEnr1OuD+bM7uQ 8mfS6Xd1qLHeg7k0Fx2AZQIryr+pD7rxvcFV4ZUsG0OJoVbxI2CC+Jy4bYnQT5Ya8CLTKybXk7Ntm ms/HUZfLsahrt+qLr0wC65qm0729G2ItuYYhlUAvUmuNtCuXUaEexYApdhY0mGJNJk5mfZdqiZ06h 6blK0jSlnJjTM5/fECRzy7Gc5phr52O3IcmSp23oCJNFWCR34IyHtOlNqkBpTE7X+XA3GuvhdGg9D MeY3PA+PIKywadihmN6bw0IjMAf0YrEAea/ojud7LRFlvyhAq+t8W7jveI1H3PqEW0I8gcNg7fPfw /IpJBbNg==; Received: from authenticated user by zero.zsh.org with local id 1mEMxO-000C3w-Pk; Fri, 13 Aug 2021 02:30:02 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ua1-f49.google.com) smtp.remote-ip=209.85.222.49; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ua1-f49.google.com ([209.85.222.49]:37547) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mEMwf-000BLj-2q; Fri, 13 Aug 2021 02:29:17 +0000 Received: by mail-ua1-f49.google.com with SMTP id 67so3805167uaq.4 for ; Thu, 12 Aug 2021 19:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=mUQuA7YCX67aeyzCALkLYqDUIelCQ5XGAsEDT6GMorY=; b=ZGTPgcYxW4n/QWVLtMqxgRKHfTpBYBGWIuTvDaAwmedzjhnbpXpalrr3KwGaxydVXy gwoKmkB2TAL+p1Yzilfpw9i2GY5tGZ/hxgqT+4BodX22HEt/1XbM4MYWsxHh/I9oKwCw 9fwHs2qG9oN7OLAdSYWdKfX2O+RKxyC/ymt+D5/Z9MfcIsMOFIkjbqPzCtkX7VHkZCXn 69CsXA7xoPCQXmFBRR5nWNp2wNcOxfkh8QFzbz9Loupako/p+4VDicbhJF0V3cIpjJom 4IoLGUtFXybEK6CXYav/X0QtBaZaNBiEYCw0qLHBpXGrniT5zM1Kd45BVr0R4brDUEFJ wgBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=mUQuA7YCX67aeyzCALkLYqDUIelCQ5XGAsEDT6GMorY=; b=ljmrMZXViHWDl7HuP0k9sQghOXIn+hcg1t16qA6oVxRbBxQXTJZ5cZLV6sHKYgcgy9 vGGpVDaZ+PmWAmaiTxBaECOc/Jk/4C22z0lHlgXUqM1i66aTWVE/l0Dslew/QC+N85IV vwNWHGtN3SrQREXHt7S15E2tm6Irl7YJqK0hDs9BkTy5eT32ybNoJgybbeMlFd0cb8Vq KqVLV0oH5Lqy1wDIR9QRt1UGg9IvfjEoPpTO5Ekm55ihzLUNPfnaoGdIcqRGxZExomwA K9MEqgcNOH3SGSV7wcV31peMFb7fXoVF26HV4CJEZLqPPz3sDbSMuKdJW/8uaVM+9fBs l6cg== X-Gm-Message-State: AOAM530B3bCWfQXFXpf2eVWhrDqig/An/9RiF3a0skatcso9lmgLPRBU jVfsHbhK3duEGdLh0qKPN1DTRwGdj22IdXpOGDRX7lI3 X-Google-Smtp-Source: ABdhPJyHWCqbsHS7Sdf1bdU/f/3sLphOFVmTEVcaz9XrTZ9kyJ3b8ZAepBd53nC0DgMWNwXNqux2MAk3fG1ZuCgkXm0= X-Received: by 2002:ab0:2bc1:: with SMTP id s1mr189989uar.56.1628821755815; Thu, 12 Aug 2021 19:29:15 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab0:1508:0:0:0:0:0 with HTTP; Thu, 12 Aug 2021 19:29:15 -0700 (PDT) In-Reply-To: References: From: Mikael Magnusson Date: Fri, 13 Aug 2021 04:29:15 +0200 Message-ID: Subject: Re: Re-loading files loaded via "autoload" To: Philippe Troin Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 26929 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 8/12/21, Philippe Troin wrote: > On Wed, 2021-08-11 at 20:25 +0200, Mikael Magnusson wrote: >> eg, we have this, which mentions it in a comment of the example code: >> It is also possible to create a function that is not marked >> as autoloaded, >> but which loads its own definition by searching fpath, by using >> `autoload -X' >> within a shell function. For example, the following are >> equivalent: >> >> myfunc() { >> autoload -X >> } >> myfunc args... >> >> and >> >> unfunction myfunc # if myfunc was defined >> autoload myfunc >> myfunc args... > > I use this function as a convenience when I work on autoloaded > functions: > > autoreload () { > emulate -L zsh > local i > for i in $@ > do > (( $+functions[$i] )) && unfunction $i > autoload -U $i > done > } Both unfunction and autoload -U will happily handle $@, so there's no real need for the loop. You can redirect the unfunction 2> /dev/null if you don't want to be informed that you specified a nonexisting function as in the above. You should also use - in case you ever want to specify a function starting with - or +, eg unfunction - $@; autoload -U - $@ (another non-equivalence in the code example above btw, -myfunc() autoload -X will work as specified, but the second one will break for -myfunc/+myfunc :) -- Mikael Magnusson