When fish receives a "cancellation inducing" signal (SIGINT in particular)
it has to unwind execution - for example while loops or whatever else that
is executing. There are two ways this may come about:
1. The fish process received the signal
2. A child process received the signal
An example of the second case is:
some_command | some_function
Here `some_command` is the tty owner and so will receive control-C, but
then fish has to cancel function execution.
Prior to this change, these were handled uniformly: both would just set a
cancellation signal inside the parser. However in the future we will have
multiple parsers and it may not be obvious which one to set the flag in.
So instead distinguish these cases: if a process receives SIGINT we mark
the signal in its job group, and if fish receives it we set a global
variable.
We were previously aborting the main event loop before calling fish_exit
in the event of a SIGHUP. This patch causes the SIGHUP to be stored in a
separate state variable from a regular "must exit" condition so the
associated event can be fired before we terminate the loop.
All streams are redirected before the event is called to prevent a
SIGTTIN/SIGTTOU due to the user script reading/writing from a disposed
tty.
Closes#7014
This error only happens on recent versions of gcc, see previous
commit e6bb7fc973 for more info.
Instead of using `ignore_result()` here, I've added a `system_assert`
function/macro that mimics the behavior of all the other `system()`
calls in the file.
Previously fish weak-linked wcsdup, wcsncasecmp, and wcscasecmp.
This enabled fish to be used on 10.6. However the minimum Mac version
is now 10.9, where these symbols are available.
This reworks the "a=" detection to be simpler.
If we detect a variable assignment that produces an error,
simply consume it.
We also take the opportunity to not highlight it as an error,
and add some tests.
Original commit is 1ca05d32d3.
Typing that command in an interactive prompt would make the highlighter thread
eat up CPU and memory. Probably not the right fix; I think the token should
already have been consumed when the error is detected, then there is no need
to consume it when unwinding.
When selectiong a large completion entry in the pager, it would clobber the
prompt. To reproduce, first run this command
complete -c : -xa '(
# completion entries that, when applied to the commandline
# need one, two, or three lines respectively
echo 1
echo 2(string repeat -n (math $COLUMNS - 5) x)
echo 3(string repeat -n $COLUMNS x)
printf %s\n n(seq $LINES)
)'
then type ": " and hit Tab repeatedly. When cycling through completion
entries, observe that fish always tries to render the pager with the same
size, even though the number of lines occupied by the command line buffer
changes due to soft wrapping.
Fix this by rendering the pager after the command line has been rendered, so
we know how many lines we have left.
This switches fish_indent from parsing with parse_tree
to the new ast.
This is the most difficult transition because the new ast retains less
lexical information than the old parse tree. The strategy is:
1. Use parse_util_compute_indents to compute indenting for each token.
2. Compute the "gap text" between the text of significant tokens. This
contains whitespace, comments, etc.
3. "Fix up" the gap text while leaving the significant tokens alone.
This switches parse_util_compute_indents from parsing with parse_tree to
the new ast.
It also reworks the parse_util_compute_indents tests, because
parse_util_compute_indents will be the backing for fish_indent.
This is the first commit of a series intended to replace the existing
"parse tree" machinery. It adds a new abstract syntax tree and uses a more
normal recursive descent parser.
Initially there are no users of the new ast. The following commits will
replace parse_tree -> ast for all usages.
Prior to this commit, fish used NUL ('\0') to disable control
functions (for example, the function that generates SIGTSTP).
However NUL may in fact be bindable and is on macOS via
control-space.
Use instead _POSIX_VDISABLE if defined and not -1.
This was always awkward as fish script, and had problems with
interrupting the autoloading.
Note that we still leave the old function intact to facilitate easier
upgrading for now.
Fixes#7145.
Page-Down seems to deactivate history search, so trying to undo
would leave the command line in an inconsistent state.
Fixes#7162 which was introduced in
12a9cb29 Fix assertion failure on page up / page down
It is used exclusively as vector at the moment since we only ever append
at the end. Making it a deque would be useful when allowing to edit the
search string and subsequently resume the search at an arbitrary position
in the history.
When editing a multiline command line and pressing "up" with the cursor at the
first line, fish attempts a hsitory search. If the search fails, don't move
the cursor to the end of the multiline command because this can be annoying
when the user does not actually want to perform a history search.