mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-12 13:08:49 +00:00
function: restore '%self' functionality for --on-process-exit
One key use of process expansion, used in currently-shipped code, is for running a function on current shell exit. Restore the use of %self as a valid argument (and add `self`) and document this change. (faho: Remove bare "self")
This commit is contained in:
parent
98d736f916
commit
21890ccac7
2 changed files with 8 additions and 1 deletions
|
@ -25,7 +25,10 @@ The following options are available:
|
||||||
|
|
||||||
- `-j PGID` or `--on-job-exit PGID` tells fish to run this function when the job with group ID PGID exits. Instead of PGID, the string 'caller' can be specified. This is only legal when in a command substitution, and will result in the handler being triggered by the exit of the job which created this command substitution.
|
- `-j PGID` or `--on-job-exit PGID` tells fish to run this function when the job with group ID PGID exits. Instead of PGID, the string 'caller' can be specified. This is only legal when in a command substitution, and will result in the handler being triggered by the exit of the job which created this command substitution.
|
||||||
|
|
||||||
- `-p PID` or `--on-process-exit PID` tells fish to run this function when the fish child process with process ID PID exits.
|
- `-p PID` or `--on-process-exit PID` tells fish to run this function when the fish child process
|
||||||
|
with process ID PID exits. Instead of a PID, for backward compatibility,
|
||||||
|
"`%self`" can be specified as an alias for `$fish_pid`, and the function will be run when the
|
||||||
|
current fish instance exits.
|
||||||
|
|
||||||
- `-s` or `--on-signal SIGSPEC` tells fish to run this function when the signal SIGSPEC is delivered. SIGSPEC can be a signal number, or the signal name, such as SIGHUP (or just HUP).
|
- `-s` or `--on-signal SIGSPEC` tells fish to run this function when the signal SIGSPEC is delivered. SIGSPEC can be a signal number, or the signal name, such as SIGHUP (or just HUP).
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,10 @@ static int parse_cmd_opts(function_cmd_opts_t &opts, int *optind, //!OCLINT(hig
|
||||||
}
|
}
|
||||||
e.type = EVENT_JOB_ID;
|
e.type = EVENT_JOB_ID;
|
||||||
e.param1.job_id = job_id;
|
e.param1.job_id = job_id;
|
||||||
|
} else if ((opt == 'p') && (wcscasecmp(w.woptarg, L"%self") == 0)) {
|
||||||
|
pid = getpid();
|
||||||
|
e.type = EVENT_EXIT;
|
||||||
|
e.param1.pid = pid;
|
||||||
} else {
|
} else {
|
||||||
pid = fish_wcstoi(w.woptarg);
|
pid = fish_wcstoi(w.woptarg);
|
||||||
if (errno || pid < 0) {
|
if (errno || pid < 0) {
|
||||||
|
|
Loading…
Reference in a new issue