Commit graph

10186 commits

Author SHA1 Message Date
David Adam
d0735882a3 add tests for the not-quite-fixed #5812 2019-04-18 21:12:25 +08: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
Mahmoud Al-Qudsi
d66ec08819 Add partial aws and ~full aws s3 completions
[ci skip]
2019-04-17 22:37:19 -05:00
David Adam
4d8a82b68f benchmarks: use true executable in path
true is /bin/true on some Linux and /usr/bin/true on macOS.

[ci skip]
2019-04-17 18:31:19 +08: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
Aaron Gyes
65bc94c493 Revert "set completions: complete __ variables"
This reverts commit f4e40f2f4b.
2019-04-15 12:57:59 -07:00
Aaron Gyes
92f4a009b3 __fish_config_interactive: disable file completions for builtins
Calling `complete` once here is preferable to adding a bunch of
1 line files to be autoloaded.
2019-04-15 12:49:24 -07:00
Aaron Gyes
89b6b05f88 Fix builtin completions
Command substitution needs parenthesis
2019-04-15 12:24:54 -07:00
Aaron Gyes
f4e40f2f4b set completions: complete __ variables
Now that __ stuff is sorted after a-z, we should not completely
omit them from completions.
2019-04-14 20:35:02 -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
a9e0990773 Add changelog note about parser error propagation fix
..as this affects backwards compatibility (as witnessed by the tests
that failed after making this fix).
2019-04-13 17:28:16 -05:00
Mahmoud Al-Qudsi
2dfc85245f Add regression tests for eval 2019-04-13 17:28:16 -05: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
47a61a3202 Test: validate $status is preserved on calling into a function 2019-04-13 17:21:13 -05:00
Mahmoud Al-Qudsi
ab37dfaf78 Add tests for evaluaton of empty blocks and functions 2019-04-13 17:21:13 -05:00
Mahmoud Al-Qudsi
87f6856954 Fix tests expecting non-zero status after empty function call 2019-04-13 17:21:13 -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
f35f2fe110 Mark the benchmark as using the terminal
Prevents buffering all output from the command.
2019-04-13 12:40:12 -07:00
ridiculousfish
e634abc1c8 Add a benchmark for external commands
This just runs '/usr/bin/true' a lot.
2019-04-13 12:40:09 -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
Mahmoud Al-Qudsi
5989a92dae Add completions for rg (ripgrep)
[ci skip]
2019-04-12 15:20:45 -05:00
David Adam
2ca1bc433f fish_indent_lexer: explicitly encode/decode bytes over pipe
Universal newlines behaves differently between Python 2.7 and 3.x,
leading to problems when running Sphinx with Python 2.7.

fish_indent always uses \n, so there's no need to use universal newline
detection.

This also allows full UTF-8 in documentation sources.

Closes #5808.
2019-04-12 23:10:53 +08: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
Geographer
9cf1b18b26 Honor dirprev scope (#5796)
* Honour `dirprev` scope

Honour the scope of the `dirprev` variable if it is universal
and avoid to shadow it with a global. This enables to share
the `cd` history between sessions.

* Honor dirnext and __fish_cd_direction scope

If these variables exist in the universal scope, do not shadow them
2019-04-12 09:43:34 +02:00
Fabian Homborg
898ed12a6c
Merge pull request #5795 from cstyles/git-completions
Add git completions
2019-04-12 09:42:52 +02:00
Fabian Homborg
e672b03993 functions/fish_hg_prompt: Remove --color and --pager
These weren't added long enough ago, and I only added them
speculatively.

So it should make it work with old hg versions.

CC @zanchey.

[ci skip]
2019-04-12 09:01:34 +02:00