mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 13:53:10 +00:00
Remove dunderscores from __fish_status_to_signal (#7597)
* Remove dunderscores from __fish_status_to_signal * Document fish_status_to_signal * CHANGELOG: Add fish_status_to_signal * Add string join to fish_status_to_signal documentation example
This commit is contained in:
parent
29121ffc4c
commit
18940ea086
4 changed files with 32 additions and 2 deletions
|
@ -102,6 +102,7 @@ Scripting improvements
|
||||||
- ``string`` subcommands now quit early when used with ``--quiet`` (:issue:`7495`).
|
- ``string`` subcommands now quit early when used with ``--quiet`` (:issue:`7495`).
|
||||||
- Failed redirections will now set ``$status`` (:issue:`7540`).
|
- Failed redirections will now set ``$status`` (:issue:`7540`).
|
||||||
- ``read`` can now read interactively from other files, so e.g. forcing it to read from the terminal via ``read </dev/tty`` works (:issue:`7358`).
|
- ``read`` can now read interactively from other files, so e.g. forcing it to read from the terminal via ``read </dev/tty`` works (:issue:`7358`).
|
||||||
|
- The previously internal function ``__fish_status_to_signal`` is now ``fish_status_to_signal``, documented, and ready for external use.
|
||||||
|
|
||||||
Interactive improvements
|
Interactive improvements
|
||||||
------------------------
|
------------------------
|
||||||
|
|
29
doc_src/cmds/fish_status_to_signal.rst
Normal file
29
doc_src/cmds/fish_status_to_signal.rst
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
.. _cmd-fish_status_to_signal:
|
||||||
|
|
||||||
|
fish_status_to_signal - Convert exit codes to human-friendly signals
|
||||||
|
====================================================================
|
||||||
|
|
||||||
|
Synopsis
|
||||||
|
--------
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
function fish_prompt
|
||||||
|
echo -n (fish_status_to_signal $pipestatus | string join '|') (prompt_pwd) '$ '
|
||||||
|
end
|
||||||
|
|
||||||
|
Description
|
||||||
|
-----------
|
||||||
|
|
||||||
|
``fish_status_to_signal`` converts exit codes to their corresponding human-friendly signals if one exists.
|
||||||
|
This is likely to be useful for prompts in conjunction with the ``$status`` and ``$pipestatus`` variables.
|
||||||
|
|
||||||
|
Example
|
||||||
|
-------
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
>_ sleep 5
|
||||||
|
^C⏎
|
||||||
|
>_ fish_status_to_signal $status
|
||||||
|
SIGINT
|
|
@ -23,7 +23,7 @@ function __fish_print_pipestatus --description "Print pipestatus for prompt"
|
||||||
# SIGPIPE (141 = 128 + 13) is usually not a failure, see #6375.
|
# SIGPIPE (141 = 128 + 13) is usually not a failure, see #6375.
|
||||||
if not contains $last_status 0 141
|
if not contains $last_status 0 141
|
||||||
set -l sep $brace_sep_color$separator$status_color
|
set -l sep $brace_sep_color$separator$status_color
|
||||||
set -l last_pipestatus_string (__fish_status_to_signal $argv | string join "$sep")
|
set -l last_pipestatus_string (fish_status_to_signal $argv | string join "$sep")
|
||||||
set -l last_status_string ""
|
set -l last_status_string ""
|
||||||
if test $last_status -ne $argv[-1]
|
if test $last_status -ne $argv[-1]
|
||||||
set last_status_string " "$status_color$last_status
|
set last_status_string " "$status_color$last_status
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
function __fish_status_to_signal --description "Print signal name from argument (\$status), or just argument"
|
function fish_status_to_signal --description "Print signal name from argument (\$status), or just argument"
|
||||||
for arg in $argv
|
for arg in $argv
|
||||||
if test $arg -gt 128
|
if test $arg -gt 128
|
||||||
set -l signals SIGHUP SIGINT SIGQUIT SIGILL SIGTRAP SIGABRT SIGBUS \
|
set -l signals SIGHUP SIGINT SIGQUIT SIGILL SIGTRAP SIGABRT SIGBUS \
|
Loading…
Reference in a new issue