Commit Graph

9664 Commits

Author SHA1 Message Date
ridiculousfish
061f8f49c6 Add dup2_list_t::fd_for_target_fd
This adds an "in-process" interpretation of dup2s, allowing for fish to
output directly to the correct file descriptor without having to perform
an in-kernel dup2 sequence.
2019-02-17 13:01:59 -08:00
ridiculousfish
ebe2dc2766 Processes to record topic generations before execution
The sigchld generation expresses the idea that, if we receive a sigchld
signal, the generation will be different than when we last recorded it. A
process cannot exit before it has launched, so check the generation count
before process launch. This is an optimization that reduces failing
waitpid calls.
2019-02-17 13:01:59 -08:00
ridiculousfish
a95bc849c5 Rewrite process_mark_finished_children using topics
This is a big change to how process reaping works, reimplenting it using
topics. The idea is to simplify the logic in
process_mark_finished_children around blocking, and also prepare for
"internal processes" which do not correspond to real processes.

Before this change, fish would use waitpid() to wait for a process group,
OR would individually poll processes if the process group leader was
unreapable.

After this change, fish no longer ever calls blocking waitpid(). Instead
fish uses the topic mechanism. For each reapable process, fish checks if
it has received a SIGCHLD since last poll; if not it waits until the next
SIGCHLD, and then polls them all.
2019-02-17 13:01:59 -08:00
ridiculousfish
a4dc04a28e Add sighupint topic
This corresponds to SIGHUP and SIGINT. This will be used to break out of
process_mark_finished_children().
2019-02-17 13:01:59 -08:00
ridiculousfish
fc9d238642 Introduce topic monitoring
topic_monitor allows for querying changes posted to one or more topics,
initially sigchld. This will eventually replace the waitpid logic in
process_mark_finished_children().

Comment from the new header:

Topic monitoring support. Topics are conceptually "a thing that can
happen." For example, delivery of a SIGINT, a child process exits, etc. It
is possible to post to a topic, which means that that thing happened.

Associated with each topic is a current generation, which is a 64 bit
value. When you query a topic, you get back a generation. If on the next
query the generation has increased, then it indicates someone posted to
the topic.

For example, if you are monitoring a child process, you can query the
sigchld topic. If it has increased since your last query, it is possible
that your child process has exited.

Topic postings may be coalesced. That is there may be two posts to a given
topic, yet the generation only increases by 1. The only guarantee is that
after a topic post, the current generation value is larger than any value
previously queried.

Tying this all together is the topic_monitor_t. This provides the current
topic generations, and also provides the ability to perform a blocking
wait for any topic to change in a particular topic set. This is the real
power of topics: you can wait for a sigchld signal OR a thread exit.
2019-02-17 13:01:59 -08:00
ridiculousfish
ccc45235b0 Introduce enum_array_t
Allows for indexing an array via an enum class.
2019-02-17 13:01:59 -08:00
ridiculousfish
78ed659151 Fancify enum_set and introduce enum_iter_t
Allow iterating over the values of an enum class.
2019-02-17 13:01:59 -08:00
Collin Styles
8a0be93e50 Add completions for "git remote get-url" 2019-02-17 16:30:00 +01:00
Aaron Gyes
05701a779b isatty: command [ instead of command test
I don't know why but Go users keep having random tools installed into
PATH named `test`. Fixes #5665
2019-02-16 17:15:52 -08:00
Sabine Maennel
20c51b7da9 changes according to feedback
Changes according to the feedback have been made:

- What is a shell section has been moved before Installation and Start section

- Content changes have been made as suggested in both of the above sections.
2019-02-16 13:40:18 -08:00
Sabine Maennel
f6974e5a76 documentation
Start issue 740

- changed introduction section
- added installation section
- added what is a shell section
2019-02-16 13:40:18 -08:00
Fabian Homborg
d48eb56aea Improve curl completions
Just a bunch of rewriting descriptions and some arguments.

Most arguments here are uncompleteable, and most of these options will
never be used.

[ci skip]
2019-02-16 17:01:02 +01:00
Fabian Homborg
fdbbe9f69d fish_tests: Initialize some collections
For some reason this'd crash on NetBSD otherwise.
2019-02-16 16:40:13 +01:00
Fabian Homborg
dbeaa0c8de Add curl completion
Mostly copying the autogenerated stuff with some light description
cleanup.

Fixes #5664.

[ci skip]
2019-02-16 16:40:13 +01:00
ridiculousfish
b6b7550477 Restyle redirection.h 2019-02-16 02:30:21 -08:00
ridiculousfish
f75fe823b8 Minor cleanup of process_t 2019-02-16 01:20:08 -08:00
Mahmoud Al-Qudsi
0f6720ef8e Allow override of cmake binary in BSDmakefile 2019-02-15 12:04:09 -06:00
Mahmoud Al-Qudsi
2a44517842 Update BSDmakefile formatting and add documentation 2019-02-15 12:04:09 -06:00
Aaron Gyes
f10c0dde3b __init_uvar: match previous behavior
query for any set variable, not just universals, lest someone
avoiding uvars intentionally has a problem.
2019-02-14 21:42:42 -08:00
Aaron Gyes
619a248a35 Clean up uvar initialization with a wrapper function
Adds __init_uvar
2019-02-14 17:09:16 -08:00
Mahmoud Al-Qudsi
828a704282 Fix is_wsl() #ifdef guards on non-Linux platforms 2019-02-14 18:30:10 -06:00
Mahmoud Al-Qudsi
552af31ab0 Emit warning when running under an unsupported version of WSL
Closes #5661. Ping #5298.
2019-02-14 18:21:11 -06:00
Mahmoud Al-Qudsi
9796a331bc Make WSL detection dynamic rather than statically compiled
This resolves the issue where running pre-compiled Linux packages from
binary package manager repositories lead fish to think that we are not
running under WSL.

- Closes #5619.
- Ping neovim/neovim#7330
2019-02-14 18:21:11 -06:00
Aaron Gyes
8811a10690
Update .gitattributes 2019-02-14 02:47:12 -08:00
Fabian Homborg
13eb01bc97 share/config: Guard contains against options
Fixes #5662.

[ci skip]
2019-02-14 11:00:47 +01:00
Fabian Homborg
5814b1b8e2 Fix man function for NetBSD
NetBSD's man is unusual in that it doesn't understand an empty
$MANPATH component as "the system man path", and doesn't have a
`manpath` or `man --path`.

It has a `-m` option that would be useful, but other mans also have a
`-m` option that isn't, so detecting it is tough.

It does have a `-p` option that almost does what one would want here,
so we hack around it to make things work.

Fixes #5657.

[ci skip]
2019-02-14 10:57:38 +01:00
Fabian Homborg
f037b0f30f fallback: Use passed locale in wcstod_l
Strange idea, but it just might work.
2019-02-14 10:57:38 +01:00
Mahmoud Al-Qudsi
553bf47191 Fix short arg -S for --shell
Closes #5660
2019-02-13 20:55:19 -06:00
Mahmoud Al-Qudsi
e707c530ee Add note about b247c8d9ad to CHANGELOG
There isn't an issue explicitly associated with this, so it'll probably
get lost.

[ci skip]
2019-02-13 16:45:25 -06:00
Aaron Gyes
5607bc1396
Update .gitattributes 2019-02-13 13:33:12 -08:00
Fabian Homborg
4562f8f4e3 fallback: Set LC_ALL in wcstod_l fallback
Apparently some wcstod's don't care about LC_NUMERIC.
2019-02-13 20:32:07 +01:00
Fabian Homborg
c0dc1870f0 io: Return from read even if return == -1 and errno == 0
This happens on OpenIndiana/Solaris/Illumos/SunOS.

Elsewhere we use read_blocked, which already returned in this
case (and which we might want to use here as well!).
2019-02-13 20:15:09 +01:00
Fabian Homborg
4132bb1a19 gitattributes: Mark CI scripts export-ignore
[ci skip]

(ironically)
2019-02-13 14:20:28 +01:00
Fabian Homborg
fdc4246fff Use builds.sr.ht
Enable builds on builds.sr.ht for freebsd and arch, and alpine (which uses musl).

All are built using cmake, as we want to drop the autotools build.
2019-02-13 14:20:28 +01:00
Fabian Homborg
556ddfa456 Include stdarg.h again
This is needed on NetBSD, and should be harmless elsewhere.
2019-02-13 14:09:14 +01:00
Fabian Homborg
2614deb138 tests/invocation: Use ggrep if available
We use grep -o here to filter output, but that's not available on
OpenIndiana.

It does offer "ggrep" though, which is GNU grep.
2019-02-13 13:49:53 +01:00
Fabian Homborg
c1d042051c Disable directory redirect test
On some systems, this sometimes uses unicode quotation marks.

Not on mine, but on Travis it does.

The only other workaround I can think of is setting locale to C, but
that implies not being able to test anything unicode-related in the
entire invocation tests.

So for now disable this test.
2019-02-13 13:33:30 +01:00
Fabian Homborg
84593e1519 tests/invocation: Remove local
Instead this runs the `test_file` function in a subshell, which is the
POSIXy way of doing this.

Overly magic? Sure. Standard? Indeed.
2019-02-13 13:29:31 +01:00
Fabian Homborg
3e2e44b673 output: One more unconst-cast for tputs
Needed on Solaris/OpenIndiana/Illumos/SunOS.
2019-02-13 13:28:13 +01:00
Fabian Homborg
7508865374 Include string.h where we use memset
This is needed on Solaris/Illumos/OpenIndiana/SunOS.

Presumably it's harmless elsewhere.
2019-02-13 13:27:20 +01:00
Fabian Homborg
02ca7be416 functions/_.fish: Use ggetext if available
It turns out the default gettext on the sunny operating system with
the many names interprets at least `\n` itself, so we'd end up
swallowing it.

This allows us to move past the interactive tests and onto the expect
ones.

See #5472.
2019-02-13 13:05:50 +01:00
Fabian Homborg
1ee57e9244 tests/realpath.in: We want to delete $PWD, darnit!
Illumos/OpenIndiana/SunOS/Solaris has an rm/rmdir that tries to
protect the user by not allowing them to delete $PWD.

Normally, this would be a good thing as deleting $PWD is a stupid
thing to do. Except in this case, we absolutely need to do that.

So instead we weasel around it by invoking an sh to cd out of the
directory to then invoke an `rmdir` to delete it. That should throw
off any attempts at protection (we could also have tried $PWD/. or
similar, but that's possibly still protected against).

This is the last failing test on
Illumos/OpenIndiana/SunOS/Solaris/afunnyquip, so:

Fixes #5472.
2019-02-13 13:05:50 +01:00
Fabian Homborg
c62d95e428 tests: Move directory redirection test to invocation
This tested #1728, where redirecting a directory (`begin; something;
end < .`) would cause `status` to misbehave.

Unfortunately, on Illumos/OpenIndiana/SunOS, this returns a different
error (EINVAL instead of EISDIR), so we can't check that with our test harness, because
we can't redirect it.

Since it's not important that this gives the same error across
systems (and indeed we provide no way of intercepting the error!),
use an invocation test instead, because that allows different output per-uname.

See #5472.
2019-02-13 13:05:50 +01:00
Fabian Homborg
ca5b7c0ec4 math: Allow --scale=max 2019-02-13 12:54:58 +01:00
Fabian Homborg
c5a6d0bfde Split $fish_user_paths on ":" explicitly
It's used with $PATH, so it is _always_ split on ":".

We could also force it to be a path variable, but that seems a bit
overkill.

Fixes #5594.
2019-02-13 12:35:15 +01:00
Andrew Childs
56309f1c2e Only invoke path_helper in login shells
Matches upstream path_helper which is invoked in /etc/profile and only
applies to login shells. Enables running interactive, non-login shells
with altered PATH values.

Reverts change in c0f832a7, which reverts change in adbaddf.
2019-02-13 00:02:03 -08:00
Mrmaxmeier
6e9250425a src/exec: fix assertion on failed exec redirection
Minimal reproducer: `fish -c "exec cat<x"`
2019-02-12 20:52:03 -08:00
Mahmoud Al-Qudsi
b247c8d9ad Explicitly close input fd to fish_title
`fish_title` as invoked by fish itself is not running in an interactive
context, and attempts to read from the input fd (e.g. via `read`) cause
fish to segfault, go into an infinite loop, or hang at the read prompt
depending on the exact command line and fish version.

This patch addresses that by explicitly closing the input fd when
invoking `fish_title`.

Reported by @floam in #5629. May close that issue, but situation is
unclear.
2019-02-12 19:55:20 -06:00
Aaron Gyes
717718353e Remove unused macros 2019-02-12 16:10:18 -08:00
Aaron Gyes
8d9089c78b Revert "io.cpp: use BUFFER_SIZE"
This reverts commit c931e33759.
2019-02-12 15:50:43 -08:00