2019-03-31 11:05:09 +02:00
|
|
|
.. _cmd-block:
|
|
|
|
|
2018-12-16 17:39:33 -08:00
|
|
|
block - temporarily block delivery of events
|
2019-01-02 20:10:47 -08:00
|
|
|
============================================
|
2018-12-16 17:39:33 -08:00
|
|
|
|
2018-12-17 17:58:24 -08:00
|
|
|
Synopsis
|
|
|
|
--------
|
2018-12-16 13:08:41 -08:00
|
|
|
|
2021-12-09 03:53:13 -08:00
|
|
|
``block`` [*OPTIONS* ...]
|
2018-12-17 17:58:24 -08:00
|
|
|
|
2018-12-16 13:08:41 -08:00
|
|
|
|
2018-12-18 18:44:30 -08:00
|
|
|
Description
|
2019-01-02 20:10:47 -08:00
|
|
|
-----------
|
2018-12-16 13:08:41 -08:00
|
|
|
|
2019-03-31 11:07:59 +02:00
|
|
|
``block`` prevents events triggered by ``fish`` or the :ref:`emit <cmd-emit>` command from being delivered and acted upon while the block is in place.
|
2018-12-16 13:08:41 -08:00
|
|
|
|
2018-12-19 12:02:45 -08:00
|
|
|
In functions, ``block`` can be useful while performing work that should not be interrupted by the shell.
|
2018-12-16 13:08:41 -08:00
|
|
|
|
|
|
|
The block can be removed. Any events which triggered while the block was in place will then be delivered.
|
|
|
|
|
2018-12-19 12:02:45 -08:00
|
|
|
Event blocks should not be confused with code blocks, which are created with ``begin``, ``if``, ``while`` or ``for``
|
2018-12-16 13:08:41 -08:00
|
|
|
|
|
|
|
The following parameters are available:
|
|
|
|
|
2021-12-09 03:53:13 -08:00
|
|
|
**-l** or **--local**
|
|
|
|
Release the block automatically at the end of the current innermost code block scope
|
2018-12-16 13:08:41 -08:00
|
|
|
|
2021-12-09 03:53:13 -08:00
|
|
|
**-g** or **--global**
|
|
|
|
Never automatically release the lock
|
2018-12-16 13:08:41 -08:00
|
|
|
|
2021-12-09 03:53:13 -08:00
|
|
|
**-e** or **--erase**
|
|
|
|
Release global block
|
2018-12-16 13:08:41 -08:00
|
|
|
|
2018-12-18 18:44:30 -08:00
|
|
|
Example
|
2019-01-02 20:10:47 -08:00
|
|
|
-------
|
2018-12-18 19:14:04 -08:00
|
|
|
::
|
|
|
|
|
|
|
|
# Create a function that listens for events
|
|
|
|
function --on-event foo foo; echo 'foo fired'; end
|
2019-09-17 16:50:52 +08:00
|
|
|
|
2018-12-18 19:14:04 -08:00
|
|
|
# Block the delivery of events
|
|
|
|
block -g
|
2019-09-17 16:50:52 +08:00
|
|
|
|
2018-12-18 19:14:04 -08:00
|
|
|
emit foo
|
|
|
|
# No output will be produced
|
2019-09-17 16:50:52 +08:00
|
|
|
|
2018-12-18 19:14:04 -08:00
|
|
|
block -e
|
|
|
|
# 'foo fired' will now be printed
|
2018-12-16 13:08:41 -08:00
|
|
|
|
2018-12-18 18:44:30 -08:00
|
|
|
Notes
|
2019-01-02 20:10:47 -08:00
|
|
|
-----
|
2018-12-16 13:08:41 -08:00
|
|
|
|
2021-12-09 03:53:13 -08:00
|
|
|
Events are only received from the current fish process as there is no way to send events from one fish process to another (yet).
|