Commit Graph

8540 Commits

Author SHA1 Message Date
Fabian Homborg
69f68d31df Reserve some builtin names
`argparse`, `read`, `set`, `status`, `test` and `[` now can't be used
as function names anymore.

This is because (except for `test` and `[`) there is no way to wrap these properly, so any
function called that will be broken anyway.

For `test` (and `[`), there is nothing that can be added and there
have been confused users who created a function that then broke
everything.

Fixes #3000.
2018-02-25 21:29:24 +01:00
Xavier Lepaul
5648322993 Add required argument to history delete (#4740) 2018-02-25 16:46:25 +01:00
Kevin Konrad
8536a6825f add completion for MacPorts 2018-02-24 23:32:25 +08:00
ridiculousfish
99200d3bfb Attempt to fix the Linux Travis build 2018-02-23 21:38:48 -08:00
ridiculousfish
c4d903ff98 Rationalize how the parser reports tokenizer errors
Remove the unnecessary SQUASH_ERROR flag and correctly report errors
generated from the tokenizer.
2018-02-23 17:28:12 -08:00
ridiculousfish
0950c35eb2 Reduce the amount of copying when the parser drives the tokenizer 2018-02-23 15:58:13 -08:00
ridiculousfish
99fb7bb6aa Refactor how redirections are represented by the tokenizer
Prior to this fix, each redirection type was a separate token_type.
Unify these under a single type TOK_REDIRECT and break the redirection
type out into a new sub-type redirection_type_t.
2018-02-23 15:19:58 -08:00
ridiculousfish
6673fe5457 Clean up tokenizer implementation
Rather than storing a bunch of "next_foo" fields, simply populate the
tok_t directly.
2018-02-23 14:31:13 -08:00
Steely Wing
e9a4875a6b Remove the duplicate "(" (#4748) 2018-02-23 18:19:19 +01:00
Mahmoud Al-Qudsi
1b27c97bfb [cmake] Fix dependency path for FBVF for fish.pc rule
The custom command for fish.pc had a dependency on FBVF, but it appears
that the relative path to FBVF was incorrect and with CMake 3.10.1 under
FreeBSD this was consistently causing the build to fail if
../build_tools/git_version_gen.sh hadn't (coincidentally, I think?)
already run.

Explicitly set the dependency path for FBVF to the binary directory.
2018-02-21 13:58:56 -06:00
Mahmoud Al-Qudsi
9e1576bdc4 Revert "[cmake] Add rule to generate FBVF"
This reverts commit e4c59ac60a.

I hadn't seen the FBVF rule in the `Version` CMake file. There's
something else going on here.
2018-02-21 13:50:05 -06:00
Mahmoud Al-Qudsi
e4c59ac60a [cmake] Add rule to generate FBVF
The custom command for fish.pc had a dependency on FBVF, but there was
no cmake rule for the generation of the FBVF file. With CMake 3.10.1
under FreeBSD, this was consistently causing the build to fail if
../build_tools/git_version_gen.sh hadn't (coincidentally, I think?)
already run.
2018-02-21 13:40:15 -06:00
Jordi Burguet-Castell
0cd934ea63 apt.fish: add completions for "depends" and "rdepends" 2018-02-20 22:38:48 +11:00
Xavier Lepaul
49b0c7a4fe Fix typo in doc 2018-02-20 22:34:22 +11:00
ridiculousfish
0f62161b2b Clean up tokenizer error handling. 2018-02-19 16:31:39 -08:00
ridiculousfish
f30bf40300 Clean up comment parsing in tokenizer
Unify the show_comments and non-show_comments path.
2018-02-19 16:20:47 -08:00
ridiculousfish
b13ee818d2 Some early cleanup of tokenizer
Prior to this the tokenizer ran "one ahead", where tokenizer_t::next()
would in fact return the last-parsed token. Switch to parsing on demand
instead of running one ahead; this is simpler and prepares for tokenizer
changes.
2018-02-19 15:10:59 -08:00
Fabian Homborg
04c399c5a9 Fix changelog typo
[ci skip]
2018-02-19 20:29:19 +01:00
Fabian Homborg
304d9da6a0 Document fish_exit event 2018-02-19 20:21:02 +01:00
Fabian Homborg
f7adaeb97b Use the new fish_exit event 2018-02-19 20:21:02 +01:00
Fabian Homborg
b67a614d86 Replace the process-exit event with generic "fish_exit" event
Turns out the process-exit is only ever used in conjunction with
`%self`. Make that explicit by just adding a new "fish_exit" event,
and deprecate the general process-exit machinery.

Fixes #4700.
2018-02-19 20:21:02 +01:00
ridiculousfish
9444c65ee8 Remove an unused variable from expand_cmdsubst 2018-02-18 20:31:35 -08:00
ridiculousfish
137c2559d9 Remove parser_error
It was unused.
2018-02-18 20:29:28 -08:00
ridiculousfish
5c44d897ea Mark overriding virtual functions as override instead of virtual 2018-02-18 19:12:45 -08:00
ridiculousfish
51c9ad1359 Mark trivial constructors/destructors as default 2018-02-18 19:12:45 -08:00
ridiculousfish
da84b38430 Constructors to accept more parameters by value
In cases where the constructor needs to take ownership of parameters,
pass them by value and use std::move.
2018-02-18 19:12:45 -08:00
ridiculousfish
74e6a82849 Remove explicit 'void' parameters. 2018-02-18 19:12:45 -08:00
Mahmoud Al-Qudsi
50541544f2 Distinguish between function and block IO for fork debug log messages 2018-02-18 16:49:27 -06:00
Mahmoud Al-Qudsi
fedce06687 Decrease error level for 'already has control of terminal' messages 2018-02-18 16:49:27 -06:00
ridiculousfish
fd2a0dffa9 Reflect newlines after pipes in fish grammar
The previous attempt to support newlines after pipes changed the lexer to
swallow newlines after encountering a pipe. This has two problems that are
difficult to fix:

1. comments cannot be placed after the pipe
2. fish_indent won't know about the newlines, so it will erase them

Address these problems by removing the lexer behavior, and replacing it
with a new parser symbol "optional_newlines" allowing the newlines to be
reflected directly in the fish grammar.
2018-02-18 14:44:08 -08:00
ridiculousfish
ea4e997dc9 Remove ends_with_pipe from reader
Now that parse_util_detect_errors() can report incomplete pipelines,
we no longer have to detect this in the reader.
2018-02-18 13:17:45 -08:00
ridiculousfish
ddd1afc57c Teach parse_util_detect_errors about unterminated pipelines
Allow it to return PARSER_TEST_INCOMPLETE for code like
`echo | `
2018-02-18 13:13:58 -08:00
slama
26ea8dc362 add tests for a pipe at the end of the line 2018-02-18 13:01:38 -08:00
slama
38418d6356 Enable multi-line edit when the line ends with a pipe (#1285) 2018-02-18 13:01:38 -08:00
ridiculousfish
cefb9e6d03 Factor our plain statement case of parse_util_detect_errors
Factors out a lot of code into a separate function.
2018-02-18 13:00:46 -08:00
ridiculousfish
81b3baaa9c Correct handling of unescapable entities in quotes
Prior to this fix, if you attempt to complete from inside a quote and the
completion contained an entity that cannot be represented inside quotes
(i.e. \n \r \t \b), the result would be a broken mess of quotes. Rewrite
the implementation so that it exits the quotes, emits the correct unquoted
escape, and then re-enters the quotes.
2018-02-17 15:18:46 -08:00
ridiculousfish
01d87455e1 Teach parse_util_escape_string_with_quote about tildes
Properly escape literal tildes in tab completion results. Currently we
always escape tildes in unquoted arguments; in the future we may escape
only leading tildes.

Fixes #2274
2018-02-17 15:18:43 -08:00
ridiculousfish
a261beef02 Minor cleanup of complete.cpp 2018-02-17 13:27:30 -08:00
ridiculousfish
0b2d8fd37e Switch some loops in handle_completions to C++11 range-based for looops 2018-02-17 13:10:05 -08:00
ridiculousfish
cdfdc994f1 Clean up completion_t constructors
Use some move semantics and default implementations.
2018-02-16 21:28:53 -08:00
ridiculousfish
9cd952588f Reset autoloads in response to variable changes
Prior to this fix, autoloads like function and completion autoloads
would check their path variable (like fish_function_path) on every
autoload request. Switch to invalidating it in response to the variable
changing.

This improves time on a microbenchmark:

    for i in (seq 50000)
      setenv test_env val$i
    end

from ~11 seconds to ~6.5 seconds.
2018-02-15 22:20:57 -08:00
Mahmoud Al-Qudsi
be13ac353b Refactor job control to make functions act like their names imply
The job control functions were a bit messy, in particular
`set_child_group`'s name would imply that all it does is set the child
group, but in reality it used to set the child group (via `setpgid`),
set the job's pgrp if it hasn't been set, and possibly assign control of
the terminal to the newly-created job.

These have been split into separate functions. Now `set_child_group`
does just (and only) that, `maybe_assign_terminal` might assign the
terminal to the new pgrp, and `on_process_created` is used to set the
job properties the first time an external process is created. This might
also speed things up (but probably not noticeably) as there are no more
repeated calls to `getpgrp()` if JOB_CONTROL is not set.

Additionally, this closes #4715 by no longer unconditionally calling
`setpgid` on all new processes, including those created by `posix_spawn`
which does not need this since the child's pgrep is set at in the
arguments to that API call.
2018-02-14 19:08:12 -06:00
ridiculousfish
8cf476fbf4 Merge branch 'functions_use_nodes'
This merges a set of changes that switch functions from executing source
to executing an already parsed tree (the same tree used when the function
is defined). This speeds up function execution, reduces memory usage, and
avoids annoying double parsing.

A simple microbenchmark of function execution:

    for i in (seq 10000)
      setenv test_env val$i
    end

time improves from 1.63 to 1.32 seconds.
2018-02-12 11:56:38 -08:00
ridiculousfish
5b5a3f78e1 Eliminate parse_execution_context_t::get_offset
This was used to find the index given a pointer to a node. It's now unused.
2018-02-12 10:56:08 -08:00
ridiculousfish
d536b152f7 Simplify the parser_t::eval() return type to void
The return value was unused.
2018-02-12 10:55:55 -08:00
ridiculousfish
4eb73862fc Switch parser_t::execution_contexts to only storing one
We only ever need the topmost (currently executing) context. We can
store the stack via the C stack rather than an explicit std::vector.
2018-02-12 10:55:42 -08:00
ridiculousfish
92d5c28730 Move eval_level into parser_t
This avoids the ping-ponging of eval_level through
parse_execution_context. Simply store the global eval level in the
parser_t.
2018-02-12 10:55:31 -08:00
ridiculousfish
8bddce2633 Remove fake_block_t
It was unused.
2018-02-12 10:55:28 -08:00
ridiculousfish
3e063e7c13 Remove node_offset from block_t
It was not used. Also clean up the constructor some.
2018-02-12 10:55:26 -08:00
ridiculousfish
8251d949f1 Switch executing_node_idx to storing a tnode_t
Avoids annoying index<->node conversions.
2018-02-12 10:55:20 -08:00