This suppresses lint warnings about using `getpwent()` because there is
only one context where fish uses it. Thus the fact it may not be thread
safe is not relevant to fish. This also improves that call site in
`completer_t::try_complete_user()` method by short-circuiting the loop
when a match is found.
The lint warning about possible problems using `flock()` to lock files
that I added isn't helpful and is just noise in the `make lint-all`
output. What we should do is is change to code to obviate the need for
file locking. But that's a big change for another day.
Another change related to issue #3985. I forgot to includes this in my
previous two changes related to to consistently returning status 121
when any command, not just `string`, is handed invalid args.
This changes all of the builtins to behave like `string` to return
STATUS_INVALID_ARGS (121) if the args passed to the command don't make
sense. Also change several of the builtins to use the existing symbols
(e.g., STATUS_CMD_OK and STATUS_CMD_ERROR) rather than hardcoded "0"
and "1" for consistency and to make it easier to find such values in
the future.
Fixes#3985
This primarily replaces "STATUS_BUILTIN_OK" with "STATUS_CMD_OK" and
"STATUS_BUILTIN_ERROR" with "STATUS_CMD_ERROR". That is because we want
to make it clear these status codes are applicable to fish functions as
well as builtins. Future changes will make it easier to use these
symbols and values in functions.
Working on a related problem caused me to notice that if a fish script
was run via `nohup` it would die when receiving SIGHUP. This fixes the
code to handle that correctly so that fish scripts can be nohup'd.
Fixes#4007
Per discussion in PR#3998 to review adding a `--filter` flag to `string
replace` rename the same flag in the `string match` subcommand to avoid
confusion about the meaning of the flag.
Discussion in issue #3295 resulted in a decisions to rename the
functions --metadata flag to --details.
This also fixes a bug in the definition of the short flags for the
`functions` command. The `-e` flag does not take an argument and
therefore should not be defined as `e:`. Notice that the long form,
`--erase`, specifies `no_argument`. This discrepency happened to work
due to a quirk of how the flag parsing loop was written.
0 is not a good default PGID, because it's possible for a kernel process
to have the PGID of 0 under Linux.
This meant that job_get_from_pid could return incorrect jobs, as the PGID
for internal, non-forked jobs was the same as kernel processes.
Avoid this by using an invalid PGID as the initial PGID.
It is possible for fish to not be the process group leader; avoid
signalling the process group containing the current process by checking
with getpgrp() rather than assuming that getpid() is enough.
If fish is not the first process in a pipeline, and jobs are started
from the fish process, it is possible for fish and the OS to have
different ideas about what the process group of the jobs are.
This change confirms the current PGID, rather than assuming that it is
the same as the PID.