Commit Graph

19388 Commits

Author SHA1 Message Date
Rikuki IX
85801b443a
feat(completion): add lsb_release completion (#10795) 2024-10-19 13:06:06 -05:00
Jason Nader
6082c3f77a
completions/diff: allow file completion for --unified (#10796)
* completions/diff: allow file completion for --unified

* Update diff.fish

* Update diff.fish
2024-10-19 16:58:29 +02:00
Johannes Altmanninger
b625c566b1 Remove workaround for WezTerm configured with enable_kitty_keyboard=true
Some checks failed
Rust checks / clippy (push) Has been cancelled
make test / ubuntu (push) Has been cancelled
Rust checks / rustfmt (push) Has been cancelled
make test / ubuntu-32bit-static-pcre2 (push) Has been cancelled
make test / ubuntu-asan (push) Has been cancelled
make test / macos (push) Has been cancelled
On a German keyboard, with a German keymap, and this ~/.wezterm.lua

    local wezterm = require 'wezterm'
    local config = wezterm.config_builder()
    config.enable_kitty_keyboard = true
    return config

when I press shift+# (which is single quote)
WezTerm sends the CSI u encoding shift-'.

Because of this, we completely disable kitty progressive enhancements and
modifyOtherKeys on WezTerm.

It makes no sense for every single app to work around WezTerm violating the
protocol. All these workarounds just create unnecessary version dependencies.
Also our workaround is brittle; it breaks as soon as you're inside something
like SSH.
Least importantly, the workarond prevents users of English keyboard layouts
to easily use the new features.

Since it seems so easy to work around by settting "enable_kitty_keyboard = false",
and most importantly, since that's the default, it seems better to remove
the workaround to simplify the world.

See #10663
2024-10-17 11:30:30 +02:00
Johannes Altmanninger
3869b59000 Add some context to changelog on new alt arrow bindings 2024-10-17 11:30:30 +02:00
Fabian Boehm
a1e74007d2 CHANGELOG colorscheme 2024-10-17 11:14:01 +02:00
Fabian Boehm
81ff6db62d default color scheme: Make commands "normal" color
Some checks failed
Rust checks / rustfmt (push) Has been cancelled
Rust checks / clippy (push) Has been cancelled
make test / ubuntu (push) Has been cancelled
make test / ubuntu-32bit-static-pcre2 (push) Has been cancelled
make test / ubuntu-asan (push) Has been cancelled
make test / macos (push) Has been cancelled
This makes the default colorscheme less colorful for two reasons:

1. It makes it a little less "angry fruit salad"
2. Some terminals (like Microsoft's Windows Terminal) have a terrible
blue default that contrasts badly against a black background

The alternative is to make *parameters* "normal" and give commands the
current parameter color (cyan). But I've seen cyan be quite blue and
quite green depending on the terminal, so I don't want to rely on it.
2024-10-15 21:21:30 +02:00
Fabian Boehm
0dfc490721 build.rs: Use Cargo_PKG_VERSION if no version could be found
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run
`cargo build --git` clones a git repo without any tags, so you get a
version like

```
fish, version f3fc743fc
```

which is *just* the commit hash and missing the "3.7.1-NUM-g" part.

So, if we hit that case (detected because it has no ".", under the
assumption that we'll never make a version that's just "4" instead of
"4.0"), we prepend the version from Cargo.toml.
2024-10-15 13:10:07 +02:00
Fabian Boehm
de13e6f9af complete: Only describe commands if the function exists
This shells out to __fish_describe_command, but if the install is
incomplete that will trigger the command-not-found handler.
2024-10-15 13:09:02 +02:00
Fabian Boehm
ebf19c22fd fish_config: Find fish via fish-path 2024-10-15 13:09:02 +02:00
Mahmoud Al-Qudsi
8447c32d65 __fish_indent: Cache fish_indent location
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run
2024-10-14 19:01:41 -05:00
exploide
7bb6ce5156 completions: added arping 2024-10-14 15:34:11 -07:00
EmilyGraceSeville7cf
1148b790bb
feat(completion): support winetricks command 2024-10-14 15:11:45 -07:00
exploide
2f2b4c8e99 completions: updated hashcat completions
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / clippy (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
2024-10-14 12:12:07 -07:00
Fabian Boehm
9f92d1f204 CI: Remove test deps from the clippy check 2024-10-14 21:02:26 +02:00
Johannes Altmanninger
b4f86bf0f5 Fix installation of pexpect on latest GitHub Actions images
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run
We already use --break-system-packages for macOS but it's not necessary here.
2024-10-14 11:26:08 +02:00
Johannes Altmanninger
a2dc0ef377 Revert "Lock history file before reading it"
Commit 5db0bd5 (Lock history file before reading it, 2024-10-09)
rewrites the history file in place instead of using rename().
By writing to the same file (with the same inode), it corrupts
our memory-mapped snapshot; mmap(3) says:

> It is unspecified whether modifications to the underlying object done
> after the MAP_PRIVATE mapping is established are visible through the
> MAP_PRIVATE mapping.

Revert it (it was misguided anyway).

Closes #10777
Closes #10782
2024-10-14 11:13:46 +02:00
Peter Ammon
fbf0ad98af
Build macOS x86-64 with Rust 1.73.0 in make_pkg.sh
Some checks failed
make test / macos (push) Waiting to run
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run
Lock threads / lock (push) Has been cancelled
This retains compatibility with macOS 10.9.
Note that Apple Silicon Macs shipped with 10.15, so compatibility for Apple
Silicon is not a concern.
2024-10-13 14:36:02 -07:00
Peter Ammon
9337c20c2e
Stop using the getrandom feature of the rand crate
This feature uses the "getentropy" function which is not supported on
macOS < 10.12.
2024-10-13 12:39:54 -07:00
Johannes Altmanninger
6af96a81a8 Default bindings for token movement commands
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run
There is no natural default binding for token movements. Add the
alt-{left,right,backspace,delete}, breaking some existing behavior.

For example, backward-delete-word is no longer bound to alt-backspace but
only to ctrl-backspace.  Unfortunately some terminals (particularly tmux)
don't support distinguishing ctrl-backspace from ctrl-h yet, so the loss
of alt-backspace may be tragic.

---

I guess we could also add:

    bind alt-B backward-token
    bind alt-F forward-token
    bind ctrl-W backward-kill-token
    bind alt-D kill-token

Those might be intercepted by the terminal on Linux, but I don't know where
that happens.

Tested on foot, kitty, alacritty, xterm, tmux, konsole and gnome-terminal.

Closes #10766
2024-10-13 14:53:45 +02:00
Johannes Altmanninger
2dafe81f97 Builtin source to print error if missing both file argument and piped stdin
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run
Closes #10774
2024-10-13 10:44:38 +02:00
Johannes Altmanninger
00875d0f83 Allow builtin source to read from non-regular files
Commit a91bf6d88 (builtin.c: builtin_source now checks that its argument is
a file., 2005-12-16) fixed an infinite loop for commands like "source /"
where the argument is a directory.

It did so by erroring out early unless the filename argument is a regular file.
This is too restrictive; it disallows reading from special files like /dev/null
and fifos.
Today we get a sensible error without this check, so remove it.
2024-10-13 10:44:38 +02:00
Johannes Altmanninger
ba67d20b7c Refresh TTY timestamps after nextd/prevd
This fixes a macOS-specific bug.  See 390b40e02 (Fix regression not refreshing
TTY timestamps after external command from binding, 2024-05-29) and 8a7c3ceec
(Don't abandon line after writing control sequences, 2024-04-06).

Fixes #10779
2024-10-13 08:17:22 +02:00
Johannes Altmanninger
3a02a3bd6c Fix tmux-multiline-prompt test on some systems
The fast input would race with tmux redrawing the screen,
so sometimes the ": 5" is rendered twice.
2024-10-13 08:17:22 +02:00
Johannes Altmanninger
24e7a2ca60 Disable tmux OSC 133 prompt marking test also on cirrus' old alpine
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run
tmux -V prints "tmux next-3.4" there.
2024-10-12 21:05:27 +02:00
Johannes Altmanninger
f77153e6c8 Disable tmux OSC 133 prompt marking test for some tmux versions < 3.4
OSC 133 was added to tmux 3.4.

Also fix the test on macOS where we do have 3.5a in CI; for some reason we
get copy_cursor_y=6 there.  I didn't investigate yet but at least that's
not the same bug this test was made to fix.
2024-10-12 19:48:26 +02:00
Johannes Altmanninger
5496247344 Avoid erasing OSC 133 prompt start marker with clr_eol
For multi-line prompts, we start each leading line with a clr_eol.  Immediately
before printing these prompt lines we emit the OSC 133 prompt start marker.
Some terminals such as tmux interpret make clr_eol delete such markers,
hence prompt navigation is broken.

Fix this by printing the marker only after clr_eol.

The scenario where this triggers is quite odd.  I haven't looked into why
the problem doesn't exist if I remove the recursive repaint request.

See https://github.com/tmux/tmux/issues/4183
Closes #10776
2024-10-12 19:00:16 +02:00
Johannes Altmanninger
69380c6c92 Remove redundant test setup
One function calls setup twice, and the other one is not a test so should
not be prefixed with "test_".
2024-10-12 13:32:19 +02:00
Johannes Altmanninger
a139d204c0 Restore terminal state again in panic handler
Our panic handler attempts a blocking read from stdin and only exits
after the user presses Enter.

This is unconventional behavior and might cause surprise but there is a
significant upside: crashes become more visible for terminals that don't
already detect crashes (see ecdc9ce1d (Install a panic handler to avoid
dropping crash stacktraces, 2024-03-24)).

As reported in 4d0aa2b5d (Fix panic handler, 2024-08-28), the panic handler
failed to exit fish if the panic happens on background threads.  It would
only exit the background thread (like autosuggestion/highlight/history-pager
performer) itself. The fix was to abort the whole process.
Aborting has the additional upside of generating a coredump.

However since abort() skips stack unwinding, 4d0aa2b5d makes us no longer
restore the terminal on panic. In particular, if the terminal supports kitty
progressive enhancements, keys like ctrl-p will no longer work in say,
a Bash parent shell.  So it broke 121680147 (Use RAII for restoring term
modes, 2024-03-24).

Fix this while still aborting to create coredumps.  This means we can't use
RAII (for better or worse).  The bad part is that we have to deal with added
complexity; we need to make sure that we set the AT_EXIT handler only after
all its inputs (like TERMINAL_MODE_ON_STARTUP) are initialized to a safe
value, but also before any damage has been done to the terminal. I guess we
can add a bunch of assertions.

Unfortunately, if a background thread panics, I haven't yet figured out how
to tell the main thread to do the blocking read.  So the trick of "Press
Enter to exit", which allows users to attach a debugger doesn't yet work for
panics in background threads.  We can probably figure that out later. Maybe
use pthread_kill(3)?  Of course we still create coredumps, so that's fine.
As a temporary workaround, let's sleep for a bit so the user can at least
see that there is a crash & stacktrace.

One ugly bit here is that unit tests run AT_EXIT twice but it should be
idempotent.
2024-10-12 13:28:55 +02:00
Johannes Altmanninger
468849dd54 Minor refactoring in panic handler
I don't think I really get why this newline is here. It moves the cursor
from the end of the newline to the beginning of the next line.  Maybe it
was added only for panics in background threads?  Either way it's fine.
2024-10-12 12:18:50 +02:00
Johannes Altmanninger
97581ed20f Do send bracketed paste inside midnight commander
It can handle it fine (well, it simply strips the control sequences..).
2024-10-12 12:18:50 +02:00
Johannes Altmanninger
0d9dfb307b Apply terminal protocol workarounds also in fish_key_reader
We don't care to check the latest value of these variables;
these should only be read on startup and are not meant to
be overridden by the user ever. Hence we don't need a parser.
2024-10-12 12:18:50 +02:00
Johannes Altmanninger
fe3e3b3b50 Fix potential assertion failure on SIGTERM
If SIGTERM is delivered to a background thread, a function call to sanitize
the reader state would crash in assert_is_main_thread(). In this case we
are about to exit so there's no need to fix the reader state. Skip it on
background threads.
2024-10-12 10:50:56 +02:00
Johannes Altmanninger
49b88868df Fix stripping of " (deleted)" from non-UTF8 paths to fish 2024-10-12 06:53:25 +02:00
Johannes Altmanninger
edaf011ab1 Try to use the fish_indent that corresponds to the fish binary
Some checks failed
Rust checks / clippy (push) Has been cancelled
make test / ubuntu (push) Has been cancelled
make test / ubuntu-32bit-static-pcre2 (push) Has been cancelled
make test / ubuntu-asan (push) Has been cancelled
make test / macos (push) Has been cancelled
Rust checks / rustfmt (push) Has been cancelled
Users may install two versions of fish and configure their terminal to run
the one that is second in $PATH.  This is not really what I'd do but it
seems reasonable.  We should not need $PATH for this.

Fixes #10770
2024-10-10 05:18:35 +02:00
Johannes Altmanninger
88e749e4ce fixup! Back out assertion that doesn't hold yet
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run
2024-10-09 21:35:56 +02:00
Johannes Altmanninger
c5db7565cc Back out assertion that doesn't hold yet 2024-10-09 21:34:19 +02:00
Johannes Altmanninger
5db0bd5874 Lock history file before reading it
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run
We use optimistic concurrency when rewriting the history file to
minimize the lock scope. Unfortunately, old.mtime == new.mtime
does not imply that file is unchanged; we don't have guarantees
on the granularity of the modification time timestamp, see
https://stackoverflow.com/questions/14392975/timestamp-accuracy-on-ext4-sub-millsecond

So let's lock before reading any old contents and use the other
"write-to-tempfile-and-rename" code path only when locking fails.

Potentially fixes #10300
(untested) which probably happens because read_zero_padded() attempts to
read bytes that have not been flushed yet.
2024-10-09 14:51:54 +02:00
Johannes Altmanninger
35ee5e661f history: rename target_fd_after to target_file_after
This was forgotten in decf99f71 (Use `File` instead of `OwnedFd` in a few
places (#10355), 2024-03-17).
2024-10-09 14:51:54 +02:00
Johannes Altmanninger
f906a949cf Temporarily enable history_file debug category by default
All of these should never happen so let's enable them to hopefully get useful
bug reports.  Should disable it again before a release.

See #10300
2024-10-09 14:51:54 +02:00
Johannes Altmanninger
13e5d8097c Log more history_file errors, and add more context
See #10300
2024-10-09 14:51:54 +02:00
Johannes Altmanninger
29a01eb3cf Fix EINTR handling when importing history from bash 2024-10-09 14:48:58 +02:00
Johannes Altmanninger
ffedcdaac3 Do not interpret unknown file systems as local on Linux
No functional change, since with the parent commit, we no longer treat
"DirRemoteness::local" different from "DirRemoteness::remote", but we might
do so in future, so make sure we don't give a false positive here.

Non-Linux systems have ST_LOCAL or MNT_LOCAL, so no unknowns there.

See #10434
2024-10-09 14:48:58 +02:00
Johannes Altmanninger
dc5823d150 Fix history merge on all network file systems
mmap() fails with ENODEV on remote file systems. This means we always fail
to read any old history on network file systems on Linux (except on the file
systems we recognize which are NFS, SMB and CIFS).

Untested, so I'm not sure if this works.

Fixes #10434
2024-10-09 14:48:58 +02:00
Johannes Altmanninger
37c04745e6 Avoid potential contention on SIGTERM while enabling terminal protocols
We no longer use RAII for enabling/disabling these, so a full object is
overkill.  Additionally this object doesn't allow us to recover from the case
where we receive SIGTERM while inside terminal_protocols_{enable,disable}.
We can simply run disable another time since they're idempotent. Untested.
2024-10-09 13:05:25 +02:00
Lucas Garron
a7abd83c57 Typo fix: documentaiton → documentation
Closes #10767
2024-10-09 12:36:58 +02:00
Johannes Altmanninger
2b873570a8 Fix typo 2024-10-09 12:36:58 +02:00
Fabian Boehm
e3ecfa729d CHANGELOG
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run
The flow control thing isn't down to us, it's apparently a common
terminal issue where they no longer trigger suspend when CSI u is
used.
2024-10-08 19:34:24 +02:00
Peter Ammon
c33b35efd4
Set macOS version minimums harder
Some checks failed
make test / ubuntu (push) Has been cancelled
make test / ubuntu-32bit-static-pcre2 (push) Has been cancelled
make test / ubuntu-asan (push) Has been cancelled
make test / macos (push) Has been cancelled
Rust checks / rustfmt (push) Has been cancelled
Rust checks / clippy (push) Has been cancelled
Lock threads / lock (push) Has been cancelled
Fix the macOS app.
2024-10-06 16:38:21 -07:00
Peter Ammon
0e474768f4
Set macOS version minimums when building
Allows running on older versions of macOS.
2024-10-06 14:39:04 -07:00
Johannes Altmanninger
efa109b62e Add default-enabled error log when there is a corrupted history entry
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run
We'll drop the corrupted item on the next vacuum, so this shouldn't be
too annoying, and hopefully helps to narrow down #10300 further.
2024-10-06 11:48:51 +02:00