Commit Graph

9024 Commits

Author SHA1 Message Date
Fabian Homborg
460bc00698 Fix string escape var and url styles
Turns out I broke these in my zeal to remove wcs2string.

This reverts commit 583d771b10.

Fixes #5322.
2018-11-07 12:48:11 +01:00
ridiculousfish
bfd50863b8 Correct fish_wcstod and fix Linux build failure
Limit the fish_wcstod fast path to ASCII digits only, to fix the problem
observed in the discussion for a700acadfa
where LANG=de_DE.UTF-8 would cause `test` to interpret commas instead of
periods inside floating point values.
2018-11-06 23:17:41 -08:00
Aaron Gyes
db1500bfa4
Update CHANGELOG.md
Mention that dim/italics were made to work on macOS (ancient ncurses).
2018-11-06 14:09:26 -08:00
Fabian Homborg
4d4227e57f completions/git: Match files inside directories again
Fixes #5317.
2018-11-05 15:53:06 +01:00
ridiculousfish
a700acadfa Implement fish_wcstod and adopt it in builtin_test
wcstod_l is enormously slow on the Mac. This makes arithmetic comparisons
using builtin_test about 250% as fast on macOS.
2018-11-04 20:28:10 -08:00
Mahmoud Al-Qudsi
8ebf2b8f70 Improve pandoc completions
* Only suggest PDF engines that are currently installed
* Use XDG_CONFIG_HOME (after a fashion)
* Initialize lists as arrays instead of blind strings
2018-11-04 20:49:57 -06:00
Mahmoud Al-Qudsi
ffb4ab5ca8 Prevent pandoc completions from polluting global namespace 2018-11-04 20:38:59 -06:00
Mahmoud Al-Qudsi
11b0b23587 Add git remote remove completions 2018-11-04 14:36:51 -06:00
Fabian Homborg
a7ec158373 env: Use preexisting_flags to determine pathiness
We've already checked if the variable exists above, and we've already
gotten the preexisting_flags, so we can just use them.

Saves a lookup.
2018-11-04 17:05:22 +01:00
Moritz Wilhelmy
9afc4b419e Allow cd . to re-enter the current directory
Closes #4543.
2018-11-04 21:46:24 +08:00
David Sanson
7926b69d15 Add completions for pandoc
Taken from https://github.com/dsanson/fish-completion-pandoc under the
GNU GPL as at 7195da6fc4bcbdd49ea63d47c27e4bfec2135660.

Closes #2937.
2018-11-04 21:22:58 +08:00
David Adam
4f3786f8d0 Build system: add extra sysconf directories
Closes #5235.
2018-11-04 21:14:06 +08:00
ridiculousfish
c2ffd3008a Merge branch 'remove_static_stacks'
This merges a stack that removes the WAIT_BY_PROCESS and NESTED job flags.
Instead jobs are taught about their parents, and parents are interrogated to
determine whether they are fully constructed, and therefore whether it is
safe to call waitpid().
2018-11-04 02:00:08 -08:00
ridiculousfish
73537fc7c3 Remove NESTED and WAIT_BY_PROCESS
Now jobs are aware of their parent jobs, and can interrogate those jobs,
to determine if every job in the chain is fully constructed.
Remove flags and the static stacks that manipulated them.
2018-11-04 01:52:17 -08:00
ridiculousfish
30990e8069 Replace WAIT_BY_PROCESS with a parent job check
Instead of manipulating the WAIT_BY_PROCESS flag, have each job interrogate
its "parent chain" to decide if it is safe to waitpid() on its pgid.
2018-11-04 01:51:21 -08:00
ridiculousfish
3770d9fb7a Teach each job about its parent
The parent of a job is the parent pipeline that executed the function or
block corresponding to this job. This will help simplify
process_mark_finished_children().
2018-11-04 01:40:07 -08:00
ridiculousfish
93aa95d8c4 Remove proc_last_bg_pid
It wasn't used.
2018-11-03 19:28:16 -07:00
ridiculousfish
0373a87867 Remove shell_pgid from process_mark_finished_children
It was unused.
2018-11-03 19:19:52 -07:00
ridiculousfish
182d7ce732 Teach cd completions about logical paths
Prior to this fix, cding into a symlink and then completing .. would complete
from the physical directory instead of the logical directory, which could not
actually be cd'd to. Teach cd completiond to use the logical directory.
2018-11-03 13:30:55 -07:00
ridiculousfish
cf01694def Migrate token_infos inside token_for_string and reformat 2018-11-03 12:16:56 -07:00
Fabian Homborg
e1c0ab8edb test: Switch to std::map
Massively improves the time to lookup the token type.

This speeds up `test 1 = 1` by ~8%.
2018-11-03 19:58:51 +01:00
santpent
22f794125f add command substition indexing examples (#5303)
* add command substition indexing examples

following from issue #243

* Update index.hdr.in
2018-11-02 13:24:51 +01:00
Fabian Homborg
9300ec55f0 parser_keywords: Use unordered_set instead of arrays
This makes the test mentioned in #5305:

    for i in (seq 100000); test 1 = 1; end

run ~5% faster.
2018-11-02 12:28:09 +01:00
Fabian Homborg
47c1144a3c cmake: Enable colors with ninja
Unfortunately this needs a bit of a hack, as the compiler uses isatty(),
and ninja uses a pipe.
2018-11-02 12:26:27 +01:00
Fabian Homborg
1836e704c4 Remove unnecessary "string_set_contains" function 2018-11-02 11:46:05 +01:00
Mahmoud Al-Qudsi
dfcf140e00 Add warning about broken zombie support on setpgid() fail under WSL 2018-10-31 06:23:57 +00:00
Mahmoud Al-Qudsi
b23bda8ed6 Only offer local branches for deletion in git completions 2018-10-30 05:14:20 +00:00
Mahmoud Al-Qudsi
913f65cd77
Merge pull request #5293 from mqudsi/issue_5292
Block on fg processes even if not under job control
2018-10-29 23:33:05 -05:00
Mahmoud Al-Qudsi
3b210cc5bd Do not audibly complain on EINTR in waitpid call 2018-10-29 14:22:46 -05:00
Mahmoud Al-Qudsi
1288877033 Update yarn completions
Don't attempt to complete against package names if the user is trying to
enter a switch to speed things up.

Also work around #5267 by not wrapping unfiltered `all-the-package-name`
calls in a function.
2018-10-29 13:56:40 -05:00
Clément Martinez
13c2b4cdc3 Improve virsh completions 2018-10-29 18:01:52 +01:00
Mahmoud Al-Qudsi
132edda6ff Block on fg processes even if not under job control
Closes #5292.
2018-10-29 04:45:47 +00:00
ridiculousfish
fd13043340 Rename select_try_t::IO_ERROR to select_try_t::IOCHAIN_EMPTY
select_try() returned IO_ERROR to indicate that there's no file descriptors
from which to read. Name this return value properly.

Also migrate this type into proc.cpp since it's not used outside of the
header.
2018-10-28 17:14:25 -07:00
ridiculousfish
03ec48c701 Turn the select_try_t into a switch statement
This allows the compiler to warn about missing cases.
2018-10-28 17:12:01 -07:00
ridiculousfish
bf089addd0 Restyle proc.cpp 2018-10-28 17:09:57 -07:00
Mahmoud Al-Qudsi
a2dda29cf6 Fix build on macOS Yosemite
Older versions of the macOS dev toolchain use MAP_ANON instead of
MAP_ANONYMOUS. We already do this elsewhere.
2018-10-28 12:48:27 -05:00
Mahmoud Al-Qudsi
203de775d0 Fix hang when piping from function to process and exceeding pipe buffer
This is an opposite case from the usual "pipe into grep-the-function"
where my `pbpaste` emitted a lot of content exceeding the OS pipe
buffer. The `block_on_fg` condition was just `send_sigcont` in the
original job control rewrite, and it was incorrect to sub it for
WAIT_BY_PROCESS on its own.

However, this requires always blocking when select_try returns an
interrupted/incomplete read or else fish doesn't block and stays running
in a tight loop in the background (and incorrectly writing to a terminal
it doesn't own under higher debug levels), which I *think* is OK.
2018-10-28 10:35:51 -05:00
Mahmoud Al-Qudsi
1015e74480 Treat _ and - alike for case-insensitive fuzzy matching
Closes #3584.
2018-10-28 10:35:32 -05:00
ridiculousfish
e09e1e8e41 Fix funced when using the built-in editor 2018-10-27 17:19:43 -07:00
Mahmoud Al-Qudsi
17049ce919 Reuse std::locale() across calls within single ifind()
Instantiate the std:locale instance used within the character comparison
callback outside the lambda and take a reference to it instead of
creating the locale object for each character in the sequence.

This is part of a very tight loop with lots of inputs during the
evaluation of fuzzy string matches for completions/autosuggestions and
is worth optimizing.
2018-10-27 18:51:59 -05:00
Mahmoud Al-Qudsi
0d8334a31b Fix hup_background_jobs (née kill_background_jobs) implementation
This was introduced in 1b1bc28c0a but did
not cause any problems until the job control refactor, which caused it
to attempt to signal the calling `exec` builtin's own (invalid) pgrp
with SIGHUP.

Also improved debugging for `j->signal()` failures by printing the
signal we tried sending in case of error, rename the function to
`hup_background_jobs`, and move it from `reader.h`/`reader.cpp` to
`proc.h`/`proc.cpp`.
2018-10-27 18:01:38 -05:00
Mahmoud Al-Qudsi
4d3b56c151 Associate external commands in functions with extant pgrps
When a function is encountered by exec_job, a new context is created for
its execution from the ground up, with a new job and all, ultimately
resulting in a recursive call to exec_job from the same (main) thread.

Since each time exec_job encounters a new job with external commands
that needs terminal control it creates a new pgrp and gives it control
of the terminal (tcsetpgrp & co), this effectively takes control away
from the previously spawned external commands which may be (and likely
are) expecting to still have terminal access.

This commit attempts to detect when such a situation arises by handling
recursive calls to exec_job (which can only happen if the pipeline
included a function) by borrowing the pgrp from the (necessarily still
active) parent job and spawning new external commands into it.

When a parent job spawns new jobs due to the evaluation of a new
function (which shouldn't be the case in the first place), we end up
with two distinct jobs sharing one pgrp (to fix #3952). This can lead to
early termination of a pgrp if finished parent job children are reaped
before future processes in either the parent or future child jobs can
join it.

While the parent job is under construction, require that waitpid(2)
calls for the child job be done by process id and not job pgrp.

Closes #3952.
2018-10-27 18:01:38 -05:00
Mahmoud Al-Qudsi
419d7a5138 Don't decompose shared_ptr to raw pointer for exec_job 2018-10-27 18:01:38 -05:00
Mahmoud Al-Qudsi
008eef50f3 Speed up process_mark_finished_children calls
Use SIGCHLD to determine whether or not waitpid(2) calls can be elided,
but only with extreme caution. If we receive SIGCHLD but are not able to
reap all jobs, we need to iterate through them again.

For this to work, we need to make sure that we reap all children that we
can reap after a SIGCHLD, i.e. it's not OK to just reap the first and
return or else we can never clear the dirty state flag.

In all cases, as expensive as a call to waitpid() may be, if a child
process is available for reaping it is always cheaper to wait on it then
reap it than to call select_try() and end up timing out.
2018-10-27 18:01:38 -05:00
Mahmoud Al-Qudsi
c7f5e58927 More graceful handling of setpgid(2) failure in child_set_group()
Handle EPERM (WSL only?) and EINTR by retrying.
2018-10-27 18:01:38 -05:00
Mahmoud Al-Qudsi
3afcca3114 Drop keepalive process even for WSL
Windows 10 17763 Redstone 5 (October 2018 Update) officially brings
zombie support (first introduced in 17713) to the general public.

See https://docs.microsoft.com/en-us/windows/wsl/release-notes#build-17763-1809
2018-10-27 18:01:38 -05:00
Mahmoud Al-Qudsi
319d1b81fb Add note about PROCESS_EXIT still being used 2018-10-27 18:01:38 -05:00
Mahmoud Al-Qudsi
8072900e16 Change control flow in job_continue()
The old code was rather haphazard with regards to error control, and
would make mutable changes before operations that could fail without any
viable error handling options.
2018-10-27 18:01:38 -05:00
Mahmoud Al-Qudsi
39a05a359a Overhaul continue_job() and try_select()
Convert `select_try()` to return a well-defined enum describing its
state, and handle each of the three possible cases with clear reasons
why we are blocking or not blocking in each subsequent call to
`process_mark_finished_children()`.
2018-10-27 18:01:38 -05:00
Mahmoud Al-Qudsi
1bfbed94ae Clean up terminal_give_to_job()
* Use the newly-introduced signal_block_t RAII wrapper
* Remove EINTR loops as all signals are blocked
* Clean up control flow thanks to RAII wrappers
* Rename parameter to clarify what it does and update docs accordingly
* Update outdated comments referencing SIGSTOP code that was removed a
  long time ago.
* Remove no-op CHECK_BLOCK() call
2018-10-27 18:01:38 -05:00