Commit Graph

8127 Commits

Author SHA1 Message Date
Mahmoud Al-Qudsi
3083e0ea80 Work around false positive RESOURCE_LEAK in coverity scan
Fixes defect number 7520322
2018-02-08 16:59:38 -06:00
Mahmoud Al-Qudsi
82b7e6de69 Fix unused code (coverity defect #7520283)
Due to the logic above, isz cannot be zero if we take the else branch.
2018-02-08 16:54:28 -06:00
ridiculousfish
56a46a0bab Merge 'Rearchitect WSL compatibility from SIGCONT to keepalive process'
This merges a sequence of commits that undoes the SIGCONT orchestration
used for WSL compatibility. The essential problem is this: In Unix and
Linux, exited processes are still valid until it is reaped; you can, say,
make an exited process a group leader. But in Windows, when a process
exits, it is gone, and most syscalls (other than, say, waitpid) fail for
it. This is known as the WSL Rick Grimes problem.

This manifests as various race conditions in WSL between a parent operating
on a child, and the child exiting. Prior to this merge, these were
addressed by having the child wait for the parent to send it a SIGCONT.
This resolved the race.

This merge removes this approach and replaces it with a simpler mechanism
that leverages the existing keepalive machinery. A keepalive process is
created for all platforms when we have a pipeline that contains a builtin.
This is necessary to keep the whole process group alive. The fix is, on
WSL, we always create a keepalive and make it the group leader. Because the
keepalive does not call exec and its lifetime is bound to a C++ stack
frame, it is easy to resolve the race.

This improves performance a bit (except on WSL), since child processes no
longer have to synchronize with the parent process, but the big win is
simplicity. This removes the notion of the single global stopped child, of
which there could only be one, and which had be resumed at the right
time(s), of which there were several.
2018-02-07 12:57:01 -08:00
ridiculousfish
cb03be9fe6 Remove unused 'pgrp_set' variable 2018-02-07 12:54:26 -08:00
ridiculousfish
8de266afb4 Improve commenting regarding process groups and builtins. 2018-02-07 12:49:12 -08:00
ridiculousfish
0c18f68cc2 Remove support for blocking children
This removes support for blocking children via signals, which was used
to orchestrate processes on WSL. Now we use the keepalive mechanism
instead.
2018-02-07 12:49:12 -08:00
ridiculousfish
080521071f Teach keepalives to exit when their parent dies
keepalive processes are typically killed by the main shell process.
However if the main shell exits the keepalive may linger. In WSL
keepalives are used more often, and the lingering keepalives are both
leaks and prevent the tests from finishing.

Have keepalives poll for their parent process ID and exit when it
changes, so they can clean themselves up. The polling frequency can be
low.
2018-02-07 12:49:12 -08:00
ridiculousfish
14880ce7d1 Resume setting group ID in both parent and child 2018-02-07 12:49:12 -08:00
ridiculousfish
e9f676a7f4 Provide a way to stop blocking children via s_block_children
This is to investigate alternatives to the existing kill(SIGSTOP)
WSL compatibility thing.
2018-02-07 12:49:11 -08:00
ridiculousfish
1b1fd5ab9b Mark needs_keepalive more often for WSL
Have WSL use a keepalive whenever the first process is external.
This works around the fact that WSL prohibits setting an exited
process as the group leader.
2018-02-07 12:49:11 -08:00
ridiculousfish
cef39cdcc0 Add is_windows_subsystem_for_linux to detect WSL 2018-02-07 12:49:11 -08:00
Fabian Homborg
a04a6d116e [docs] PLURALIZE
My last commit for the day.
2018-02-07 01:12:30 +01:00
Fabian Homborg
59a90fc543 [docs] Reword test example
That was a bit too stuffy.

[ci skip]
2018-02-07 01:12:01 +01:00
Fabian Homborg
50bec2c32e [docs] Add test example to tutorial
As stated in
https://stackoverflow.com/questions/48653771/fishshell-checking-equvalancy-like-does-in-most-languages,
we didn't have one of those, and `test` is a relatively important part
of plenty of `if`s.
2018-02-07 01:09:33 +01:00
Fabian Homborg
aa31fb92f2 Skip interactive tests on macOS on Travis
These just add noise since Travis' macOS machines are apparently
hopelessly overloaded.

Fixes my sanity.
2018-02-06 18:54:27 +01:00
Benoit Hamon
54c9d57e42 Ansible completions (#4697)
* 🚀

* prepare to merge into fish-shell

* split into different files

* remove deprecated option

* captitalize descriptions

* make shorter description for ansible

* update ansible-playbook (and ansible for consistency)

* update version on vault and galaxy
2018-02-06 17:53:23 +01:00
Mahmoud Al-Qudsi
7fafdee98e
Merge pull request #4704 from fish-shell/curses_ncurses
Fix curses includes on platforms offering real libcurses.
2018-02-06 10:44:29 -06:00
ridiculousfish
72208a9438 Use the layout cache instead of static variables for caching prompts
This correctly reacts to changes in TERM (which might affect prompt
width due to escape code differences), and eliminates some ugly
static variables.
2018-02-04 16:20:55 -08:00
ridiculousfish
1bd5946d23 Add prompt layout caching to layout_cache_t 2018-02-04 16:20:55 -08:00
ridiculousfish
d1436486e2 Rename cached_esc_sequences_t to layout_cache_t
Preparation for migrating the prompt cache into this struct.
2018-02-04 16:20:55 -08:00
Fabian Homborg
634feac600 [docs] Remove mention of cached variables from math
The variable cache was removed in
95162ef19d, so this is now wrong.
2018-02-04 23:26:21 +01:00
ridiculousfish
8386a815d3 Add updated pager reserved line behavior to changelog 2018-02-04 14:17:38 -08:00
ridiculousfish
a87970fbb5 Have the pager use a simple newline count to determine reserved lines
When the pager wants to use the full screen to show many options, it reserves
space at the top to see the command. Previously it pretended the command was a
prompt and engaged the prompt layout mechanism to compute these lines. Instead
let's juts count newlines since escape sequences within commands are very rare.
2018-02-04 14:14:37 -08:00
slama
27c1c06ed4 improve the size of completions page to show the entire prompt 2018-02-04 14:04:08 -08:00
ridiculousfish
9ba6b62791 Remove some ancient "#if 0' code and fix formatting errors 2018-02-04 14:03:08 -08:00
Mahmoud Al-Qudsi
63c8a197e5 [cmake] Clean up curses vs ncurses includes
There were several issues with the way that the include tests for curses.h
were being done that were ultimately causing fish to use the headers from
ncurses but link against curses on platforms that provide an actual
libcurses.so that isn't just a symlink to libncurses.so

In particular, the old code was first testing for curses's cureses.h and then
falling back to libncurses's implementation of the same - but that logic was
reversed when it came to including term.h, in which case it was testing for
the ncurses term.h and falling back to the curses.h header. Long story short,
while cmake will link against libcurses.so if both libcurses.so and
libncurses.so are present (unless CURSES_NEED_NCURSES evaluates to TRUE, but
that makes ncurses a hard requirement), but we were brining in some of the
defines from the ncurses headers, causing SIGSEGV panics when fish ultimately
tried to access variables that weren't exported or were mapped to undefined
areas of memory in the other library.

Additionally it is an error to include termios.h prior to including the plain
Jane curses.h (not ncurses/curses.h), causing errors about unimplemented types
SGTTY/chtype. So far as I can tell, both curses.h and ncurses/curses.h pull in
termios.h themselves so it shouldn't even be necessary to manually include it,
but I have just moved its #include below that of curses.h
2018-02-04 03:11:22 -06:00
Mahmoud Al-Qudsi
a95a83b140 [cmake] Add missing HAVE_CURSES_H #cmakedefine 2018-02-04 03:11:22 -06:00
Mahmoud Al-Qudsi
fea1597a27 [cmake] Correct test for term.h (include curses.h first)
The non-ncurses version of term.h requires that curses.h be first
included. Only very recent versions of CMake include a LANGUAGE
option to CHECK_INCLUDE_FILES, so we aren't using it and specifying
CXX here..
2018-02-04 03:11:22 -06:00
ridiculousfish
85fba3a316 Remove HISTORY_SEARCH_TYPE_*_PCRE
These were unused and unimplemented.
2018-02-03 14:41:01 -08:00
ridiculousfish
89709c3a89 Clean up some history search interfaces 2018-02-03 14:41:01 -08:00
Fabian Homborg
5262719995 Don't fire exit events for jobs with pgid == -2
This fixes a hang common on WSL, when fish has PID 2.

Fixes #4582.
2018-02-03 16:22:57 +01:00
David Adam
3be0261294 travis: move to in-tree builds 2018-02-01 22:48:12 +08:00
David Adam
56be045324 [cmake] copy shipped documentation files if they exist
Enables documentation in tarballs to be installed, even if Doxygen isn't
present.
2018-02-01 22:46:27 +08:00
David Adam
e1bc48492f [cmake] only copy tests for out-of-tree builds
Makes in-tree builds work again.
2018-02-01 22:46:27 +08:00
David Adam
d28493dba6 [cmake] add variable if building in-tree 2018-02-01 22:46:27 +08:00
Fabian Homborg
7d60d1db6d [git completions] Remove unique-remote-branches
This never worked properly (since a branch that only exists locally
would also be offered) and is dog-slow.

When we come up with a better way to do it we can readd it.
2018-01-31 21:55:22 +01:00
Fabian Homborg
18e21a0992 [git completions] Complete branches faster
This saves one `git branch` invocation and improves the descriptions.
2018-01-31 21:55:18 +01:00
Fabian Homborg
0ab437be26 [git completions] Make paths not in $PWD relative to the root again
When git prints a path like "share/completions/git.fish", that's
relative to the root of the repo. So we need to either remove
everything from the $PWD (if the path is inside the $PWD), or prepend
a ":/", which is git-speak for "relative to the root".

This was removed by mistake in the recent switch to `git status`.

Fixes #4688.
2018-01-31 11:25:13 +01:00
Fabian Homborg
4fac2f98c2 [git completions] Use status v1 output
Apparently the v2 format is too new (released Nov 2016), and the v1
format has everything we need.
2018-01-31 11:25:13 +01:00
ogaclejapan
64c8d4c265 Fix typo that invalid options in argparse 2018-01-31 16:45:19 +11:00
David Adam
fb53a96a1c Add configure-time check for std::make_unique
Fixes the build on Clang 6 and closes #4685.
2018-01-31 13:43:05 +08:00
ridiculousfish
54cefeb5b1 Make sliced history (e.g. $history[1]) much faster
This special cases expansion of $history variables, so that slicing
history no longer needs to construct the entire history array. Speedup
is around 100x in my test.

Fixes #4650
2018-01-30 18:34:46 -08:00
ridiculousfish
816d35de43 Clean up expand_variables
Partially rewrite this function to be shorter and easier to follow.
2018-01-30 17:45:34 -08:00
ridiculousfish
3d1975c6a6 Convert variable_is_colon_delimited_var to a const array 2018-01-30 13:32:15 -08:00
ridiculousfish
39a02f8ead Turn the set of read-only variables into a const array 2018-01-30 13:28:49 -08:00
ridiculousfish
f025269195 env_var_t to forget its name
Store properties associated with the name via flags instead
2018-01-30 12:36:50 -08:00
ridiculousfish
5c2e6734c1 Normal text input to disable paging instead of search
Prior to this fix, if the user typed normal characters while the
completion pager was shown, it would begin searching. This feature was
not well liked, so we are going to instead just append the characters as
normal and disable paging. Control-S can be used to toggle the search
field.

Fixes #2249
2018-01-30 09:58:08 -08:00
ridiculousfish
c4a12f90c1 Bind pager-toggle-search to control-s by default. 2018-01-30 09:58:08 -08:00
ridiculousfish
d0d7bb75cd Add new pager-toggle-search input function
This adds a new input binding pager-toggle-search which toggles the
search field on and off when the pager is showing.
2018-01-30 09:58:08 -08:00
David Adam
f135c53196 [cmake] move all CheckFunctionExists to CheckCXXSymbolExists
CheckFunctionExists checks for C linkage only, and recommends the use of
CheckSymbolExists in the documentation. This improves the detection of
C++ features, as opposed to C features.
2018-01-30 22:28:04 +08:00