mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 03:51:14 -03:00
Add set --no-event
This allows running `set` without triggering any event handlers. That is useful, for example, if you want to set a variable in an event handler for that variable - we could do it, for example, in the fish_user_path or fish_key_bindings handlers. This is something the `block` builtin was supposed to be for, but it never really worked because it only allows suppressing the event for the duration, they would fire later. See #9030. Because it is possible to abuse this, we only have a long-option so that people see what is up.
This commit is contained in:
@@ -965,4 +965,33 @@ set -e undefined[..1]
|
||||
set -l negative_oob 1 2 3
|
||||
set -q negative_oob[-10..1]
|
||||
|
||||
# --no-event
|
||||
|
||||
function onevent --on-variable nonevent
|
||||
echo ONEVENT $argv $nonevent
|
||||
end
|
||||
|
||||
set -g nonevent bar
|
||||
set -e nonevent
|
||||
|
||||
# CHECK: ONEVENT VARIABLE SET nonevent bar
|
||||
# CHECK: ONEVENT VARIABLE ERASE nonevent
|
||||
|
||||
set -g --no-event nonevent 2
|
||||
set -e --no-event nonevent
|
||||
set -S nonevent
|
||||
|
||||
set -g --no-event nonevent 3
|
||||
set -e nonevent
|
||||
# CHECK: ONEVENT VARIABLE ERASE nonevent
|
||||
|
||||
set -g nonevent 4
|
||||
# CHECK: ONEVENT VARIABLE SET nonevent 4
|
||||
set -e --no-event nonevent
|
||||
|
||||
set -l nonevent 4
|
||||
set -e nonevent
|
||||
# CHECK: ONEVENT VARIABLE SET nonevent
|
||||
# CHECK: ONEVENT VARIABLE ERASE nonevent
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user