Commit Graph

2686 Commits

Author SHA1 Message Date
ridiculousfish
8181883111 Minor refactoring of logic around when a job wants to claim the terminal
Introduce should_claim_terminal() which encapsulates an && exprsesion which
was previously repeated a lot.
2019-07-12 13:31:56 -07:00
ridiculousfish
d577eb4aaa Only use the global fish_complete_path and fish_function_path
Prior to this fix, fish would attempt to react if a local fish_complete_path
or fish_function_path were set. However this has never been very well tested
and will become impossible with concurrent execution. Always use the global
values.
2019-07-12 12:40:12 -07:00
ridiculousfish
0e4fe53718 clang-format some files 2019-07-06 13:11:50 -07:00
ridiculousfish
bc0329f775 Add wcstolower
Converts a string to lowercase. Eliminates some loops that did this
explicitly.
2019-07-06 12:19:34 -07:00
ridiculousfish
b1a1b617f1 child_setup_process to accept new termowner directly
Soon we will have more complicated logic around whether to call tcsetpgrp.
Prepare to centralize the logic by passing in the new term owner pgrp,
instead of having child_setup_process perform the decision.
2019-07-03 18:06:35 -07:00
ridiculousfish
8282369f45 child_setup_process to stop passing the process
child_setup_process only cares about whether we are in a forked child, not
the entire process structure. Narrow the parameter.
2019-07-03 17:48:52 -07:00
Fabian Homborg
8013686d17 delete-or-exit: Only exit if the commandline is empty
This exitted if the cursor was at the end of the line as well (i.e. if
delete-char failed). That's a bit too eager.

Also documentation, which should have already been included.
2019-07-03 11:48:38 +02:00
ridiculousfish
09e4f8ff42 Refactor how the terminal is transferred to jobs
Centralize the logic around when a job acquires the terminal.
2019-06-29 15:58:36 -07:00
ridiculousfish
2931d869d5 Remove the foreground job property
This was not used consistently and was confused with the foreground job
flag. Whether a job is foreground is mutable, so it should remain a flag.
2019-06-29 15:54:49 -07:00
ridiculousfish
98ba7d7790 Simplify maybe_assign_terminal()
Move this out of postfork, it is not called after fork.
2019-06-29 14:36:14 -07:00
ridiculousfish
f58960ba01 Add a DIE("unreachable") in should_claim_process_group_for_job
Fixes a gcc warning.
2019-06-29 11:40:52 -07:00
ridiculousfish
4a2c709fb1 Eliminate shell_is_interactive
We used to have a global notion of "is the shell interactive" but soon we
will want to have multiple independent execution threads, only some of
which may be interactive. Start tracking this data per-parser.
2019-06-29 11:28:26 -07:00
ridiculousfish
3f1d7bbdc5 Call tcsetpgrp in child processes before resetting signal handlers
Also ignore SIGTTIN and SIGTTOU across the tcsetpgrp call.

Hopeful fix for #5963
2019-06-28 11:54:55 -07:00
ridiculousfish
262fe65121 Correctly mark a node when erasing an exported variable
Fixes #5965
2019-06-28 11:22:49 -07:00
ridiculousfish
3c800e0608 Make history tests more robust
history now often writes to the history file asynchronously, but the history
test expects to find the text in the file immediately after running the
command. Hack a bit in history to make this test more reliable.
2019-06-28 11:16:27 -07:00
ridiculousfish
e3f94f4b72 Centralize signal handling into a single function
Prior to this diff, fish had different signal handling functions for
different signals. However it was hard to coordinate when a signal needed
to be the default handler, and when it was custom. In #5962 we overwrote
fish's custom WINCH handler with the default_handler when fish script asked
for WINCH to be handled.

Just have a single big signal handler function. That way it can never be
set to the wrong thing.

Fixes #5969
2019-06-28 10:51:22 -07:00
ridiculousfish
8254342339 Remove the useless second parameter from signal_handle
It was always set to 1.
2019-06-28 10:33:03 -07:00
ridiculousfish
f3736e8fdf fish to claim a job's pgroup if the first process is fish internal
When executing a job, if the first process is fish internal, then have
fish claim the job's pgroup.

The idea here is that the terminal must be owned by a pgroup containing
the process reading from the terminal. If the first process is fish
internal (a function or builtin) then the pgroup must contain the fish
process.

This is a bit of a workaround of the behavior where the first process that
executes in a job becomes the process group leader. If there's a deferred
process, then we will execute processes out of order so the pgroup can be
wrong. Fix this by setting the process group leader explicitly as fish
when necessary.

Fixes #5855
2019-06-26 17:30:51 -07:00
ridiculousfish
f7e2e7d26b Don't generate exit events for jobs created from within event handlers
Add a new job property from_event_handler, and do not create exit events for
such jobs. This prevents easy accidental infinite recursion.
2019-06-26 17:30:51 -07:00
Fabian Homborg
d7a9bdf5c3 reader: Do the "delete" part for delete-or-exit
For some reason this is supposed to do a delete-*char*.

I was assuming the function was broken and it should delete the entire
line.

Fixes #5967.
2019-06-26 22:53:19 +02:00
Fabian Homborg
d415350aaf reader: Add delete-or-exit bind function
This is an important binding and should therefore be in C++.
2019-06-25 19:57:00 +02:00
Fabian Homborg
77d8487078 string: Also stop printing documentation
Especially as, in this case, the documentation is quite massive.

Caught by porting string's test to littlecheck.

See #3404 - this was already supposed to be included.
2019-06-25 17:26:30 +02:00
Fabian Homborg
caedf01c00 Revert "Latch signal handlers"
This reverts commit 7ed1022cf4.

Fixes #5962.
2019-06-25 11:25:09 +02:00
ridiculousfish
27e4d1d62d Revert "Revert "Don't service ioport completions if data is available on stdin""
This reverts commit 005e6f2ab8.

This allows new text entry to take priority over highlighting, improving the
performance of pasting.
2019-06-23 16:45:06 -07:00
ridiculousfish
89fb408eb6 Migrate some job flags into const properties struct
This helps clarify which parts of a job are mutable, and which are constant.
2019-06-23 12:42:44 -07:00
ridiculousfish
5362161343 Call tcsetgrp() in child processes again
25afc9b377 made this unnecessary by
having child processes wait for a signal after fork(), but this change
was later reverted. If we artificially slow down fish (e.g. with a sleep)
after the fork call, we see commands getting backgrounded by mistake.

Put back the tcsetgrp() call.
2019-06-23 12:42:44 -07:00
ridiculousfish
8255c01edb Rename setup_child_process to child_setup_process
Try to name all functions called after fork with "child" prefix.
2019-06-23 12:42:44 -07:00
Fabian Homborg
9b54a53758
Prevent not-yet-loaded functions from loaded when erased (#5951)
* Prevent not-yet-loaded functions from loaded when erased

Today, `functions --erase $function` does nothing if the function
hasn't been autoloaded yet.

E.g. run, in an interactive session

    > functions --erase ls
    > type ls

and be amazed that it still shows our default `ls --color=auto`
wrapper function.

This seems counter-intuitive - removing a function ought to remove it,
whether it had been executed before or not.

* doc/changelog
2019-06-22 11:08:36 +02:00
Lily Ballard
fe2ec1e4f8
Merge pull request #5943 from lilyball/string_collect
Add new `string` subcommand `string collect`
2019-06-22 00:30:20 -07:00
Fabian Homborg
370f5356a1 Move "character has no narrow representation" to flog
This was a warning, which is kind of ridiculous, as it's inactionable
error spew.

Fixes #2815.
2019-06-19 12:36:38 +02:00
Lily Ballard
181e44d331 Invert the flag for string collect
Instead of requiring a flag to enable newline trimming, invert it so the
flag (now `--no-trim-newlines`) disables newline trimming. This way our
default behavior matches that of sh's `"$(cmd)"`.

Also change newline trimming to trim all newlines instead of just one,
again to match sh's behavior.
2019-06-16 16:40:14 -07:00
Lily Ballard
b41e5cbbb7 Add string collect
The `string collect` subcommand behaves quite similarly in practice to
`string split0 -m 0` in that it doesn't split its output, but it also
takes an optional `--trim-newline` flag to trim a single trailing
newline off of the output.

See issue #159.
2019-06-16 15:51:57 -07:00
ridiculousfish
5b5887ea99 Correct capitalization of complete_and_search 2019-06-16 14:38:27 -07:00
ridiculousfish
360116221a Switch history_t to use owning_lock internally
This removes a lot of tricky manual locking. It also removes the "main
thread" dependency.
2019-06-14 20:49:17 -07:00
yogendra
6bed255a52 Fix Issue 5910 2019-06-14 08:56:42 -07:00
ridiculousfish
1c66d56d3a Add debug categories for reaping processes 2019-06-13 14:29:13 -07:00
Fabian Homborg
e363552ef0 screen: Include termios for NetBSD
Otherwise it won't build.
2019-06-11 11:34:14 +02:00
Mahmoud Al-Qudsi
cfe1f1db9e Fix build on FreeBSD 12.0 with stock Clang
`isspace()` is in `ctype.h`.
2019-06-10 16:51:42 -05:00
ridiculousfish
aa950e5c13 Provide an optimized override of get_pwd_slash() 2019-06-10 10:26:33 -07:00
Fabian Homborg
38a7c77e4b Re-double-super-fix tilde completion crash
Yeah, I was too clever with the operators here.

Fixes #5929.
2019-06-10 18:50:40 +02:00
Fabian Homborg
d1ca392393 math: Allow "x" for multiplication
It's always a bit annoying that `*` requires quoting.

So we allow "x" as an alternative, only it needs to be followed by
whitespace to distinguish it from "0x" hexadecimal notation.
2019-06-10 18:45:10 +02:00
ridiculousfish
42138f00c6 Remove wchdir()
It's unused, and will soon be dangerous as the process-wide cwd will
lose meaning.
2019-06-10 09:37:08 -07:00
ridiculousfish
6637ccd3a2 Keep an fd for the cwd in the parser
To support distinct parsers having different working directories, we need
to keep the working directory alive, and also retain a non-path reference
to it.
2019-06-10 09:27:51 -07:00
ridiculousfish
6ce85aebc6 Switch file_io_t to store a wcstring
We no longer use file_io_t after fork(). We don't need to use a malloc'd
string any more. Use a wcstring.
2019-06-09 17:43:25 -07:00
ridiculousfish
1baa479bbf Eliminate the global list of scoped transient commandlines
Store this in a parser's libdata instead.
2019-06-09 14:11:25 -07:00
ridiculousfish
421cf92380 Use a generation count for uvars exports
Because an exported universal variable must be exported in all variable
stacks, explicit invalidation is infeasible. Switch the universal variables
to a generation count.
2019-06-09 13:48:07 -07:00
ridiculousfish
7dffaf1a02 Reimplement exported variable change detection
Prior to this fix, fish would invalidate the exported variable list
whenever an exported variable changes. However we soon will not have a
single "exported variable list." If a global variable changes, it is
infeasible to find all exported variable lists and invalidate them.

Switch to a new model where we store a list of generation counts. Every
time an exported variable changes, the node gets a new generation. If the
current generation list does not match the cached one, then we know that
our exported variable list is stale.
2019-06-09 13:25:30 -07:00
ridiculousfish
79ee59adc0 Convert the create_export_array message to flog 2019-06-09 13:22:18 -07:00
Per Bothner
e05a0716e5 Make sure initial indentation is done using cursor move, not spaces.
The goal to allow a terminal to reliably distinguish user input
from indentation and prompts, in the context of shell integration.
2019-06-09 11:36:47 -07:00
Per Bothner
7448e7825f Avoid code duplication relating to screen clearning in s_update. 2019-06-09 11:32:26 -07:00
Mahmoud Al-Qudsi
c9a77bb474 Optimize history search reset checking
`history_search.active()` is an atomic read, whereas
`command_ends_history_search(..)` is a little bit heavier.
2019-06-08 21:07:32 -05:00
ridiculousfish
be97499106 Revert "Revert "Add a test for autoload_t""
This reverts commit 2507162f80.

Put back the autoload test.
2019-06-07 12:12:43 -07:00
Per Bothner
18cf2b8509 Rename incorrect is_single_byte_escape_seq to is_three_byte_escape_seq. 2019-06-07 08:31:52 +02:00
Per Bothner
060a068a3c Fix comment for is_single_byte_escape_seq. 2019-06-07 08:31:52 +02:00
Fabian Homborg
ae59fdeda5 src/builtin_read: Remove more references to fish_history 2019-06-06 15:07:46 +02:00
Fabian Homborg
51fcb79d96 Remove read history
This was undocumented, not all that useful and potentially unwanted.

In particular it means that things like

   mysql -p(read)

will still keep the password in history.

Also it allows us to simply implement asking for the history deletion
term.

See #5791.
2019-06-06 15:07:46 +02:00
ridiculousfish
fc99d6c7af clang-format all files 2019-06-03 20:30:48 -07:00
ridiculousfish
d1fc8d5f71 Improve the iothread port structure
Mark both fds in the ioport as non-blocking, and allow bulk reads.
2019-06-03 16:42:51 -07:00
ridiculousfish
b478f877ee Clean up g_fork_count
Make it static and atomic
2019-06-03 12:58:59 -07:00
ridiculousfish
bc103c2ea6 Make the list of event handlers thread safe 2019-06-03 12:33:10 -07:00
ridiculousfish
ead16958b2 Make set_signal_observed thread-safe 2019-06-03 12:32:48 -07:00
ridiculousfish
ad301ab3a0 Remove an incorrect shadowing use of principal_parser 2019-06-03 02:55:36 -07:00
ridiculousfish
ff55249447 Make events per-parser
This makes the following changes:

1. Events in background threads are executed in those threads, instead of
being silently dropped

2. Blocked events are now per-parser instead of global

3. Events are posted in builtin_set instead of within the environment stack

The last one means that we no longer support event handlers for implicit
sets like (example) argv. Instead only the `set` builtin (and also `cd`)
post variable-change events.

Events from universal variable changes are still not fully rationalized.
2019-06-03 02:48:35 -07:00
ridiculousfish
890c1188ab Instantize and rationalize locking around the input mapping set
Hypothetically a background thread could invoke builtin_bind, etc.
Protect the set of input bindings with a lock.
2019-06-02 22:54:01 -07:00
ridiculousfish
2ef4d982df Clean up some dependencies in input.h 2019-06-02 17:49:52 -07:00
ridiculousfish
ad35fb7457 Make the bind mode per-parser
Eliminates a use of principal_parser
2019-06-02 16:57:52 -07:00
ridiculousfish
671df14178 Thread a parser into inputter_t 2019-06-02 16:41:13 -07:00
ridiculousfish
a48dbf23b8 Instantize the character event queue
Wrap this stuff up in structs so it's no longer global.
2019-06-02 16:37:05 -07:00
Fabian Homborg
6c1d29e14d fixup! Fix build
I deleted the lines that defined "narrow_path" and
"explicit_vars_path", but didn't see the two remaining uses.

Sorry!
2019-06-01 10:32:30 +02:00
Fabian Homborg
7525befadb path_get_path: Narrow string before
This cuts down on the wcs2string here by ~25%.

The better solution would be to cache narrow versions of $PATH, since
we compute that over and over and over and over again, while it rarely changes.

Or we could add a full path-cache (where which command is), but that's
much harder to invalidate.

See #5905.
2019-06-01 09:57:18 +02:00
Fabian Homborg
5ca14904d0 Store narrow version of uvar path
This sets the explicit path to the default one, which should be okay,
since the default path never changes (not even if $XDG_CONFIG_HOME
does).

Then it saves a narrow version of that, which saves most of the time
needed to `sync` in most cases.

Fixes #5905.
2019-06-01 09:56:57 +02:00
Fabian Homborg
bc19647be2 wutil: Give narrow versions of a few functions
Note that this isn't technically *w*util, but the differences between
the functions are basically just whether they do the wcs2string
themselves or not.
2019-06-01 09:34:47 +02:00
ridiculousfish
4e03d3c264 Correct a race in topic monitor
This fixes a race condition in the topic monitor. A thread may decide to
enter the wait queue, but before it does the generation list changes, and
so our thread will wait forever, resulting in a hang.

It also simplifies the implementation of the topic monitor considerably;
on reflection the whole "metagen" thing isn't providing any value and we
should just compare generations directly.

In the new design, we have a lock-protected list of current generations,
along with a boolean as to whether someone is reading from the pipe. The
reader (only one at a time) is responsible for broadcasting notifications
via a condition variable.
2019-05-31 09:31:42 -07:00
ridiculousfish
d920a618de Add FLOG logging to the topic monitor 2019-05-31 09:31:42 -07:00
ridiculousfish
b20bdcebfa FLOG narrow-string output to use fwprintf
This avoids mixing narrow and wide I/O on the same stream.
Extends the fix in #5900 by allowing narrow string literals again.
2019-05-31 09:31:42 -07:00
Fabian Homborg
4ebb6cf39e complete: Add "--force-files"
This allows a completion to specify that *it* takes files.

Useful for things like `sudo -e`, because sudo usually doesn't take
any files.
2019-05-30 19:13:42 +02:00
Fabian Homborg
87971e1f2e Widen the rest of the FLOGs
Fixes #5900.
2019-05-30 13:08:35 +02:00
Fabian Homborg
d73ee4d54b More using FLOGF when formatting is needed
sed-patched, every time a "%" is used in a call to `FLOG`, we use
`FLOGF` instead.
2019-05-30 11:54:09 +02:00
Fabian Homborg
9d62d8e3fd Use FLOGF when formatting is needed
This passed a format string in a variable which is why it was
presumably overlooked.

[ci skip]
2019-05-30 11:48:56 +02:00
ridiculousfish
ee9e5d4996 Allow disabling debug categories with leading -
This was always supposed to work but the string_prefixes_string call
had the wrong order.
2019-05-29 14:21:50 -07:00
ridiculousfish
0863c237b0 Make thread_id a visible thing
Every thread now has a non-recyclable thread id. This will be an aid in
debugging.
2019-05-29 12:34:11 -07:00
ridiculousfish
f3ee6a99c3 Add some FLOG logging around internal processes 2019-05-29 12:34:11 -07:00
Fabian Homborg
61292b0c6c fish_tests: Fix warnings 2019-05-29 21:11:08 +02:00
Fabian Homborg
6617c4d79e Use C++11 value-initialization instead of { 0 }
Removes a warning in GCC.
2019-05-29 20:50:35 +02:00
Fabian Homborg
1259b32ecc Mark some variables as unused
These triggered warnings.
2019-05-29 20:50:35 +02:00
Fabian Homborg
39099ceb10 Remove R_BEGIN_INPUT_FUNCTIONS
The enum starts at 0 (defined to be!), so we can eliminate this one.

That allows us to remove a reliance on the position of
beginning_of_line, and it would trigger a "type-limits" warning.

Also leave a comment because I actually hit that.
2019-05-29 20:50:35 +02:00
Fabian Homborg
4a6a354675 Placate compiler warnings 2019-05-29 20:50:35 +02:00
Fabian Homborg
364bc3fd63 test: Fix return type
This just returns a success signifier, not an error code.
2019-05-29 20:50:35 +02:00
Fabian Homborg
a5b633d3a5 env: Correct type
We'd be comparing "int" and "mode_t", and "mode_t" might be unsigned.

Found via GCC warning.
2019-05-29 20:50:35 +02:00
Fabian Homborg
e895cef245 tinyexpr: Correct pi type 2019-05-29 20:50:35 +02:00
Fabian Homborg
97507a24a2 Increase default read limit to 100MiB
Someone has hit the 10MiB limit (and of course it's the number of
javascript packages), and we don't handle it fantastically currently.

And even though you can't pass a variable of that size in one go, it's
plausible that someone might do it in multiple passes.

See #5267.
2019-05-29 11:01:45 +02:00
Fabian Homborg
66e238fad0 More wide IO for FLOG
This widens the remaining ones that don't take a char
anywhere.

The rest either use a char _variable_ or __FUNCTION__, which from my
reading is narrow and needs to be widened manually. I've been unable
to test it, though.

See #5900.
2019-05-29 08:07:04 +02:00
Fabian Homborg
32949eefbe src/exec: Use wide IO for FLOG
Another step towards #5900.
2019-05-28 23:08:35 +02:00
Fabian Homborg
7c1a40fe86 flog: Use wide literals with wide chars
This solves the main part of (careful linebreak)
issue #5900.

I'm betting all the errors that do use narrow IO are broken, including
a bunch of asserts.
2019-05-28 22:39:47 +02:00
David Adam
7fe93c7518 src/expand: update comment for fallthrough to GCC standard
As suggested in 75db3b4ff4 (r33153119)
2019-05-28 23:20:20 +08:00
David Adam
b5cf9e52ca wcsfilecmp: be clearer about sorting "-" after letters 2019-05-28 22:05:23 +08:00
David Adam
c848787107 add extra test for wcsfilecmp
Test changes added for #5634 in 6e525cc5d9.
2019-05-28 22:03:03 +08:00
David Adam
ba4f4bfce2 Convert further debug(0) calls to FLOG
Follow on from ea9d1ad82f.
2019-05-28 21:06:42 +08:00
ridiculousfish
29c627d020 Stop calling principal_parser() inside parse_execution.cpp 2019-05-27 19:56:35 -07:00
ridiculousfish
835c6ffa67 clang-format all files 2019-05-27 19:47:13 -07:00
ridiculousfish
0150d505de Allow underscores to be treated as dashes in debug categories 2019-05-27 17:38:09 -07:00
ridiculousfish
ea9d1ad82f Convert debug(0) calls to FLOG 2019-05-27 17:31:17 -07:00
ridiculousfish
6282ac5713 Convert locale variable changes from debug to flog 2019-05-27 17:24:52 -07:00
ridiculousfish
46a9da83e8 Convert terminal ownership logging from debug to flog 2019-05-27 17:24:52 -07:00
ridiculousfish
d9676bb2a8 Convert fork events from debug to flog 2019-05-27 17:24:52 -07:00
ridiculousfish
8774860468 Convert job logging from debug to FLOG 2019-05-27 17:24:52 -07:00
ridiculousfish
63a16befd4 Introduce the fish log, a replacement for debug()
This adds a new mechanism for logging, intended to replace debug().

The entry points are FLOG and FLOGF. FLOG can be used to log a sequence of
arguments, FLOGF is for printf-style formatted strings.

Each call to FLOG and FLOGF requires a category. If logging for a category
is not enabled, there is no effect (and arguments are not evaluated).

Categories may be enabled on the command line via the -d option.
2019-05-27 17:24:52 -07:00
ridiculousfish
b405b979ec Eliminate the CHECK() macro
This thing was pretty useless.
2019-05-27 17:24:19 -07:00
Fabian Homborg
9ae3b345c8 Handle empty strings in compare_completions_by_tilde
Fixes #5895.
2019-05-27 08:17:05 +02:00
ridiculousfish
d5f2d472d0 Thread a parser into reader
Eliminates uses of principal_parser
2019-05-26 18:51:47 -07:00
ridiculousfish
7ed1022cf4 Latch signal handlers
Now that our interactive signal handlers are a strict superset of
non-interactive ones, there is no reason to "reset" signals or take action
when becoming non-interactive. Clean up how signal handlers get installed.
2019-05-26 18:04:03 -07:00
ridiculousfish
ead7f28026 Unify the SIGQUIT handlers and remove set_non_interactive_handlers
Interactive signal handlers are now a strict superset of non-interactive
ones. Remove set_non_interactive_handlers()
2019-05-26 13:18:06 -07:00
ridiculousfish
d729d57d94 Unify the interactive and non-interactive signal handlers
The signal handlers for interactive and non-interactive SIGINT were distinct
and talked to the reader. This wasn't really justified and will complicate
having multiple threads. Unify these into a single signal handler.
2019-05-26 00:32:11 -07:00
ridiculousfish
5a4df9dd3a Use sigint_checker_t in debug_thread_error 2019-05-25 19:19:03 -07:00
ridiculousfish
ea3ad0c099 Introduce sigint_checker_t and use it in wait
Allow a simpler way to check for sigint via sigint_checker_t.
Adopt it in builtin_wait, instead of hooking into the reader.
2019-05-25 19:08:04 -07:00
ridiculousfish
f8ba0ac5bf Remove is_interactive_read
is_interactive_read is a suspicious flag which prevents a call to
parser_t::skip_all_blocks from a ^C signal handler. However we end
up skipping the blocks later when we exit the read loop.

This flag seems unnecessary. Bravely remove it.
2019-05-25 18:46:03 -07:00
ridiculousfish
2924751488 Correct priority of universal and global variable setting
When setting a variable without a specified scope, we should give priority
to an existing local or global above an existing universal variable with
the same name.

In 16fd780484 there was a regression that
made universal variables have priority.

Fixes #5883
2019-05-25 17:35:19 -07:00
Fabian Homborg
e339e0f389 fish_indent: Fix pygments 2019-05-25 11:38:05 +02:00
Fabian Homborg
6c0ae7477e reader: Only abort history search on cancel
Otherwise we'd undo the history search when you press e.g. execute,
which means you'd execute the search term.

Only `cancel` should walk it back, like it previously did hardcoded to
escape.

Fixes #5891.
2019-05-25 08:32:50 +02:00
ridiculousfish
a5a5ccb73d Revert "exec: If a job includes a builtin, it stays in our pgroup"
This reverts commit 711260593c.

This ended up breaking the tests; moreover it may have other problems
like preventing backgrounding.

Reopens #5855
2019-05-24 18:00:31 -07:00
ridiculousfish
43e3d3bcf2 Fix the argparse tests 2019-05-24 16:51:40 -07:00
ridiculousfish
a379e9ffeb Make the expect tests run again
These were inadvertently disabled by a bug which was introduced in
cd7e8f4103 . Fix the bug so the tests run
again.

They don't all pass yet; they regressed during the period they were
disabled.
2019-05-24 16:10:44 -07:00
Fabian Homborg
1fd627ebd3 reader: Don't handle escape specially
Escape is just another ordinary character that you can bind, or not.
2019-05-24 19:02:53 +02:00
Fabian Homborg
dd4e0a3b6d Actually end history search
Fixes #5818.
2019-05-24 19:01:24 +02:00
Fabian Homborg
d0bd238657 Don't hardcode enum numbers
"1" in the context of `escape_string(..., 1)` is referring to
`ESCAPE_ALL`, so we should use that.
2019-05-24 18:19:11 +02:00
Fabian Homborg
711260593c exec: If a job includes a builtin, it stays in our pgroup
Fixes #5855.
2019-05-24 18:04:20 +02:00
Fabian Homborg
f2bb1c8c1f expand: Simplify expand_escape_variable 2019-05-24 17:03:43 +02:00
ridiculousfish
84febe8f2e Make disowned pid reaping thread-safe 2019-05-22 17:10:33 -07:00
ridiculousfish
4d929720ce Clean up and rename io_transmorgrify 2019-05-22 16:36:22 -07:00
ridiculousfish
7915831939 Wrap setenv() and unsetenv() calls in a lock 2019-05-22 16:13:31 -07:00
ridiculousfish
e91d68266c Eliminate reader_current_filename
Store this in the parser libdata instead.
2019-05-22 13:51:27 -07:00
ridiculousfish
686b84396c Migrate the return bool outside of block_t
This is a flag that gets set by the return function. But we only need one,
not per-block. Move it into libdata.
2019-05-22 13:51:27 -07:00
Fabian Homborg
9a541d9ed4 expand: Use wcstring for the abbr prefix
This mainly is conceptually a bit simpler. The comment about making it
cheaper is entirely misplaced since this is quite far away from being
important.

Even expanding 1000 abbrs, it doesn't show up in the profile.
2019-05-22 22:31:45 +02:00
Fabian Homborg
212246ecaa fish_indent: Fix reading from stdin for 0 args
I have no idea why this passes the tests, we *have* tests reading from
stdin!
2019-05-22 22:21:28 +02:00
Fabian Homborg
1faffa515e Don't crash if CDPATH is "./"
Fixes #5887.
2019-05-22 21:48:40 +02:00
ridiculousfish
363652ad76 debug_thread_error to wait for a signal instead of sleep
Allows for control-C out of it
2019-05-21 20:15:59 -07:00
Fabian Homborg
6d20b3984a Revert "src/screen: Stop falling back to wchar_t"
This was, under some circumstances, apparently off by one.

If a suggestion was really long, like

```fish
infocmp | string split , | string trim | string match -re . | while read -d = -l key val; test -z "$val"; and continue; string match -q '*%*' -- $val; and continue; test (string replace -ra '\e([\[\]]|\(B).*[\comJKsu]' '' -- a(tput $key)b) = ab; or echo $key $val; end > xterm
```

(I'm assuming longer than $COLUMNS), it would staircase like with a wrong wcwidth.

This reverts commit 15a5c0ed5f.
2019-05-21 23:35:31 +02:00
ridiculousfish
11209b7553 Switch the block stack to a deque instead of vector of shared pointers
That makes the block stack easier to copy.
2019-05-21 10:25:48 -07:00
ridiculousfish
ad57133c7f Switch parser_t to hold its variables via shared_ptr
Preparation for variable stacks with finite lifetimes.
2019-05-21 10:25:48 -07:00
Aaron Gyes
714b8420a9 %s -> %ls for wchar_t
I noticed my debug output for 24bit color mode was garbled due to
this being wrong. I spent a little time trying to get the compiler
to tell us about these, but -Wformat doesn't do anything for wchar
printf functions, and __attribute__((format(printf, n, m))) will
cause an error with wchar_t's, so I gave up and decided to manually
check out every '%s' in the entire project. I found (only) one
more.

debug(0, "%s", wchars) will report warnings for incorrect
specifiers but debug(0, L"%s", wchars) is unable. Thus there may
be reason to prefer not using L"..." as an argument if all else
is equal and it's not necessary.
2019-05-20 13:48:35 -07:00
Fabian Homborg
c2b7e9b2e6 fish_indent: Allow multiple file arguments
Allows `fish_indent -w **.fish` to restyle all fish files under the
current directory.

(This also has the sideeffect of reducing style.fish time by ~10s, as
we only need to invoke `fish_indent` once, instead of once per-file)
2019-05-20 21:04:51 +02:00
ridiculousfish
8e640cdcc5 fish_indent to stop stripping quotes from keywords 2019-05-19 20:56:28 -07:00
ridiculousfish
159d6d669a Remove all block_t subclasses 2019-05-19 14:44:40 -07:00
ridiculousfish
eff4873eca Stop creating subclasses of block_t
Move all block_t creation methods to static methods, and stop creating
subclasses (all of which are now empty).
2019-05-19 14:40:35 -07:00
ridiculousfish
cf92b7626c Migrate event_block's event into block_t 2019-05-19 13:07:06 -07:00
ridiculousfish
8697fa063b Migrate source_block's source_file into block_t
Continue to work towards flattening this hierarchy.
2019-05-19 13:01:59 -07:00
ridiculousfish
fec0e40b5e Migrate function_block name and args into block_t
The goal is to eliminate this block hierarchy.
2019-05-19 12:56:07 -07:00
ridiculousfish
cd7e8f4103 Migrate loop status from blocks into libdata
Blocks will soon need to be shared across parsers. Migrate the loop status
(like break or continue) from the block into the libdata. It turns out we
only ever need one, we don't need to track this per-block.

Make it an enum class.
2019-05-19 12:50:05 -07:00
Fabian Homborg
3efa2ad93b Replace wcslen with math 2019-05-19 18:23:33 +02:00
Fabian Homborg
1e9d41f2c1 Remove now-useless code for detecting {}
This can't happen anymore.
2019-05-19 18:23:33 +02:00
Fabian Homborg
967c1d51ee Only do brace expansion if they contain a variable or ","
Brace expansion with single words in it is quite useless - `HEAD@{0}`
expanding to `HEAD@0` breaks git.

So we complicate the rule slightly - if there is no variable expansion
or "," inside of braces, they are just treated as literal braces.

Note that this is technically backwards-incompatible, because

    echo foo{0}

will now print `foo{0}` instead of `foo0`. However that's a
technicality because the braces were literally useless in that case.

Our tests needed to be adjusted, but that's because they are meant to
exercise this in weird ways.

I don't believe this will break any code in practice.

Fixes #5869.
2019-05-19 18:23:27 +02:00
Fabian Homborg
15a5c0ed5f src/screen: Stop falling back to wchar_t
wcstring is perfectly capable of doing this.
2019-05-19 17:32:09 +02:00
Dawid Dziurla
0b3bb0e7c1 Underline every valid entered path (#5872)
* src/highlight: Underline every valid entered path

* update CHANGELOG

* fix highlight test
2019-05-19 10:03:56 +02:00
ridiculousfish
c42eb0eb4f Remove the process from function_block_t
Prior to this fix, a function_block stored a process_t, which was only used
when printing backtraces. Switch this to an array of arguments, and make
various other cleanups around null terminated argument arrays.
2019-05-18 21:09:04 -07:00
ridiculousfish
508c3a8005 Make is_event and other globals part of parser_t libdata 2019-05-18 19:03:45 -07:00
ridiculousfish
c44dae2d73 Migrate certain runtime flags to atomics hidden behind functions 2019-05-18 18:50:28 -07:00
ridiculousfish
4fcb9d1fed Hide no_exec behind a function 2019-05-18 18:50:28 -07:00
ridiculousfish
be41407610 Make have_proc_stat an ordinary function
Removes a mutable global variable.
2019-05-18 18:50:28 -07:00
ridiculousfish
5158ee812b Eliminate the job from block_t
This exists only to support the '--on-job-exit caller' feature.
Just store the calling job ID directly in the parser's libdata.
2019-05-18 18:50:28 -07:00
Fabian Homborg
0aead5caf8 Repaint-mode to reexecute the rest if mode-prompt output is empty
We previously checked if fish_mode_prompt existed as a function, but
that's a bad change for those who already set it to an empty function
to have a mode display elsewhere.
2019-05-14 19:26:52 +02:00
ridiculousfish
005e6f2ab8 Revert "Don't service ioport completions if data is available on stdin"
This reverts commit 0453023f7b.

This broke the history tests. Reverting this while I sort it out.
2019-05-14 09:52:49 -07:00
Fabian Homborg
a7b1c2f76a Drop wcwidth ASCII check
Updated widechar_width takes care of it.

Technically, this does ~3 comparisons more per-character (because it
checks variation selectors and such), but that shouldn't really matter.
2019-05-14 09:49:51 +02:00
Fabian Homborg
2d37bc9bd1 Update widechar_width
This includes the change to check ASCII chars first, so we can now
drop our workaround.
2019-05-14 09:49:51 +02:00
Fabian Homborg
752b5362ee Only widen string if necessary
This tried a bunch of times, but only the final one is important.
2019-05-14 09:49:51 +02:00
Fabian Homborg
87b93cd4ca src/history: Only widen bash history lines once
This did str2wcs when checking, then again when adding.
2019-05-14 09:49:51 +02:00
Fabian Homborg
2aaf7fda27 src/history: Stop renarrowing a string in a for-loop
Classic case of doing stuff in a loop that doesn't change. No idea if
the compiler caught it, but I sleep easier now.
2019-05-14 09:49:50 +02:00
ridiculousfish
0453023f7b Don't service ioport completions if data is available on stdin
This defers certain autosuggestions and syntax highlighting until after
large pastes are complete.
2019-05-13 14:16:43 -07:00
ridiculousfish
277db64804 Force termsize back to valid in get_current_winsize()
get_current_winsize() is intended to be lazy. It does the following:

1. Gets the termsize from the kernel
2. Compares it against the current value
3. If changed, sets COLUMNS and LINES variables

Upon setting these variables, we notice that the termsize has changed
and invalidate the termsize. Thus we were doing this work multiple times
on every screen repaint.

Put back an old hack that just marked the termsize as valid at the end
of get_current_winsize().
2019-05-13 14:05:42 -07:00
Fabian Homborg
e22422c073 Don't do fish_setlocale that early
This just sets some special characters that we use in the reader, so
it only needs to be done before the reader is set up.

Which, as it stands, is in env_init().
2019-05-13 16:09:37 +02:00
ridiculousfish
234c97e6d2 Remove some unused variables 2019-05-12 18:23:00 -07:00
ridiculousfish
1719d6f136 Make $status and $pipestatus per-parser
Another step towards allowing multiple parsers to execute in parallel.
2019-05-12 14:00:44 -07:00
ridiculousfish
8031fa3bdb Stop using atomic types for non-primitives
atomic<winsize> requires linking libatomic on some platforms which is
annoying. Remove the one use.

Fixes #5865
2019-05-12 13:07:37 -07:00
ridiculousfish
1e4ebfa470 Make electric variables a real thing
Use an actual struct to describe electric variables and what is special
about each one.
2019-05-11 19:17:33 -07:00
ridiculousfish
16fd780484 Reimplement the whole variable stack
The variable stack is a mess - confused locking, surprising callouts, and
unclear division of labor. Just reimplement the whole thing.
2019-05-11 19:17:16 -07:00
ridiculousfish
cfddd881ef Make PWD a per-processor variable
Handle this variable specially.
2019-05-11 17:13:34 -07:00
ridiculousfish
ee250aba82 Factor some environment setting into set_scoped_internal
Breaks up a monolith function.
2019-05-11 17:13:34 -07:00
ridiculousfish
15a52d0f0d Centralize some of the logic for walking the environment stack
Prepare to introduce a new node for per-process variables.
2019-05-11 17:13:34 -07:00
Fabian Homborg
adcc70d0b3 wcwidth: Return early for simple ASCII
Characters from space to before DEL are width 1, and they
appear *often*.

So it's quite a good idea to return early for them.

Fixes #5866.
2019-05-11 21:40:35 +02:00
Fabian Homborg
4462f6d600 src/screen: Skip a wcswidth
This stops trying to see if the previous line is wider if it is a
prefix of the current one.

Which turns out to be true often enough that it's a net benefit.
2019-05-11 10:43:38 +02:00
Fabian Homborg
ac983f6c4b src/screen: Stop recomputing wcwidth
This passes character width as an argument for a few functions.

In particular, it hardcodes a width of "1" for a space literal.
There's no reason to compute wcwidth for the length of the prompt.
2019-05-11 10:43:38 +02:00
Fabian Homborg
567b6ed2b5 src/screen: Stop doing a bunch of unnecessary work
This measured *all* the characters on the commandline, and saved all
of them in another wcstring_list_t, just to then do... nothing with
that info.

Also, it did wcslen for something that we already have as wcstring,
reserved a vector and did a bunch of work for autosuggestions that
isn't necessary if we have more than one line.

Instead, we do what we need, which is to figure out if we are
multiline and how wide the first line is.

Fixes #5866.
2019-05-10 17:43:46 +02:00
Fabian Homborg
d2b02a8a61 src/screen: Only check for combining marks if necessary
line_shared_prefix explains in its comment that

> If the prefix ends on a combining character, do not include the
  previous character in the prefix.

But that's not what it does.

Instead, what it appears to do is to return idx for *every* combining
mark. This seems wrong to begin with, and it also requires checking
wcwidth for *every* character.

So instead we don't do that. If we find the mismatch, we check if it's
a combining mark, and then go back to the previous character (i.e. the
one before the one that the combining mark is for).

My tests found no issues with this, other than a 20% reduction in
pasting time.
2019-05-10 17:43:46 +02:00
Fabian Homborg
eb41965ac3 reader: Remove superfluous while-loop
It's possible this was useful at some point, but now it just always
inserts the string the first time.
2019-05-10 17:43:46 +02:00
Mahmoud Al-Qudsi
097d6c3c5b Fix order of operations in tilde comparison
The previous form of the statement evaluated to a constant comparison
and couldn't have been what was actually intended.
2019-05-09 01:22:23 -05:00
Per Bothner
4c0a119557 Disable cursor_down optimization, but fix to check c_oflag, but c_iflag.
The old commit #3f820f0 "Disable ONLCR mapping of NL output to CR-NL"
incorrectly used c_iflag instead of c_oflag, and I copied that error
in my patch.  Fixed that. However, there seems to be other problems
trying to use "\x1B[A", which I have not tried to debug, so comment that out.

(However, #3f820f0 seems to mostly work if we fix it to use c_oflag.)
2019-05-08 17:22:44 +02:00
Per Bothner
50db10a422 Alternate fix for cursor_down bound to "\n" and ONLCR set.
See GitHub issue #4505 "Terminal mode confusion"
and commit #3f820f0 "Disable ONLCR mapping of NL output to CR-NL".
2019-05-08 17:22:44 +02:00
Fabian Homborg
e20c08d04e argparse: Fix validation for short-only-flags
This read something like `o=!_validate_int`, and the flag modifier
reading kept the pointer after the `!`, so it created a long flag
called `_validate_int`, which meant it would not only error out form

```fish
argparse 'i=!_validate_int' 'o=!_validate_int' -- $argv
```

with "Long flag '_validate_int' already defined", but also set
$_flag_validate_int.

Fixes #5864.
2019-05-06 17:24:42 +02:00
Fabian Homborg
5bf21f2928 Penalize files ending in ~ in suggestions
Fixes #985.
2019-05-06 17:07:29 +02:00
ridiculousfish
8a8b2513b5 Eliminate the global jobs() function
All job lists are attached to a parser now.
2019-05-05 11:33:08 -07:00
Fabian Homborg
15c50703ce fish_indent: Allow semicolons for and and or
As mentioned in #2900, something like

```fish
test -n "$var"; and set -l foo $var
```

is sufficiently idiomatic that it should be allowable.

Also fixes some additional weirdness with semicolons.
2019-05-05 12:51:49 +02:00
Fabian Homborg
c2970f9618 Reformat all files
This runs build_tools/style.fish, which runs clang-format on C++, fish_indent on fish and (new) black on python.

If anything is wrong with the formatting, we should fix the tools, but automated formatting is worth it.
2019-05-05 12:09:25 +02:00
Fabian Homborg
90d64194c5 functions: Replace crummy forced tab with spaces
Still forced indentation, but at least the kind we recommend via
fish_indent.

Fixes #1472.
2019-05-05 12:07:38 +02:00
Fabian Homborg
3bea947bb5 fish_indent: Ignore consecutive semicolons
This removes semicolons at the end of the line and collapses
consecutive ones, while replacing meaningful semicolons with newlines.

I.e.

```fish
echo;
```

becomes

```fish
echo
```

but

```fish
echo; echo
```

becomes

```fish
echo
echo
```

Fixes #5859.
2019-05-05 12:07:38 +02:00
ridiculousfish
1e171140d5 Make the input_common lookahead main-thread only 2019-05-04 20:58:36 -07:00
ridiculousfish
9018a7d5ee Rename input_initialized to s_input_initialized and make it relaxed atomic 2019-05-04 20:58:35 -07:00
ridiculousfish
e10838d5d6 Make job_control_mode a static variable with accessors 2019-05-04 20:58:35 -07:00
ridiculousfish
9fb98baba6 Thread the parser into process_clean_after_marking 2019-05-04 20:58:35 -07:00
ridiculousfish
32d1b3d7cb Simplify looping in readb 2019-05-04 20:58:35 -07:00
ridiculousfish
edab366d3a Eliminate the "input callback queue"
This was a sort of side channel that was only used to propagate redraws
after universal variable changes. We can eliminate it and handle these
more directly.
2019-05-04 20:58:35 -07:00
ridiculousfish
56fd6f696b Improve thread safety in input.cpp 2019-05-04 20:58:35 -07:00
ridiculousfish
36998eee55 Make more miscellaneous globals thread safe 2019-05-04 20:58:35 -07:00
ridiculousfish
e2c66a8131 Make termsize thread safe 2019-05-04 20:58:35 -07:00
ridiculousfish
0de1611bf1 Migrate builtin_complete recursion_level into parser_t::libdata 2019-05-04 20:58:35 -07:00
ridiculousfish
2ce827343e Universal variables to become a latch variable 2019-05-04 20:58:35 -07:00
ridiculousfish
b0a695e9fa Migrate the global exec_count into the parser 2019-05-04 20:58:35 -07:00
ridiculousfish
fe68287cb0 Make miscellaneous variables thread-safe 2019-05-04 20:58:35 -07:00
ridiculousfish
6e143bf50f Eliminate history_collection_t
This was a pretty useless type.
2019-05-04 20:58:35 -07:00
ridiculousfish
3d63a68dd0 Make builtin_random thread safe 2019-05-04 20:58:35 -07:00
ridiculousfish
f66e010949 Turn a lot of common.h variables into getter functions
Improves thread safety.
2019-05-04 20:58:35 -07:00
ridiculousfish
9dc1fd50c9 Introduce global_safety.h
This is a set of types that enable characterizing the proper way to access
global variables.
2019-05-04 20:53:32 -07:00
ridiculousfish
ec522e5978 Migrate s_main_thread_request_queue to owning_lock 2019-05-04 20:42:56 -07:00
ridiculousfish
1e57424011 Thread a parser into function_exists
Since this may autoload, it needs a parser with which to autoload.
2019-05-04 20:20:52 -07:00
ridiculousfish
bffacd2fbf Thread a parser into expansion
Expansion may perform command substitution, which needs to know the parser
to use.
2019-05-04 19:30:00 -07:00
ridiculousfish
4ce485525e Correct duplicate completion detection
Stop assuming that completions with the same hash are equal.
2019-05-04 18:35:22 -07:00
ridiculousfish
923a7ca0f0 Thread the parser into complete()
Eliminates uses of principal_parser
2019-05-04 18:17:18 -07:00
ridiculousfish
63bdc949ab Make completion request flags an enum_set 2019-05-04 17:55:57 -07:00
ridiculousfish
acd33cbabb Remove an unnecessary fetch of the principal parser 2019-05-04 16:56:38 -07:00
ridiculousfish
fbd4ff027a Initialize a field that was previously uninitialized
Caught by UBSan
2019-05-04 16:47:27 -07:00
ridiculousfish
c0c7b0f86f Make tsan detection gcc compatible 2019-05-04 16:13:55 -07:00
ridiculousfish
ec45f31ad1 Make debug_level an atomic
Fixes a tsan warning
2019-05-04 15:28:44 -07:00
ridiculousfish
0dd9f64bd9 Make topic monitor compatible with tsan
tsan does funny things to signals, preventing signals from being delivered
in a blocking read. Switch the topic monitor to non-blocking reads under
tsan.
2019-05-04 13:06:06 -07:00
Fabian Homborg
e91eb85949 argparse: Fix -- regression
I was a tad overzealous there with not appending the remaining
arguments.

Weird that we didn't test it, though.

Fixes #5857.
2019-05-03 16:20:40 +02:00
ridiculousfish
649d3ac101 Simplify reporting of invalid config paths
Do this at a well defined point, instead of randomly the first time they're
queried.
2019-05-01 17:51:51 -07:00
ridiculousfish
72e43a514b Correct the warning for invalid directories
This was inadvertently broken.
2019-05-01 17:47:50 -07:00
ridiculousfish
55e3270ac4 Remove erase_list from process_clean_after_marking
We don't need to maintain an erase_list in this function any more.
Simply remove jobs that are completed.
2019-05-01 16:32:14 -07:00
ridiculousfish
3dfaa192da Put back process and job exit events
These were removed in f8b2e818ed under a
belief that they were unused. But they are documented and supported.
2019-05-01 16:32:14 -07:00
ridiculousfish
43d668bdc8 Continue to refactor internal loop of process_clean_after_marking
Factor our logic around when to print a message.
2019-05-01 16:32:14 -07:00
ridiculousfish
b5d3fadf44 Factor out the individual process handling in process_clean_after_marking
Helps break up this monolith.
2019-05-01 16:32:14 -07:00
ridiculousfish
b8170ec1ce Clarify return value of job_reap and process_clean_after_marking 2019-05-01 16:32:14 -07:00
ridiculousfish
9700800ecf Factor disowned job removal into its own function
This helps break up process_clean_after_marking.
2019-05-01 16:31:21 -07:00
ridiculousfish
c05e72749a Rename PENDING_REMOVAL to DISOWN_REQUESTED
A commend implied that PENDING_REMOVAL was broader than it was. In practice
only disown() sets this flag. Rename the flag for clarity.
2019-05-01 15:37:53 -07:00
David Adam
665ae3787a Switch to runtime check for /proc/self/stat
Removes a compile-time check that may have affected cross-compilation.

Work on #1067.
2019-04-30 16:23:28 +08:00
Fabian Homborg
43929ced90 src/builtin_argparse: Work around wgetopt crash
If on the last argument, and it was an unrecognized option, we can't
call `wgetopt_long()` again, or it'll crash.
2019-04-29 16:55:55 +02:00
Fabian Homborg
8c9359fdd4 src/builtin_argparse: Add --ignore-unknown flag
This keeps all unknown options in $argv, so

```fish
argparse -i a/alpha -- -a banana -o val -w
```

results in $_flag_a set to banana, and $argv set to `-o val -w`.

This allows users to use multiple argparse passes, or to simply avoid
specifying all options e.g. in completions - `systemctl` has 46 of
them, most not having any effect on the completions.

Fixes #5367.
2019-04-29 15:57:56 +02:00
ridiculousfish
d8ac051f89 Move selection_direction_t to pager.h and make it a class enum 2019-04-28 14:06:03 -07:00
ridiculousfish
2507162f80 Revert "Add a test for autoload_t"
This reverts commit 51c62d6cc6.

Back out the test while I attempt to fix it
2019-04-27 20:14:06 -07:00
ridiculousfish
51c62d6cc6 Add a test for autoload_t 2019-04-27 16:16:48 -07:00
ridiculousfish
4ff50eba41 Remove autoload_t, rename autoloader_t to autoload_t
Now that there are no more clients of autoload_t, delete it and
rename autoloader_t to autoload_t. Also clean up the headers.
2019-04-27 15:47:08 -07:00
ridiculousfish
68a28106b2 Reimplement completion autoloading via autoloader_t
This switches the completion autoloading machinery to autoloader_t.
2019-04-27 15:37:24 -07:00
ridiculousfish
960266fe24 Reimplement the function store and autoloading
This cleans up how functions are stored and autoloaded. It eliminates the
recursive lock. Instead there is a single normal owning_lock that protects
the entirety of the function data. Autoloading is re-implemented via the
new autoloader_t.
2019-04-27 15:30:11 -07:00
ridiculousfish
3950dab9ff Add autoloader_t
autoloader_t will be the reimplementation of autoloading. Crucically it no
longer manages any locking or loading itself; instead all locking and loading
is performed by clients. This makes it easier to test and helps limit its
responsibilities.
2019-04-27 15:26:18 -07:00
ridiculousfish
b7ad6b5bdc Add autoload_file_cache_t
This will provide the "backing store" for autoloading.
2019-04-27 15:09:24 -07:00
ridiculousfish
6ec7c50ace Stop removing functions and completions in autoload
autoloading has a "feature" where functions are removed in an LRU-fashion.
But there's hardly any benefit in removing autoloaded functions. Just stop
doing it.
2019-04-27 14:49:05 -07:00
ridiculousfish
7b44b5ef15 Titlecase LRU template parameters 2019-04-27 12:07:16 -07:00
ridiculousfish
f297543ca1 Make owning_lock's template parameter titlecase instead of uppercase 2019-04-27 12:04:36 -07:00
Fabian Homborg
af0e08e9f1 argparse: Use the current function name by default
This makes the `--name` option usually unnecessary.

See #5835.
2019-04-27 15:55:49 +02:00
ridiculousfish
9bc5d60eaf Clean up enum_set.h header
Include a missing array header, and switch to idiomatic include guards.
2019-04-26 16:08:19 -07:00
Fabian Homborg
009ecfd7e6 src/tokenizer: Add ":@" to the list of non-path-component chars
This makes kill-path-component stop there.

Fixes #5841.
2019-04-26 19:16:21 +02:00
David Gowers
38cadc9d4f Variables as commands are in fact supported, eval docs should not claim otherwise. (#5819)
Provide an example that somewhat justifies eval's existence in light of this change.

Also correct similar misinformation found in a comment.
2019-04-26 15:30:13 +02:00
Fabian Homborg
22ce8c23c6 builtin_complete: Allow complete -C something
This is a long-standing issue with how `complete --do-complete` does
its argument parsing: It takes an optional argument, so it has to be
attached to the token like `complete --do-complete=foo` or (worse)
`complete -Cfoo`.

But since `complete` doesn't take any bare arguments otherwise (it
would error with "too many arguments" if you did `complete -C foo`) we
can just take one free argument as the argument to `--do-complete`.

It's more of a command than an option anyway, since it entirely
changes what the `complete` call _does_.
2019-04-26 15:02:29 +02:00
ridiculousfish
cd86c0ee88 Remove the COMPLETE_SEP define
It was unused.
2019-04-25 14:23:37 -07:00
ridiculousfish
96bc8a14ca Promote completion_mode_t to a real type
Eliminate big #defines like NO_COMMON.
2019-04-25 14:21:06 -07:00
ridiculousfish
d962668aa0 Remove PATH and COMMAND defines
Also clean up a bit of builtin_complete
2019-04-25 13:26:43 -07:00
ridiculousfish
496529b20a Remove EXPAND prefix from expand_flags and lowercase them 2019-04-25 11:34:49 -07:00
ridiculousfish
d8ab6290e8 Switch expand_flags_t to enum_set 2019-04-25 11:23:03 -07:00
ridiculousfish
dcaac58f45 Rename expand_error_t to expand_result_t and make it class enum
Also lowercase it all.
2019-04-25 10:47:28 -07:00
ridiculousfish
b54c44f2f6 Migrate expansion stages to a new type expander_t
This avoids having to pass around so many parameters during expansion.
2019-04-25 10:47:28 -07:00
Aaron Gyes
f309ae05b6 is_visual_escape_seq: whittle down the escape sequences attempted
Some of these we do not need to worry about actually being used
in a prompt.
2019-04-20 17:03:27 -07:00
ridiculousfish
fe75a3a650 Migrate autoload file checks to file_id_t 2019-04-19 18:47:07 -07:00
ridiculousfish
6dd2766a15 Remove file_access_attempt_t::stale
It was unused.
2019-04-19 18:26:29 -07:00
Per Bothner
2edfab685a Some comment fixes and renaming of is_iterm2_escape_seq. (#5827)
* Some comment fixes and renaming of is_iterm2_escape_seq.

The comment for is_iterm2_escape_seq incorrectly says "CSI followed by ]".
This is wrong, because CSI is ESC followed by [ (or the seldom-used 0x9b).
The procedure  actually matches Operating System Command (OSC) escape codes.
Since there is nothing iterm2-specific about OSC, is_osc_escape_seq
would be a better name.

Also s_desired_append_char documents a non-existent parameter.

* Update broken iterm2 url in comment.
2019-04-19 09:29:35 -07:00
Mahmoud Al-Qudsi
8ca2641857 Revert overzealous !parent_job is_visible() condition
This was added in 04a96f6 but not strictly required to fix #5803
(verified), with the intention of hiding invisible background jobs
(created by invoking a function within a pipeline) from the user, but
that also broke intentionally created jobs from displaying as well.

I'm thinking it can't be done without keeping track of caller context vs
job context.

Closes #5824.
2019-04-17 22:47:41 -05:00
ridiculousfish
a173c079d5 expand_abbreviation to always accept an environment_t
Now that snapshotting is fixed, we don't need to get the principal
environment stack any more.
2019-04-16 22:45:58 -07:00
ridiculousfish
2e119813e1 get_abbreviations to accept an environment_t
Now that we don't have dorky snapshotting, thread an dnvironment_t through
get_abbreviations. Removes a usage of env_stack_t::principal().
2019-04-16 22:27:01 -07:00
Aaron Gyes
7e514d2aa5 expand_abbreviation(): escape when looking up abbreviation vars
This was doing exactly the opposite: unescaping and not hitting
the encoded _fish_abbr_X variables when looking up.

Fixes #5573
2019-04-16 21:33:09 -07:00
ridiculousfish
6b52b0994c Attempt to fix the travis build 2019-04-14 17:43:02 -07:00
ridiculousfish
2fac0f0b39 Correctly lock around umask
umask can only be set, never just queried. Thus we need to lock around
calls to it.

Also guess the value; if we guess right we don't need to reset it.
2019-04-14 16:08:29 -07:00
ridiculousfish
020d4a2848 Adopt env_scoped_t::snapshot() and remove env_var_snapshot_t
Remove the env_var_snapshot_t class and switch everything to the new snapshot
function of env_scoped_t.

Fixes #5658. Fixes #5571.
2019-04-14 15:50:38 -07:00
ridiculousfish
64584a6624 Add a snapshot function to env_scoped_t
Allow creating lightweight read-only copies of a scoped environment.
2019-04-14 15:50:30 -07:00
ridiculousfish
0ca3ae7c7e Rejigger var_stack_t's ctors
Prepare var_stack_t to support snapshotting.
2019-04-14 15:50:24 -07:00
ridiculousfish
69655ef5c1 Reorganize env.cpp
Group functions together more logically
2019-04-14 15:50:19 -07:00
ridiculousfish
1d464da698 Introduce env_scoped_t
env_scoped_t lives between environment_t and env_stack_t.
It represents the read-only logic of env_stack_t and will be used to back
the new environment snapshot implementation.
2019-04-14 15:50:12 -07:00
ridiculousfish
46fd47a0da Organize some code slightly better in env.h 2019-04-14 15:50:06 -07:00
Mahmoud Al-Qudsi
05f52924c1 Fix bad tests
These tests used raw, unescaped parentheses to perform `test` logical
grouping, but the test failures weren't caught because the parser
evaluation errors were not being propagated (fixed in bdbd173e).
2019-04-13 17:28:16 -05:00
Mahmoud Al-Qudsi
b2a1da602f Fix error propagation in parser_t::eval
It was unconditionally returning `parse_execution_success`. This was
causing certain parser errors to incorrectly return after evaluation
with `$status` equal to `0`, as reported after `eval`, `source`, or
sub-`fish` execution.
2019-04-13 17:28:16 -05:00
Mahmoud Al-Qudsi
8e4010b263 Make eval override previous status
Closes #5692 (again).
2019-04-13 17:28:10 -05:00
Mahmoud Al-Qudsi
4530a41004 Fix return code after execution of empty function 2019-04-13 17:21:13 -05:00
ridiculousfish
cc9386fca9 Clean up some headers in env and env_dispatch.cpp 2019-04-13 14:39:20 -07:00
ridiculousfish
2537fe0f9e Put back a missing lock in env_stack_t::set_internal
Setting a variable could race with getting it.

The lockin^g here needs a serious overhaul.
2019-04-13 12:40:58 -07:00
ridiculousfish
2f1e572756 Minor cleanup of env_node_t
Mark some fields const that don't need to change. Trying to get ready to
improve locking here.
2019-04-13 12:40:58 -07:00
ridiculousfish
372291ad02 Collapse a weirdly structured clause in env.cpp 2019-04-13 12:40:57 -07:00
ridiculousfish
a597b0e6e1 Remove get_proc_had_barrier
Prior to this change, fish used a global flag to decide if we should check
for changes to universal variables. This flag was then checked at arbitrary
locations, potentially triggering variable updates and event handlers for
those updates; this was very hard to reason about.

Switch to triggering a universal variable update at a fixed location,
after running an external command.  The common case is that the variable
file has not changed, which we can identify with just a stat() call, so
this is pretty cheap.
2019-04-13 12:40:57 -07:00
ridiculousfish
341799194e Factor out fetching electric variables into a separate function
This factors env_stack_t::get() a little better
2019-04-13 12:40:57 -07:00
ridiculousfish
2c7dc98337 Revert "fcntl a little less"
This reverts commits:
e5362a4ae5.
dd9a26715d.

These commits were incorrect because they stomped other flags, such as
O_NONBLOCK.
2019-04-13 12:27:05 -07:00
ridiculousfish
13c5f93d63 Revert "Optimize function calls by reducing inherit vars heap allocations and copies"
This reverts commit cdce8511a1.

This change was unsafe. The prior version (now restored) took the lock and
then copied the data. By returning a reference, the caller holds a
reference to data outside of the lock.

This function isn't worth optimizing. Hardly any functions use this
facility, and for those that do, they typically just capture one or two
variables.
2019-04-13 12:03:02 -07:00
Mahmoud Al-Qudsi
cdce8511a1 Optimize function calls by reducing inherit vars heap allocations and copies
* Convert `function_get_inherit_vars()` to return a reference to the
  (possibly) existing map, rather than a copy;
* Preallocate and reuse a static (read-only) map for the (very) common
  case of no inherited vars;
* Pass references to the inherit vars map around thereafter, never
  triggering the map copy (or even move) constructor.

NB: If it turns out the reference is unsafe, we can switch the inherit vars
to be a shared_ptr and return that instead.
2019-04-13 11:26:10 -05:00
David Adam
56125f73e4 env: trigger locale updates if LOCPATH changes
Closes #5815.
2019-04-13 21:58:54 +08:00
ridiculousfish
47b9907113 Remove an unused variable 2019-04-12 23:03:28 -07:00
ridiculousfish
4e1fdaf5a7 Use move semantics in builtin_eval
Saves some allocations
2019-04-12 23:02:45 -07:00
ridiculousfish
c95e1b83c7 Minor cleanup of eval builtin
Fix some copy and paste errors, remove some dead variables and code,
make the return a bit more structured.
2019-04-12 22:42:27 -07:00
Fabian Homborg
a8030c020b src/fish_indent.cpp: Fix return-value warning 2019-04-12 15:38:38 +02:00
Mahmoud Al-Qudsi
e0e0fe9dd3 Re-implement eval as a regular builtin
I did not realize builtins could safely call into the parser and inject
jobs during execution. This is much cleaner than hacking around the
required shape of a plain_statement.
2019-04-12 07:04:15 -05:00
Aaron Gyes
1834e962d2 Correct carat position for unexpected } in brace expansion
before:

$ echo {}}-
fish: Unexpected '}' for unopened brace expansion

$ ./fish -c 'echo {}}}}'
fish: Unexpected '}' for unopened brace expansion
echo {}}}}
^

now:
$ echo {}}}}}}1-
fish: Unexpected '}' for unopened brace expansion
echo {}}}}}}
       ^
2019-04-11 17:18:53 -07:00
Aaron Gyes
75db3b4ff4 fix incorrectly aligned carat in command expansion errors and more
- fix the carat position expanding e.g. `command $,`
- improve the error reporting for not-allowed command subtitutions
  by figuring out where the expansion failed instead of using
  SOURCE_LOCATION_UNKNOWN
- allow nullptr for parse_util_licate_brackets_range() out_string
  argument if we don't need it to do any work.

Fixes #5812
2019-04-11 14:44:46 -07:00
Mahmoud Al-Qudsi
4539a9db15 Drop unused include in src/exec.cpp
It was added in 2544c622841fd8b7317109f12fe4eb55c5ea1d0a,
and caught by @faho.
2019-04-11 13:01:29 -05:00
Mahmoud Al-Qudsi
4d54147e7e Merge branch 'eval_parser'
Implements `eval` in cpp rather than as a fish function.
2019-04-11 10:41:33 -05:00
Mahmoud Al-Qudsi
2fe2169065 Make eval a decorator
`eval` has always been implemented as a function, which was always a bit
of a hack that caused some issues such as triggering the creation of a
new scope. This turns `eval` into a decorator.

The scoping issues with eval prevented it from being usable to actually
implement other shell components in fish script, such as the problems
described in #4442, which should now no longer be the case.

Closes #4443.
2019-04-11 10:36:49 -05:00
ridiculousfish
f7817a2586 Remove env_node_t::contains_any_of
Dead code...
2019-04-10 23:18:30 -07:00
Mahmoud Al-Qudsi
0bda853dc7 Add detection of eval to the parser
While `eval` is still a function, this paves the way for changing that
in the future, and lets the proc/exec functions detect when an eval is
used to allow/disallow certain behaviors and optimizations.
2019-04-10 21:19:57 -05:00
ridiculousfish
b6555a0dc4 Add print-rusage-self to fish
This adds an option --print-rusage-self to the fish executable. When set,
this option prints some getrusage stats to the console in a human-readable
way. This will be used by upcoming benchmarking support.
2019-04-10 14:33:45 -07:00
Mahmoud Al-Qudsi
04a96f6c6e Change when PENDING_REMOVAL jobs are removed
Followup to 394623b.

Doing it in the parser meant only top-level jobs would be reaped after
being `disown`ed, as subjobs aren't directly handled by the parser.

This is also much cleaner, as now job removal is centralized in
`process_clean_after_marking()`.

Closes #5803.
2019-04-10 11:00:48 -05:00
Mahmoud Al-Qudsi
394623bf08 Prevent disown from directly removing jobs
This prevents the `disown` builtin from directly removing jobs out of
the jobs list to prevent sanity issues, as `disown` may be called within
the context of a subjob (e.g. in a function or block) in which case the
parent job might not yet be done with the reference to the child job.

Instead, a flag is set and the parser removes the job from the list only
after the entire execution chain has completed.

Closes #5720.
2019-04-09 23:29:58 -05:00
Mahmoud Al-Qudsi
f1b261388a Fix build error on old (buggy?) versions of libstdc++
Closes #5801.
2019-04-09 22:43:32 -05:00
Mahmoud Al-Qudsi
ab1519acef Fix high CPU usage in subsequent select(2) calls
The timeout was being reset to zero, so `select` was being called in a
very tight loop.

Closes #5761.
2019-04-09 21:10:30 -05:00
David Adam
c6c0c9bfdf use standard warning for invalid variable in for loop
Work on #5800.
2019-04-09 20:10:57 +08:00
ridiculousfish
e44cb235a7 Add pygments CSV output to fish_indent
This will allow pygments to highlight fish code using fish_indent.
2019-04-08 19:09:41 -07:00
ridiculousfish
3e14f96d40 Eliminate string_set_contains 2019-04-08 16:22:04 -07:00
ridiculousfish
1caf20f7c3 Migrate the read limit into env_dispatch 2019-04-08 16:22:04 -07:00
ridiculousfish
fa0a6ae096 Move locale and curses init from env to env_dispatch 2019-04-08 16:22:04 -07:00
ridiculousfish
11651dec7a Clean up env_stack_t::pop
Use the new dispatch mechanism to reduce duplication
2019-04-08 16:22:04 -07:00
ridiculousfish
a4fe3c87ae Switch certain environment callbacks from named to anonymous 2019-04-08 16:22:04 -07:00
ridiculousfish
987e41de12 Remove the op from env_dispatch
Environment dispatch passes strings like "ERASE" and "SET" but nobody
ever looks at those. Just get rid of them.
2019-04-08 16:22:04 -07:00
ridiculousfish
dc729653be Migrate pop complexity from vars_stack_t to env_stack_t
When popping a scope from the environment stack, we currently do a lot of
nonsense like looking for changed curses variables. We want to centralize
this in env_stack_t so that it can be migrated to the env_dispatch logic.
Move this logic up one level in preparation for doing that.
2019-04-08 16:22:04 -07:00
ridiculousfish
59fb5b1849 var_stack_t::pop() to return the popped node 2019-04-08 16:22:04 -07:00
ridiculousfish
0c5809a088 Minor cleanup of env_node_t 2019-04-08 16:22:04 -07:00
ridiculousfish
ab67354192 Migrate fish_use_posix_spawn into env_dispatch 2019-04-08 16:22:04 -07:00
ridiculousfish
e7de9cc371 Migrate some env initialization into env_dispatch 2019-04-08 16:22:04 -07:00
ridiculousfish
b67174b4a3 Clean up env_dispatch_table 2019-04-08 16:22:04 -07:00
ridiculousfish
b7fceddfc8 Refactor some environment code into env_dispatch.cpp
This new file is supposed to encapsulate all of the logic around
reacting to variable changes, as opposed to the environment core.
This is to help break up the env.cpp monolith.
2019-04-08 16:22:04 -07:00
Aaron Gyes
e5362a4ae5 wutil.cpp: fixup: don't involve the uninitialized parameter 2019-04-08 16:02:00 -07:00
Aaron Gyes
8eb05f8731 parse_execution.cpp: validate 'for' variable name
Fixes #5800
(that's a nice round number)
2019-04-08 11:23:00 -07:00
Aaron Gyes
dd9a26715d fcntl a little less
Setting O_CLOEXEC on closed file descriptors and getting E_BADF
should be faster than actually checking if an fd is open first.
2019-04-08 11:23:00 -07:00
ridiculousfish
bf40f84b06 Remove an unused variable 2019-04-07 15:07:36 -07:00
ridiculousfish
f5bb8639d6 More aggressively inherit pgrps from parent jobs
Prior to this fix, a job would only inherit a pgrp from its parent if the
first command were external. There seems to be no reason for this
restriction and this causes tcsetgrp() churn, potentially cuasing SIGTTIN.
Switch to unconditionally inheriting a pgrp from parents.

This should fix most of #5765, the only remaining question is
tcsetpgrp from builtins.
2019-04-07 13:35:00 -07:00
ridiculousfish
39a9740997 Be less aggressive about reclaiming the foreground pgrp
Prior to this fix, in every call to job_continue, fish would reclaim the
foreground pgrp. This would cause other jobs in the pipeline (which may
have another pgrp) to receive SIGTTIN / SIGTTOU.

Only reclaim the foreground pgrp if it was held at the point of job_continue.

This partially addresses #5765
2019-04-07 09:20:32 -07:00
ridiculousfish
23d88e0e03 Add fish_test_helper executable
In tests we would like to arrange for an executable to invoke certain
system calls, e.g. to claim or relinquish control of the terminal. This is
annoying to do portably via e.g. perl. fish_test_helper is a little
program where we can add custom commands to make it act in certain ways.
2019-04-07 09:20:19 -07:00
Aaron Gyes
4e555aebec Remove is_whitespace and whitespace character string declarations
I don't doubt such functions and character arrays could be useful,
to keep things consistent, but they are not actually being used.
2019-04-06 02:07:56 -07:00
Fabian Homborg
2a3677b386 Stop setting term-modes early
This set the term modes to the shell-modes, including disabling
ICRNL (translating \cm to \cj) and echo.

The rationale given was that `reader_interactive_init()` would only be
called >= 250ms later, which I _highly_ doubt considering fish's total
startup time is 8ms for me.

The main idea was that this would stop programs like tmuxinator that
send shortcuts early from failing _iff_ the shortcut was \cj, which
also seems quite unusual.

This works both with `rm -i` and `read` in config.fish, because `read`
explicitly calls `reader_push`, which then initializes the shell modes.

The real fix would involve reordering our init so we set up the
modesetting first, but that's quite involved and the remaining issue
should barely happen, while it's fairly common to have issues with a
prompt in config.fish, and the workaround for the former is simpler, so let's leave it for now.

Partially reverts #2578.

Fixes #2980.
2019-04-05 12:55:13 +02:00
Aaron Gyes
be80a56ad4 expand.cpp: use wcspbrk for is_quotable 2019-04-04 17:32:39 -07:00
Aaron Gyes
b4ddd797e3 remove unused wcstring 2019-04-04 14:24:36 -07:00
Aaron Gyes
b064eaa571 use std::move in a couple spots where things were unsed after copy 2019-04-04 14:16:34 -07:00
Aaron Gyes
09e8f0fd7c rearrange structure fields
Putting larger members before smaller ones will reduce structure
sizes. bools are 1 byte. on 64bit systems I think they reduced:

wgetopt.h:46: 64 to 56 bytes
builtin_history.cpp:30: 48 to 32 bytes
builtin_status.cpp:91: 32 to 24 bytes
tinyexpr.cpp:69: 40 to 32 bytes
2019-04-04 13:47:10 -07:00
Mahmoud Al-Qudsi
bc66921ac9 Optimize keyword detection
The data stored in these containers is small enough that it is worth
creating distinct sets for each lookup.

In a microbenchmark of these changes, the single-lookup version of the
function with lookups gated on the length of input (bypassed entirely if
the input is longer than the longest key in the container) provided a
1.5x-3.5x speedup over the previous implementation.

Additionally, as the collections are static and their contents are never
modified after startup, it makes no sense to continously calculate the
location of and allocate an iterator for the `!= foo.end()` comparison;
the end iterator is now statically cached.

I'm not expecting massive speed gains out of this change, but the parser
does perform enough of these to make it worth optimizing in this way.
2019-04-03 20:53:29 -05:00
ridiculousfish
dd007c29f4 Revert "parser: try to avoid some strings being copied"
This reverts commit 7a74198aa3.

Believe it or not this commit actually increased copying. When accepting
a value you know you're going to take ownership of, just accept it by
value; then temporaries can invoke the move ctor and blah blah blah.

We really need a lightweight refcounted pass-by-value string to make this
less error prone.
2019-04-01 20:22:02 -07:00
Fabian Homborg
99dd6d7394 Let repaint-mode act like a repaint if no fish_mode_prompt exists
Otherwise I'm pretty sure we'd get complaints from people who use a
mode-indicator elsewhere in their prompts.
2019-04-01 16:04:14 +02:00
Fabian Homborg
8ff866b26b Add repaint-mode bind function
If we switch the bind mode, we add a "force-repaint" there just to
redraw the mode indicator.

That's quite wasteful and annoying, considering that sometimes the prompt can take
half a second.

So we add a "repaint-mode" function that just reexecutes the
mode-prompt and uses the cached values for the others.

Fixes #5783.
2019-04-01 15:59:39 +02:00
Fabian Homborg
da1b32f0ad
Remove option to use system wcwidth (#5777)
As it turns out it didn't work much better, and it fell behind in
support when it comes to things that wcwidth traditionally can't
express like variation selectors and hangul combining characters, but
also simply $fish_*_width.

I've had to tell a few people now to rebuild with widecharwidth after
sending them on a fool's errand to set X variable.

So keeping this option is doing our users a disservice.
2019-04-01 15:59:33 +02:00
Fabian Homborg
0d72912641
Expand abbr explicitly (#5762)
* Add "expand-abbr" bind function

This can be used to explictly allow expanding abbreviations.

* Make expanding abbr explicit

NOTE: This accepts them for space only, we currently also do it for \n
and \r.

* Remove now dead code

We no longer trigger an abbr implicitly, so we can remove the code
that does it.

* Fix comment

[ci skip]
2019-04-01 15:59:15 +02:00
Mahmoud Al-Qudsi
eb2d829bc5 Use explicit lock.exchange()
There's really no point in using std::atomic if we're not going to
actually guarantee the entire read & write process is atomic.
2019-03-31 18:17:33 -05:00
Mahmoud Al-Qudsi
b5b9406711 Use explicit atomic/CAS to prevent race conditions
They are probably equivalent on x86/64 being single-byte reads/writes,
but it never hurts to be safe.
2019-03-31 18:09:59 -05:00
Mahmoud Al-Qudsi
3c537bfa65 Optimize get_deferred_process() traversal 2019-03-31 13:20:49 -05:00
ridiculousfish
0aa0dceeb3 End coalescing repaints on check-exits
Hopeful fix for #5766
2019-03-29 20:56:23 -07:00
ridiculousfish
0b11b8cffb Revert "Optimize identification of deferred process"
This reverts commit 4aea4c09b3.

Said commit broke many tests
2019-03-28 20:22:58 -07:00
Mahmoud Al-Qudsi
4aea4c09b3 Optimize identification of deferred process 2019-03-28 22:12:50 -05:00
Mahmoud Al-Qudsi
f8b2e818ed Remove legacy generic process/job exit events 2019-03-28 18:55:36 -05:00
Mahmoud Al-Qudsi
7f5e58ae69 Only send JOB_EXIT after the job has been actually erased 2019-03-28 18:55:36 -05:00
Mahmoud Al-Qudsi
06adb1dc38 Store jobs to erase in separate list 2019-03-28 18:55:36 -05:00
Mahmoud Al-Qudsi
36f3a6d7e0 Use const auto for all jobs 2019-03-28 18:55:36 -05:00
Mahmoud Al-Qudsi
d4d5c03a03 Clean up invalid job id detection in fg builtin 2019-03-28 18:55:36 -05:00
Mahmoud Al-Qudsi
1f59976c2c Further clean up job list manipulation 2019-03-28 18:55:36 -05:00