fish-shell/doc_src/cmds/block.rst

53 lines
1.3 KiB
ReStructuredText
Raw Normal View History

.. _cmd-block:
block - temporarily block delivery of events
============================================
Synopsis
--------
**block** [*OPTIONS* ...]
Description
-----------
2019-03-31 09:07:59 +00: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.
In functions, ``block`` can be useful while performing work that should not be interrupted by the shell.
The block can be removed. Any events which triggered while the block was in place will then be delivered.
Event blocks should not be confused with code blocks, which are created with ``begin``, ``if``, ``while`` or ``for``
The following parameters are available:
2021-12-09 11:53:13 +00:00
**-l** or **--local**
Release the block automatically at the end of the current innermost code block scope
2021-12-09 11:53:13 +00:00
**-g** or **--global**
Never automatically release the lock
2021-12-09 11:53:13 +00:00
**-e** or **--erase**
Release global block
Example
-------
2018-12-19 03:14:04 +00:00
::
# Create a function that listens for events
function --on-event foo foo; echo 'foo fired'; end
2018-12-19 03:14:04 +00:00
# Block the delivery of events
block -g
2018-12-19 03:14:04 +00:00
emit foo
# No output will be produced
2018-12-19 03:14:04 +00:00
block -e
# 'foo fired' will now be printed
Notes
-----
2021-12-09 11:53:13 +00: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).