Commit Graph

19593 Commits

Author SHA1 Message Date
Fabian Boehm
74e0436c3c Document installable builds 2024-12-06 22:12:26 +01:00
Fabian Boehm
3360dcbebc Make static builds on Github Actions
For x86_64 and cross-compiled for aarch64, manually triggered

It *seems* to work, but I had to explicitly disable gettext for it (which is AFAICT currently non-functional under musl anyway).

Also it will create one .zip containing two .tar.xzs. It is about 8MB, which should be fine, tbh.
2024-12-06 22:12:26 +01:00
Fabian Boehm
1599293796 Build man pages into installable fish
This calls sphinx-build from build.rs to include the man pages in the binary.

We don't abort if sphinx doesn't exist, but we do if it failed.
2024-12-06 22:12:26 +01:00
Fabian Boehm
2343a6b1f1 docs: Read version from the version file
Makes it possible to generate the man pages without fish_indent
available.

(not the html docs because they highlight via fish_indent!)
2024-12-06 22:12:26 +01:00
Fabian Boehm
7c73c5fec0 Make fish installable
When built with the default "installable" feature, the data files (share/) are
included in the fish binary itself.

Run `fish --install` or `fish --install=noconfirm` (for
non-interactive use) to install fish's data files into ~/.local/share/fish/install

To figure out if the data files are out of date, we write the current version
to a file on install, and read it on start.

CMake disables the default features so nothing changes for that, but this allows installing via `cargo install`,
and even making a static binary that you can then just upload and have extract itself.

We set $__fish_help_dir to empty for installable builds, because we do not have
a way to generate html docs (because we need fish_indent for highlighting).
The man pages are found via $__fish_data_dir/man
2024-12-06 22:12:26 +01:00
Fabian Boehm
7827a8e533 Make bin path an Option
It is possible we cannot acquire this
2024-12-06 22:12:26 +01:00
Fabian Boehm
aa30b4db4b Set crate version to 4.0.0-alpha1
The next version is gonna be 4.0.0
2024-12-06 22:12:26 +01:00
Fabian Boehm
378dc9123a git_version_gen: Just print the version
This was needed because we #included it in C++, but now it's easier to
have just the version in there
2024-12-06 22:12:26 +01:00
Fabian Boehm
5abd0e46f5 build.rs: Panic if version could not be found
We don't want "fish --version" to print "unknown" or any other fake version
2024-12-06 22:12:26 +01:00
Fabian Boehm
e24823dd6c Signals: Compute signal set once on startup
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
Really the only thing we're looking for here is if we're started with
HUP ignored or not.

Saves a syscall per external process.

Continuation of #10869
2024-12-04 20:18:16 +01:00
Ambrose Bonnaire-Sergeant
3012020af3
doc: expand &| reference to full example (#10885)
* doc: expand &| reference to full example

* feedback
2024-12-04 20:13:00 +01:00
Fabian Boehm
7b2cc9dca2 CI: Disable cargo-deny again
I am not a fan of CI tools that make the checks fail for reasons
unrelated to the patch at hand.
2024-12-04 18:42:20 +01:00
Himadri Bhattacharjee
d124c31958 refactor: remove unnecessary copied() for Utf32Str reference
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
Rust checks / cargo-deny (push) Has been cancelled
2024-12-02 19:12:39 +01:00
Fabian Boehm
b2e6609367 builtin random: Be less strict about arguments
This now allows:

- Same argument (`random 5 5`)
- Swapped ends (`random 10 2`)
- One possibility (`random 0 5 4`)

This makes it easier to use with numbers generated elsewhere instead
of hard-coded, so you don't need to check as much before running it.

Fixes #10879
2024-12-02 19:06:14 +01:00
Fabian Boehm
1cad9898d6 Refactor some more .unwrap/asserts
Some checks failed
make test / ubuntu (push) Has been cancelled
make test / ubuntu-32bit-static-pcre2 (push) Has been cancelled
Rust checks / rustfmt (push) Has been cancelled
Rust checks / clippy (push) Has been cancelled
Rust checks / cargo-deny (push) Has been cancelled
make test / ubuntu-asan (push) Has been cancelled
make test / macos (push) Has been cancelled
Lock threads / lock (push) Has been cancelled
No use in asserting and then unwrapping, just .expect()
2024-11-30 23:11:04 +01:00
Fabian Boehm
4859606e0c posix_spawn: Unconditionally default all signals (except HUP)
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
Rust checks / cargo-deny (push) Waiting to run
We don't really care if the process has a custom handler installed, we
can just set it to default.

The one we check is SIGHUP, which may be given to us via `nohup`.

This saves ~30 syscalls *per process* we spawn, so:

```fish
for f in (seq 1000)
    command true
end
```

has ~30000 fewer rt_sigaction calls. These take up about ~30% of the
total time spent in syscalls according to strace.

We could also compute this set once at startup and then reuse it.
2024-11-30 23:00:44 +01:00
Peter Ammon
5d10bc6a02
Fix/suppress some clippies
needless_lifetimes is annoying; supress that. Fix some spacing that clippy was
complaining about.
2024-11-30 12:21:30 -08:00
Fabian Boehm
eee44b7469 ulimit: Fix multiplication overflow 2024-11-30 15:40:48 +01:00
Fabian Boehm
8736d9b1e7 CI: Add cargo-deny
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
Rust checks / cargo-deny (push) Waiting to run
2024-11-29 18:17:11 +01:00
Fabian Boehm
f5e71063d7 Add cargo-deny configuration 2024-11-29 18:17:00 +01:00
Fabian Boehm
2d1ad1c3cc Mostly Revert "cmake: Remove code to resolve rustup toolchains"
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
Apparently needed on our FreeBSD CI setup.

This reverts commit 281df5daad.
2024-11-28 20:00:34 +01:00
Fabian Boehm
8b464d96af Remove reference to static mut
This is what UnsafeCell is for: Providing interior mutability.

The docs at https://doc.rust-lang.org/std/cell/struct.UnsafeCell.html
give an example just like this - `&mut *ptr.get()`

Without, rustc may complain - https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html
2024-11-28 19:36:50 +01:00
Fabian Boehm
281df5daad cmake: Remove code to resolve rustup toolchains
We turned it off, but for some reason (cmake version?) that stopped working on my system.

So instead we just remove all the code that does it.

To be honest I do not know why this exists anyway.
2024-11-27 22:29:13 +01:00
Johannes Altmanninger
3ed031c149 Update Kakoune completions
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-11-27 08:44:36 +01:00
Johannes Altmanninger
644171fac6 fix: check whether a function is tombstoned during highlight
exists_no_autoload() wrongly thinks that tombstoned functions can be
autoloaded; fix that.

While at-it replace the use of get_props() with something simpler.

Co-authored-by: Himadri Bhattacharjee

Closes #10873
2024-11-27 08:44:36 +01:00
Fabian Boehm
c625a324ba docs/string-trim: Double down on the set of chars vs string thing
Some checks failed
make test / ubuntu (push) Has been cancelled
make test / ubuntu-32bit-static-pcre2 (push) Has been cancelled
Rust checks / rustfmt (push) Has been cancelled
Rust checks / clippy (push) Has been cancelled
make test / ubuntu-asan (push) Has been cancelled
make test / macos (push) Has been cancelled
2024-11-25 17:53:14 +01:00
Fabian Boehm
4101bb30bf Remove unused variables
Never set since the introduction in 61686aff34
2024-11-25 16:29:00 +01:00
Johannes Altmanninger
b89619330b Disable terminal protocols before cancellable operations
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 [disambiguate flag](https://sw.kovidgoyal.net/kitty/keyboard-protocol/#disambiguate) means that:

> In particular, ctrl+c will no longer generate the SIGINT signal,
> but instead be delivered as a CSI u escape code.

so cancellation only works while we turn off disambiguation.

Today we turn it off while running external commands that want to
claim the TTY.  Also we do it (only as a workaround for this issue)
while expanding wildcards or while running builtin wait.

However there are other cases where we don't have a workaround,
like in trivial infinite loops or when opening a fifo.

Before we run "while true; end", we put the terminal back in ICANON
mode. This means it's line-buffered, so we won't be able to detect
if the user pressed ctrl-c.

Commit 8164855b7 (Disable terminal protocols throughout evaluation,
2024-04-02) had the right solution: simply disable terminal protocols
whenever we do computations that might take a long time.
eval_node() covers most of that; there are a few others.

As pointed out in #10494, the logic was fairly unsophisticated then:
it toggled terminal protocols many times.  The fix in 29f2da8d1
(Toggle terminal protocols lazily, 2024-05-16) went to the extreme
other end of only toggling protocols when absolutely necessary.

Back out part of that commit by toggling in eval_node() again,
fixing cancellation.  Fortunately, we can keep most of the benefits
of the lazy approach from 29f2da8d1: we toggle only 2 times instead
of 8 times for an empty prompt.

There are only two places left where we call signal_check_cancel()
without necessarily disabling the disambiguate flag
1. open_cloexec() we assume that the files we open outside eval_node()
   are never blocking fifos.
2. fire_delayed(). Judging by commit history, this check is not
   relevant for interactive sessions; we'll soon end up calling
   eval_node() anyway.

In future, we can leave bracketed paste, modifyOtherKeys and
application keypad mode turned on again, until we actually run an
external command.  We really only want to turn off the disambiguate
flag.

Since this is approach is overly complex, I plan to go with either
of these two alternatives in future:
- extend the kitty keyboard protocol to optionally support VINTR,
  VSTOP and friends.  Then we can drop most of these changes.
- poll stdin for ctrl-c. This promises a great simplification,
  because it implies that terminal ownership (term_steal/term_donate)
  will be perfectly synced with us enabling kitty keyboard protocol.
  This is because polling requires us to turn off ICANON.
  I started working on this change; I'm convinced it must work,
  but it's not finished yet. Note that this will also want to
  add stdin polling to builtin wait.

Closes #10864
2024-11-24 16:11:57 +01:00
Fabian Boehm
f0a5f8738b Silence clippy lints 2024-11-24 11:17:34 +01:00
Mahmoud Al-Qudsi
1347df898e Add ascii fast path for fish_wcswidth(&wstrw)
chars.all(|c| c.is_ascii()) is autovectorizable but this outperforms even when
it's not vectorized.
2024-11-22 21:35:39 -06:00
Mahmoud Al-Qudsi
2fd51355c3 Speed up wcscasecmp by approximately 30-40%
Moving the "make empty ToLowercase iterator" logic to within the
`unwrap_or_else()` instead of always generating it brings most of the speedup;
unrolling the recursive call brings in the rest.
2024-11-22 21:34:25 -06:00
Mahmoud Al-Qudsi
8c8da78cf8 Speed up get_case_fold() 5x
Using `c.is_uppercase()` instead of getting the iterator and checking if the
first (and only) lowercase letter of the sequence is the same as the original
input is 5-8x faster (measured via criterion against `/usr/share/dict/words`).

(Additional benefit of forcibly inlining the now iterator-based comparison not
taken into account; this necessitated changing from a closure to a local
function as the inline attribute on closures is not yet supported with the
stable compiler toolchain.)
2024-11-22 16:30:10 -06:00
Mahmoud Al-Qudsi
b949497bc1 Use idiomatic names for CaseSensitivity and ContainType 2024-11-22 16:28:33 -06:00
Mahmoud Al-Qudsi
b570c7f6a6 Reduce allocations when deduping completions in place
This is still suboptimal because we are allocating a vector of indices to be
removed (but allocation-free in the normal case of no duplicates) but
significantly better than the previous version of the code that duplicated the
strings (which are larger and spread out all over the heap).

The ideal code (similar to what we had in the C++ version, iirc) would look like
this, but it's not allowed because the borrow checker hates you:

```
fn unique_in_place_illegal(comps: &mut Vec<Completion>) {
    let mut seen = HashSet::with_capacity(comps.len());
    let mut idx = 0;
    while idx < comps.len() {
        if !seen.insert(&comps[idx].completion) {
            comps.remove(idx);
            continue;
        }
        idx += 1;
    }
}
```
2024-11-22 14:11:01 -06:00
Fabian Boehm
36c5ee045c fixup! filter control sequences 2024-11-21 21:20:35 +01:00
Fabian Boehm
2d07aa2686 tests: Move control sequences filtering to fish directly
This was an sh-script that just invoked fish again.

I can see how we could implement it in another language to avoid the
fish under test corrupting the results, but it literally invoked the
fish under test anyway.
2024-11-21 21:08:56 +01:00
Fabian Boehm
8dcde27e0b functions/history: Put back some checks for clear{,-session}
Mostly we pass on the options - otherwise they would be ignored.

For `clear`, we do need the full checks, because that will
prompt *before* running the builtin.

But this makes it easier to eventually move that logic into the builtin
2024-11-21 18:55:03 +01:00
Fabian Boehm
212dd6ec37 builtins/history: Use the enum nicer
Name it so it's not SHOUTY CASE, make a `panic!` unrepresentable

No functional change
2024-11-21 18:33:32 +01:00
Fabian Boehm
fcab68c591 docs/faq: Fix some broken keys 2024-11-21 18:28:43 +01:00
Fabian Boehm
6fe192606a functions/history: Set variables in function-scope explicitly
```fish
set -g LESS foo

history search bar
```

changes the global $LESS and exports it.
2024-11-21 18:27:10 +01:00
Fabian Boehm
11f11e27a1 functions/history: Remove unnecessary code
These things are all handled in the builtin
2024-11-21 18:26:47 +01:00
Kid
31b15405e9
Add completion for path basename -E/--no-extension (#10863) 2024-11-20 15:06:53 -06:00
Mahmoud Al-Qudsi
edd82be58d Fix crash on invalid CSI parameters
If a semicolon-delimited list of CSI parameters contained an (invalid) long
sequence of ascii numeric characters, the original code would keep multiplying
by ten and adding the most recent ones field until the `params[count][subcount]`
u32 value overflowed.

This was found via automated fuzz testing of the `try_readch()` routine against
a corpus of some proper/valid CSI escapes.
2024-11-20 15:01:34 -06:00
Mahmoud Al-Qudsi
b92830cb17 Change readch() into try_readch()
This lets us call into the entirety of the prior `readch()` with an exhaustible
input stream without panicking on the `unreachable!()` call. The previous
functionality is kept under the old name by calling `try_readch()` with the
`blocking` parameter set to `true` (100% same behavior as before).

While the `try_readch(false)` entrypoint isn't used directly by the current fish
codebase, it is required in order to automate input reader tests without the
overhead and complexity of running the test harness in a tty emulator emulator
like pexpect or tmux, which moreover necessitates out-of-process testing – which
is incompatible with most perf-guided testing harnesses.

I hope to be able to upstream harness integrations using this entry point in the
near future.
2024-11-20 14:53:07 -06:00
Fabian Boehm
b3108c0cee CHANGELOG 2024-11-19 21:12:44 +01:00
Fabian Boehm
7a667b4f6d Add basic completions for firejail
These are pretty basic, but get us roughly up to the level of the
official completions (that are also incomplete and offer disabled
options).

Fixes #10858
2024-11-18 16:16:07 +01:00
Peter Ammon
c4bc6b6f09
Clean up print_help
`print_help` is a hacky-wacky function used to support the `--help` command
of `fish_key_reader` and others. The Rust version panics on an error; fix
that and make it print more useful help messages.
2024-11-17 17:03:34 -08:00
Unbelievable Mystery
262e2d5fe6
Update completions for: wine (#10789)
* feat(function): move cmd completion function to a separate file

* feat(completion): support wine cmd subcommand

* feat(completion): support wine control subcommand

* feat(completion): support wine eject subcommand

* feat(completion): support wine explorer subcommand

* feat(completion): support wine explorer subcommand for desktops

* feat(completion): support wine start subcommand

* feat(completion): support wine winemenubuilder subcommand

* feat(completion): support wine winepath subcommand

* fix(function): rename function for cmd argument completion

* feat(function): implement function to complete registry keys

* feat(completion): support wine regedit subcommand

* feat(function): add top-level key descriptions

* fix(completion): remove redundant comment

* feat(completion): support wine msiexec subcommand

* refactor(completion): group code into functions

* feat(completion): enhance subcommand descriptions
2024-11-17 14:58:21 -08:00
Unbelievable Mystery
93aa5a9376
Add completions for: guile, guild (#10792)
* feat(completion): support guile command

* feat(completion): support guild command

* feat(completion): support guild subcommand

* feat(completion): squeeze code
2024-11-17 14:08:19 -08:00
Peter Ammon
642eff9e1f
Fix some clippies and remove some dead code 2024-11-17 12:37:45 -08:00