Commit graph

12362 commits

Author SHA1 Message Date
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
Fabian Homborg
1af1e7b69b CHANGELOG: Fix formatting 2020-06-02 17:39:36 +02:00
Kristofer Rye
146ec619d9 Add "alacritty" to the list of known titleable TERMs
This change is necessary to fix dynamic titles for the Alacritty
terminal.  We do this by simply adding the (wchar_t *) literal
L"alacritty" to the end of the title_terms array.  This variable is
ultimately used in the subsequent function
does_term_support_setting_title (dtsst) for the purposes of whitelisting
certain terminals.

If an Alacritty user does not have the terminfo for alacritty present in
their terminfo database, Alacritty sets the TERM variable to
"xterm-256color", but if the terminfo for Alacritty is present, TERM is
instead set to "alacritty".

Prior to this change, none of the "fallback patterns" in the dtsst
function (which is used to ultimately decide whether or not a given
value of the TERM environment variable is supported) would apply to a
value of "alacritty".  Ordinarily, the dtsst function would return true
if nothing matches, but one of the final checks involves testing the
result of ttyname_r to see if it contains the substring "tty", which
causes dtsst to return false.  In the case where TERM="alacritty", this
is erroneous, because Alacritty does, indeed, support changing its title
and will also silently ignore attempts to change the title if that
behavior has been disabled by the user [1].

The changed file, src/env_dispatch.cpp, was reformatted by clang-format
in accordance with the documented procedures for contributors.

Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>

[1]: 1dacc99183/alacritty_terminal/src/term/mod.rs (L896-L900)
2020-06-01 19:06:32 -07:00
Fabian Homborg
4d487f711d Don't use cbegin/cend
This has problems on old gcc, and isn't super necessary.
2020-06-01 15:52:15 +02:00
Fabian Homborg
4e16310940 Some more CHANGELOG 2020-06-01 15:51:45 +02:00
Fabian Homborg
90b01fd915 set: Show pathvariableness in --show 2020-06-01 15:51:10 +02:00
Fabian Homborg
4eb906c8d8 CHANGELOG Work towards 3.2
[ci skip]
2020-06-01 11:52:47 +02:00