Commit Graph

12768 Commits

Author SHA1 Message Date
ridiculousfish
9aa110314a Rationalize tty size and resizing
This merges a collection of changes attempting to rationalize how fish
handles the tty size.

The basic problem this addresses is that, prior to this fix, a call to
`common_get_width()` could result in arbitary code execution, as it lazily
updates COLUMNS and LINES which fires events, etc. With the new design, we
explicitly track the 'last known' tty size and also whether it is known stale,
and update it only at defined points.

This stuff is fraught and tricky, and so it is a merge commit so that if
something breaks, we can revert the whole thing and not end up with two
sources of termsize truth. Knock on wood.
2020-06-07 20:17:11 -07:00
ridiculousfish
c7160d7cb4 Eliminate the termsize handling from common.h
Finish the transition to termsize.h. Remove the scary termsize bits
from common.cpp, which can throw off events at arbitrary calls and are
dangerously reentrant. Migrate everyone to the new termsize.h.
2020-06-07 20:00:42 -07:00
ridiculousfish
6bdbe732e4 Adopt termsize_t in the pager 2020-06-07 20:00:42 -07:00
ridiculousfish
db909605b8 Migrate reformat_for_screen to new termsize container 2020-06-07 20:00:42 -07:00
ridiculousfish
340c8490f6 Introduce termsize_container_t
fish's handling of terminal sizes is currently rather twisted. The
essential problem is that the terminal size may change at any point from a
SIGWINCH, and common_get_{width,height} may modify it and post variable
change events from arbitrary locations.

Tighten up the semantics. Assign responsibility for managing the tty size
to a new class, `termsize_container_t`. Rationalize locking and reentrancy.

Explicitly nail down the relationship between $COLUMNS/$LINES and the tty
size. The new semantics are: whatever changed most recently takes
precendence.
2020-06-07 20:00:42 -07:00
ridiculousfish
d5a239e59e Bravely stop attempting to modify the terminal size
Prior to this fix, fish would attempt to resize the terminal via
TIOCSWINSZ, which was added as part of #3740. In practice this probably
never did anything useful since generally only the tty master can use
this. Remove the support and note it in the changelog.
2020-06-07 20:00:42 -07:00
ridiculousfish
df618a0768 Migrate DFLT_TERM from common.h to env.cpp
There's no reason every .cpp file needs to see these values.
2020-06-07 20:00:41 -07:00
ridiculousfish
7b486b4634 Factor s_reset better
Prior to this fix, s_reset would attempt to reset the screen, optionally
using the PROMPT_SP hack to go to the next line. This in turn required
passing in the screen width even if it wasn't needed (because we were
not going to abandon the line). Factor this into two functions:

- s_reset_line which does not apply the hack
- s_reset_abandoning_line which applies the PROMPT_SP hack
2020-06-07 20:00:41 -07:00
ridiculousfish
fc42516dfb Unwind some calls to common_get_width from inside screen
common_get_width will "lazily" decide the screen width, which means
changing the environment variable stack. This is a surprising thing
to do from the middle of screen rendering.

Switch to passing in widths explicitly to screen.
2020-06-07 20:00:41 -07:00
ridiculousfish
0673d86242 Remove a dead overload of s_reset
This function was not actually implemented.
2020-06-07 20:00:41 -07:00
ridiculousfish
812cc1dbaf Clean up line_t
Use a single allocation instead of two for text and colors.
Comment and tighten up its methods.
2020-06-07 20:00:41 -07:00
ridiculousfish
5429b54258 Remove k_invalid_termsize 2020-06-07 20:00:41 -07:00
ridiculousfish
462313f930 Remove ASSERT_IS_NOT_FORKED_CHILD from open_cloexec
This was tripping initialization order checks from ASAN, and is
otherwise not a very useful check here.
2020-06-07 19:58:52 -07:00
Kristofer Rye
3cfe113a60 builtin_string: Remove redundant condition in handle_flag_f
The removed comparison ({begin,end,field} == INT_MIN) always evaluates
to false, because at this point in evaluation, `begin <= 0` has already
been evaluated to be false.  Since INT_MIN <= 0, the second conditional
in all three of the affected cases is always false.  The C++ standard
seems to guarantee left-to-right evaluation of logical operators, but
not necessarily bitwise operators.

Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
2020-06-07 15:56:51 -07:00
ridiculousfish
8a27873598 Remove redundant expect tests
With the new pexpect based framework, bind and pipeline expect tests can
be removed.

Amusingly the complete.fish check required the existence of bind.expect.
Fix the check at the same time.
2020-06-07 14:53:17 -07:00
ridiculousfish
4ae4314e63 Improve pexpect output
Make it easier to use pexpect and to understand its error messages.
Switch to a style in tests using bound methods, which makes them
less noisy to write.
2020-06-07 14:53:17 -07:00
ridiculousfish
3b7feb38e9 Add pexpect-based interactive testing framework
This adds a new interactive test framework based on Python's pexpect. This
is intended to supplant the TCL expect-based tests.

New tests go in `tests/pexpects/`. As a proof-of-concept, the
pipeline.expect test and the (gnarly) bind.expect test are ported to the
new framework.
2020-06-07 14:46:21 -07:00
ridiculousfish
218fe15264 Add 'pip install pexpect' to travis config
In preparation for the new pexpect-based tests, modify
the travis config file to install pexpect.
2020-06-07 14:41:05 -07:00
ridiculousfish
229ead9b8a env_stack_t::set_termsize to operate on self, not global stack 2020-06-07 12:57:34 -07:00
ridiculousfish
064324984b Use consistent variable names in decl and def of calc_prompt_layout 2020-06-07 12:56:14 -07:00
Rosen Penev
9636d9f5d3 [clang-tidy] remove pointless string init
Found with readability-redundant-string-init

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-06-07 12:49:35 -07:00
Rosen Penev
67e5473a11 [clang-tidy] remove pointless cstr
Found with readability-convert-member-functions-to-static

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-06-07 12:49:35 -07:00
Rosen Penev
871a15bf58 [clang-tidy] fix automatic move warning
Found with performance-no-automatic-move

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-06-07 12:49:35 -07:00
Fabian Homborg
7791457bbb docs: Add string-collect link 2020-06-07 20:04:31 +02:00
Fabian Homborg
a6e4e082b7 docs: Include "fish for bash users" document
Not 100% done, but it should be okay as an overview.

Fixes #2382.
2020-06-07 20:04:05 +02:00
Mikel Ward
96425d2231 Fix string collect examples
collect -N leaves the trailing newline, not the other way around.
2020-06-07 19:33:27 +02:00
Fabian Homborg
37e9a3067f CHANGELOG 2020-06-07 16:28:23 +02:00
Fabian Homborg
9d2bf248ee test: Add tests for error messages 2020-06-07 16:23:29 +02:00
Fabian Homborg
1b4378d39d test: Show indexes starting at 1
We are 1-indexed, and so it's weird to have `test` count its arguments
from 0.

For `test 1 =` this changes the error from

test: Missing argument at index 2
1 =
    ^

to

test: Missing argument at index 3
1 =
    ^
2020-06-07 16:23:24 +02:00
Fabian Homborg
8a9e038b4e test: Show a caret for errors
test loves error messages like

test: Missing argument at index 2

without explaining where that "index 2" is.

So now, we print the arguments below that, with a caret pointing to
the place where the error occured.

For example:

    > test 1 = 2 and echo true or echo false
    test: Expected a combining operator like '-a' at index 3
    1 = 2 and echo true or echo false
          ^

    (Type 'help test' for related documentation)

Fixes #6030.
2020-06-07 16:23:10 +02:00
ridiculousfish
971f108bda Mark Intl cmake package as quiet
This suppresses not-very-interesting messages from CMake about whether
Intl was found or not.

Fixes #7091
2020-06-06 18:56:54 -07:00
ridiculousfish
783a895b11 Mark PCRE2's packages as quiet
This suppresses certain CMake messages about PCRE2 features that are not
relevant for fish. See #7091.
2020-06-06 18:55:55 -07:00
ridiculousfish
61e948454f Do even less work for empty commands
Inspired by #4829, skip further work when running a command
interactively if that command is empty.
2020-06-06 17:17:22 -07:00
Awal Garg
cb5eb72c6b Skip pre/post exec events for empty commands (#4829) 2020-06-06 16:31:33 -07:00
David Adam
c5e535e794 docs: link and explicit instructions on creating a blank fish_mode_prompt
Work on #5783.

[ci skip]
2020-06-06 22:52:13 +08:00
Fabian Homborg
0846fc8181 Manparser: Also replace \(cq escapes in the non-Deroff manparser
I'm not entirely sure why we have multiple parsers here, but I'm
guessing there's a reason.

Fixes #7086.
2020-06-06 16:23:43 +02:00
Fabian Homborg
ab2db135ba docs: Add first draft of fish-vs-bash
That name's probably not the correct one.

The idea is to have a quick primer document for people coming from bash.
2020-06-05 19:19:23 +02:00
Fabian Homborg
801ab95fd0 docs: Explain $XDG_CONFIG_HOME 2020-06-05 19:18:09 +02:00
Fabian Homborg
77fc83c293 docs: Reword history substitution
That prepend-sudo note was a bit awkward. I'm still not super happy
with it, but it should be better.

Also remove the "simple but effective" comment.
2020-06-05 19:17:19 +02:00
Fabian Homborg
a8d1eb83da CHANGELOG
[ci skip]
2020-06-04 18:29:31 +02:00
Fabian Homborg
e646285bcb
Let __fish_prepend_sudo use the last commandline if there is no current one (#7079)
* docs/faq: Mention prepend_sudo

[ci skip]

* __fish_prepend_sudo: Use $history[1] if commandline is empty

Currently, if you press alt+s with an empty commandline, it inserts
"sudo", which seems fairly useless.

Now, it inserts "sudo " followed by the last history entry, which
makes it a replacement for `sudo !!`.

* docs
2020-06-04 18:25:02 +02:00
Charles Gould
3692d63188 completions: shorten fzf descriptions 2020-06-04 18:24:11 +02:00
Charles Gould
0f4ed5b6b8 completions: shorten base64 descriptions 2020-06-04 18:24:11 +02:00
Charles Gould
fd2eb26ee3 completions: fix typo for mktemp 2020-06-04 18:24:11 +02:00
Fabian Homborg
44184f68e4 Add status dirname and status basename convenience commands
There's a terrible number of fishscripts that start with

    set path (dirname (status filename))

And that's really just a bit boring.

So let's let it be

    set path (status dirname)
2020-06-04 18:23:32 +02:00
Alexander Sieg
af2d19bde0
completions: add hikari completion (#7083)
* completions: add hikari completion

* requested changes by code reviewer
2020-06-04 18:22:25 +02:00
Fabian Homborg
5efe1a09ce docs/argparse: Add note on optional arguments
Yeah I had to answer this one again.

[ci skip]
2020-06-04 17:28:02 +02:00
Fabian Homborg
0064279905 Don't show greetings in read in scripts
This reverts commit 1b0ec21773.

"Interactive" has multiple meanings here, one of them being "the whole shell" is interactive, which `status is-interactive` tests, and one "this interaction is interactive", which happens when `read`ing in a script.

Fixes #7080.
2020-06-04 17:00:09 +02:00
Jason
4dff15b74e
kdeconnect-cli completions: ignore stderror (#7074)
* kdeconnect-cli completions: ignore error messages

* squash this please
2020-06-03 16:12:52 +02:00
Fabian Homborg
f25f15fd69 completions: Fix leftover "^" redirections 2020-06-02 21:43:32 +02:00