Commit Graph

19507 Commits

Author SHA1 Message Date
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
Johannes Altmanninger
9c4d31f89a Make errors in the history_file log category human-readable 2024-10-06 11:42:30 +02:00
Johannes Altmanninger
f36f757fa6 Never rewrite history file when adding ephemeral items
When I run a command with leading space, it is not added to the on-disk
history.  However we still call History::save().  After 25 of such calls,
we rewrite the history file (even though nothing was written by us).

This is annoying when diagnosing #10300 where the history of the current
shell (but not other shells) is broken; because the history rewrite will
make the problem go away. Let's not save in this case, to make it easier to
run commands to inspect the state of the history file.
2024-10-06 08:30:53 +02:00
Johannes Altmanninger
33bcf4d0ce Remove redundant drop 2024-10-06 08:30:53 +02:00
Peter Ammon
521498143a
Fix the static PCRE2 build harder
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
Commit 4e79ec5f tried to restore the static PCRE2 build after the update to the
pcre2 crate, but it set an environment variable at configure time, not build
time.

Properly set the environment variable at build time.
2024-10-05 20:22:55 -07:00
Johannes Altmanninger
1b9b893169 After reading corrupted history entry, keep reading older entries
Given a history like

    - cmd: echo OLD
      when: 1726157160
    \x00\x00\x00- cmd: echo leading NUL bytes
      when: 1726157160
    - cmd: echo NEW
      when: 1726157223

offset_of_next_item() happily records 3 items even though the second item
is corrupted.
decode_item() fails which makes the caller stop loading any older items --
we got knee capped.

Avoid this horrible failure mode by skipping over these items already in
offset computation. For now we still lose the corrupted item itself.

In future we should probably try to delete the NUL bytes or avoid the
corruption in the first place.

See #10300 and others.
2024-10-06 00:28:26 +02:00
diniamo
052e764f29 accept-autosuggestion to return false if there was no autosuggestion to accept
Example usage:

    bind ctrl-space accept-autosuggestion and execute

Closes #10608
2024-10-05 23:43:16 +02:00
EmilyGraceSeville7cf
cd3da62d24 fix(completion): unescape strings for __fish_complete_list 2024-10-05 23:32:59 +02:00
Jacob Chapman
a9cee9e755 Commands to move by entire tokens
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
ja: I'll try to add default bindings in a follow-up PR.

Closes #10738
Closes #2014
2024-10-05 22:43:39 +02:00
Fabian Boehm
e4c7a522ff webconfig: Add missing highlighting vars
This would otherwise not set these variables.

Tbh I would like if this wasn't hardcoded like that.
2024-10-05 16:30:58 +02:00
Fabian Boehm
5e8adb18f4 complete: Sort --keep-order completions smaller
This should make the sort have a strict weak ordering, which rust
requires since 1.81 (or it will panic).

Note: This changes the order, but that's *fine* since the current
order is random weirdness anyway.

Fixes #10763
2024-10-05 13:53:02 +02:00
Fabian Boehm
2238c07b91 path: Remove weird order hack
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
Part of #10763
2024-10-04 16:48:40 +02:00
Wolfgang Müller
38300a818e completions/portage: Follow symbolic links in repos.conf
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
Repository configuration files in the repos.conf/ directory may also be symbolic
links, so make sure to follow those.
2024-10-04 10:23:58 +02:00
Fabian Boehm
cd9e50c2cc completions/set: Complete variables of all scopes when setting
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
This was overly smart and tried to not show you e.g. global variables
unless you were setting without scope or explicitly global.

That is annoying when you do

`set -g fish_col<TAB>`

and don't get colors because they're universal, but you could
overwrite them.

We *could* elide e.g. local variables if we're setting a global, but I
can see someone wanting to set a universal variable on basis of a
global ("save this"), so I would rather not try to find the very
specific cases where this works.
2024-10-03 11:46:17 +02:00
Fabian Boehm
0fea1dae8c __fish_print_help: Make formatting more man-like
1. Leave the indentation
2. Leave the "NAME" header - without the first line would be
unindented
3. Leave the "SYNOPSIS" header

We use $MANPAGER here, so it should be formatted like a manpage.

The alternative is to write special docs for this use-case, which
would be shorter and point towards the full man page.

Fixes #10625
2024-10-03 11:29:24 +02:00
EmilyGraceSeville7cf
07bc54f406 feat(template): note about not documenting completions in PRs 2024-10-03 09:44:42 +02:00
Nikita Bobko
c253aa7a8c fish_vi_key_bindings: add bindings for semicolon and comma in visual mode
They are already presented in normal mode, and I presume were forgotten to be
added in visual mode

I don't add it to ./CHANGELOG.rst because it's a minor change that can be
considered as a bug fix
2024-10-03 09:42:59 +02:00
Johannes Altmanninger
f6d5355d7a Bump iTerm workaround version
Some checks failed
make test / ubuntu-32bit-static-pcre2 (push) Has been cancelled
make test / ubuntu (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
This unnecessarily enables the workaround for some nightly versions.

See #10653
2024-09-30 11:00:03 +02:00
Peter Ammon
4e79ec5f0e
CMake: Restore static PCRE2 builds
Some checks failed
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
Lock threads / lock (push) Has been cancelled
The recent update to the rust-pcre2 crate lost the property where a static
PCRE2 build could be enabled with a Cargo feature. This means that static
PCRE2 builds can no longer be forced.

Switch to setting the "PCRE2_SYS_STATIC" variable again, which is how the
official rust-pcre2 crate expects to work.
2024-09-29 19:42:48 -07:00
Peter Ammon
c227233571
fish_apropos: use realpath instead of readlink
readlink -f is not supported on macOS Big Sur (from 2020).
2024-09-29 18:13:36 -07:00
Johannes Altmanninger
243a8345ce Minor changelog updates
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
2024-09-28 18:00:02 +02:00
Johannes Altmanninger
d829a99977 Fix kbd tag HTML rendering
Commit c921c124e (docs: use canonical key names in :kbd: tags, 2024-04-13)
removed the box highlighting from elements like :kbd:`ctrl-c`.
This is because Sphinx for some reason converts this into

    <kbd>
        <kbd>ctrl</kbd>
        -
        <kbd>c</kbd>
    </kbd>

which results in duplicate boxes.
(See https://github.com/sphinx-doc/sphinx/issues/7530)

Our current style looks a bit ugly (it's
definitely worse than github's rendering at
https://github.com/fish-shell/fish-shell/blob/master/CHANGELOG.rst).
Let's restore the old style but make sure to only apply it only to the
outermost kbd element.

While at it, use the same monospace font as for inline code.
2024-09-28 18:00:02 +02:00
Johannes Altmanninger
4c43819d32 Fix crash indenting quoted suffix after command substitution
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
Commit b00899179 (Don't indent multi-line quoted strings; do indent inside
(), 2024-04-28) made parse_util_compute_indents() crash on `echo "$()"'x`.
After recursively indenting the command substitution, we indent the "'x
suffix.  We skip the quoted part by setting "done=2".  Later we wrongly
index "self.indents[done..range.start+offset+1]" (= "self.indents[2..1]").

Fix this by making sure that "start >= done", thus not setting any indents
for the quoted suffix.  There is no need to do so; only the first character
in each line needs an indent.
2024-09-28 13:36:17 +02:00
Johannes Altmanninger
50314e309b Follow naming convention 2024-09-28 13:35:07 +02:00
Johannes Altmanninger
d00e900e5a Don't reattempt failing history pager search
In particular, this fixes the case

    ctrl-r foo ctrl-r

where foo substring-matches no more than one page's worth of results.
The second attempt will fall back to subsequence matching which is wrong.
2024-09-28 11:28:49 +02:00
Johannes Altmanninger
ae7fd770ee Extract history pager state 2024-09-28 11:26:50 +02:00
Johannes Altmanninger
263f1b35de Reapply "Clear to eol before outputting line in multi-line prompt"
In case a terminal resize[1] causes us
to repaint a multi-line prompt that changes width like

    function fish_prompt
        for i in 1 2 3
            random choice 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 'bbbbbbbbbbb'
        end
    end

we add a clr_eol after each line[2] , to make sure
that a "b" line does not have leftover "a" letters
(80aaae5b7 (Clear to end of each line in left prompt, 2020-10-25)).

Unfortunately, if a prompt line takes up all the columns, clr_eol will
wrongly clear the last column. Reproduce with

    function fish_prompt
        string repeat $COLUMNS -
        echo "$PWD> "
    end

and observe that the last "-" is missing.

Previous (reverted) attempt d3ceba107 (Clear to eol before outputting line
in multi-line prompt, 2021-05-17) found the right fix but had an off-by-one
error which reintroduced the leftover "a" letters in the "random choice"
prompt above.

Given prompt string "aa\nbb\ncc", it wrongly printed

    clr_eol "aa" clr_eol "\nbb" "\ncc"

Observe that the first line is cleared twice, while the second line is
never cleared. Fix that.

[1]: or an async "commandline -f repaint" triggered by a uvar change /
     async prompt update
[2]: except after the last line where we probably already emit clr_eol
     elsewhere..

Alternative fix: emit both clr_eol and clr_bol *before* drawing the current
line. However, if fish and the terminal disagree on character width, that
approach might erase too much.

Closes #8164
2024-09-28 10:39:54 +02:00
Fabian Boehm
48a6550688 Remove obsolete workaround for strftime on BSD
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
This was added in libc 0.2.152, see aff5e66e54
2024-09-24 21:38:15 +02:00
Fabian Boehm
798150ac39 Update widecharwidth for Unicode 16
Commit 533e50efb0b9b122a08f2273337dbf6b44b03cc7 upstream.
2024-09-24 17:00:13 +02:00
Peter Ammon
4e8d6b1760
Improve the README of the printf crate 2024-09-23 11:16:42 -07:00
Johannes Altmanninger
308ed62d83 fish_key_reader: stop emitting \n for ctrl-j
I guess it's nice to know that these two are the same but that info is not
needed here, it just adds confusion. The user must have pressed ctrl-j if
we get here, so echo that back.

See the parent commit.
2024-09-23 20:08:46 +02:00
Johannes Altmanninger
4336f9df7f fish_key_reader: stop emitting \b for ctrl-h
This is just too confusing; \b sounds like it would map backspace but it's
actually just ctrl-h.  Backspace is a different key ("bind backspace"),
so let's move away from \b.

Reproduce by typing ctrl-h in fish_key_reader, or, for even more confusion,
use a terminal like tmux and type ctrl-backspace which also sends ctrl-h.

I've thought about changing \b (and its aliases like \ch and \x08) to mean
backspace but that seems like unnecessary breakage, since they all already
mean ctrl-h, and can usually be mapped independent of backspace.

See the discussion in #10738
2024-09-23 20:00:35 +02:00