From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Roman Perepelitsa <roman.perepelitsa@gmail.com>
Cc: Marlon Richert <marlon.richert@gmail.com>,
Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Bug report: `setopt noaliases` not respected in `local` statement without assignment.
Date: Sun, 29 Mar 2020 20:47:02 +0000 [thread overview]
Message-ID: <20200329204702.5c096185@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <CAN=4vMpbXEL=XSji4J9NRcaBud3-+YzNXpePj0i79EDB67juRA@mail.gmail.com>
Roman Perepelitsa wrote on Sun, 29 Mar 2020 12:24 +0200:
> On Thu, Mar 26, 2020 at 11:34 PM Daniel Shahaf <d.s@daniel.shahaf.name> 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
next prev parent reply other threads:[~2020-03-29 20:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-26 9:54 Marlon Richert
2020-03-26 9:59 ` Roman Perepelitsa
2020-03-26 10:27 ` Marlon Richert
2020-03-26 10:38 ` Roman Perepelitsa
2020-03-26 22:34 ` Daniel Shahaf
2020-03-29 10:24 ` Roman Perepelitsa
2020-03-29 20:47 ` Daniel Shahaf [this message]
2020-03-29 21:03 ` Roman Perepelitsa
2020-03-29 21:12 ` Daniel Shahaf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200329204702.5c096185@tarpaulin.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=marlon.richert@gmail.com \
--cc=roman.perepelitsa@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).