From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: (qmail 3284 invoked from network); 29 Mar 2020 20:47:46 -0000 Received-SPF: pass (primenet.com.au: domain of zsh.org designates 203.24.36.2 as permitted sender) receiver=inbox.vuxu.org; client-ip=203.24.36.2 envelope-from= Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with UTF8ESMTPZ; 29 Mar 2020 20:47:46 -0000 Received: (qmail 19761 invoked by alias); 29 Mar 2020 20:47:40 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45650 Received: (qmail 10394 invoked by uid 1010); 29 Mar 2020 20:47:40 -0000 X-Qmail-Scanner-Diagnostics: from wout4-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.2/25765. spamassassin: 3.4.2. Clear:RC:0(64.147.123.20):SA:0(-2.6/5.0):. Processed in 0.773115 secs); 29 Mar 2020 20:47:40 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrudeifedgudehiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkjghfofggtgfgsehtjedttdertddvnecuhfhrohhmpeffrghn ihgvlhcuufhhrghhrghfuceougdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgvqe enucfkphepjeelrddujeeirdduvdehrddvfedvnecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomhepugdrshesuggrnhhivghlrdhshhgrhhgrfhdrnh grmhgv X-ME-Proxy: Date: Sun, 29 Mar 2020 20:47:02 +0000 From: Daniel Shahaf To: Roman Perepelitsa Cc: Marlon Richert , Zsh hackers list Subject: Re: Bug report: `setopt noaliases` not respected in `local` statement without assignment. Message-ID: <20200329204702.5c096185@tarpaulin.shahaf.local2> In-Reply-To: References: <20200326223449.0a090ae6@tarpaulin.shahaf.local2> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Roman Perepelitsa wrote on Sun, 29 Mar 2020 12:24 +0200: > On Thu, Mar 26, 2020 at 11:34 PM Daniel Shahaf wrote: > > > > There are a few other options to worry about, e.g., KSH_ARRAYS, > > IGNORE_CLOES_BRACES. > > Good point. > > I also should've mentioned that `emulate zsh -o no_aliases -c "..."` > shouldn't be used if some of the functions you define must run with > user-defined options. E.g., if you want to respect user's > dot_glob/no_dot_glob (fzf does) or > interactive_comments/no_interactive_comments (f-sy-h does), then this > approach is out. z-sy-h handles this by saving ${options} to an associative array before resetting the options so it can execute: 86 # Before we 'emulate -L', save the user's options 87 local -A zsyh_user_options 88 if zmodload -e zsh/parameter; then 89 zsyh_user_options=("${(kv)options[@]}") 90 else 91 local canonical_options onoff option raw_options 92 raw_options=(${(f)"$(emulate -R zsh; set -o)"}) 93 canonical_options=(${${${(M)raw_options:#*off}%% *}#no} ${${(M)raw_options:#*on}%% *}) 94 for option in "${canonical_options[@]}"; do 95 [[ -o $option ]] 96 # This variable cannot be eliminated c.f. workers/42101. 97 onoff=${${=:-off on}[2-$?]} 98 zsyh_user_options+=($option $onoff) 99 done 100 fi 101 typeset -r zsyh_user_options 102 103 emulate -L zsh (I'll fix lines 95-98 in a minute, though.) Cheers, Daniel > Here's another option that doesn't require one to create a new file: > > () { 'emulate' '-L' 'zsh' '-o' 'no_aliases' && 'eval' "$(<<\END > > # original file content goes here > > END > )"; } > > Downsides: > > - one fork (increases loading time) > - breaks syntax highlighting in code editors > - zcompile won't be effective at speeding up loading time > - some aliases can still break this; for example: alias -g '()'=nope