Compare commits

...

727 Commits

Author SHA1 Message Date
Johannes Altmanninger
a2c5b2a567 Release 4.3.1
Created by ./build_tools/release.sh 4.3.1
2025-12-28 16:54:44 +01:00
Johannes Altmanninger
18295f4402 Fix icase prefix/suffix checks
Commit 30942e16dc (Fix prefix/suffix icase comparisons, 2025-12-27)
incorrectly treated "gs " as prefix of "gs" which causes a crash
immediately after expanding that abbreviation iff "gs" is our
autosuggestion (i.e. there's no history autosuggestion taking
precedence).

Fixes #12223
2025-12-28 16:54:34 +01:00
Johannes Altmanninger
443fd604cc build_tools/release.sh: don't add dch entry for snapshot version 2025-12-28 10:55:09 +01:00
Johannes Altmanninger
9e022ff7cf build_tools/release.sh: fix undefined variable for next milestone 2025-12-28 10:52:20 +01:00
Johannes Altmanninger
aba927054f start new cycle
Created by ./build_tools/release.sh 4.3.0
2025-12-28 10:45:34 +01:00
Johannes Altmanninger
bdfc491d56 Release 4.3.0
Created by ./build_tools/release.sh 4.3.0
2025-12-28 10:20:47 +01:00
Johannes Altmanninger
b72127a0b7 build_tools/release-notes.sh: fix RST syntax 2025-12-28 10:03:08 +01:00
Johannes Altmanninger
0ab2a46424 build_tools/release.sh: docs have been removed from tarball
See 135fc73191 (Remove man/HTML docs from tarball, require Sphinx
instead, 2025-11-20).
2025-12-28 10:03:08 +01:00
Johannes Altmanninger
5844650881 Set color theme eagerly again
Now that the default theme no longer contains light/dark sections,
we don't need to wait for $fish_terminal_color_theme to be initialized
before setting it.

Let's set it before loading user config to allow users to do things
like "set -e fish_color_command" in their config.

Fixes #12209
2025-12-28 09:06:16 +01:00
Johannes Altmanninger
3c77a67668 uvar migration: remove extra message if there were no color uvars 2025-12-28 09:06:16 +01:00
Johannes Altmanninger
3105f88622 fish_config choose/save: improve docs 2025-12-28 09:06:16 +01:00
Johannes Altmanninger
5702b26b22 fish_config theme choose: don't add redundant hook
If we're overriding the theme with --color-theme=, we don't need to
register the hook because $fish_terminal_color_theme will be ignored.

Also if the theme is not color-theme aware, there is no need to
register the hook.
2025-12-27 17:28:20 +01:00
Johannes Altmanninger
60ef7ca210 test_complete: improve assertion to track down intermittent failure
The result vector sometimes has three instead of two elements.
See #12184
2025-12-27 13:10:36 +01:00
Johannes Altmanninger
c486c54120 fish_config theme choose: use captured data 2025-12-27 13:10:36 +01:00
Johannes Altmanninger
6273b9420b fish_config theme choose: capture theme by copy
We don't listen for changes to the theme file, so this seems more
appropriate and more robust.
2025-12-27 13:10:36 +01:00
Johannes Altmanninger
4bb0d956eb themes/default: revert to palette colors for now
The readability concern in ed881bcdd8 (Make default theme use named
colors only, 2023-07-25) was no longer relevant, but people might
prefer we use terminal colors by default, because other apps do too,
and because it's a well-known way to make colors look good across
both dark and light mode.

If we revert this, we should make sure fish_default_mode_prompt.fish
and prompt_login.fish also use RGB colors
2025-12-27 12:57:08 +01:00
Nikita COEUR
92db03ac9f feat: aquaproj/aqua completion support
Closes #12213
2025-12-27 12:19:24 +01:00
xtqqczze
0d6aaa36d3 Use mem::take
Closes #12217
2025-12-27 12:19:24 +01:00
Johannes Altmanninger
88a7888478 postfork: remove dead code checking setpgid() error 2025-12-27 12:19:24 +01:00
Nahor
74cb96d55b fd_monitor: add missing EAGAIN check
poll()/select() can return EAGAIN on some systems, which should be
treated like a EINTR according to the man page

Closes #12211
2025-12-27 12:19:24 +01:00
Johannes Altmanninger
30942e16dc Fix prefix/suffix icase comparisons
As reported on Gitter, running "echo İ" makes history autosuggestion
for "echo i" crash.  This is because history search correctly
returns the former, but string_prefixes_string_case_insensitive("i",
"İ") incorrectly returns false.  This is because the prefix check
is implemented by trimming the rhs to the length of the prefix and
checking if the result is equal to the prefix.  This is wrong because
the prefix computation should operate on the canonical lowercase
version, because that's what history search uses.
2025-12-27 12:19:24 +01:00
Johannes Altmanninger
a8ded9cb0d Separate wcscasecmp() concerns better 2025-12-27 09:28:01 +01:00
Johannes Altmanninger
4d67678217 changelog: update, clarify color variable fallback
Do a pass over the changelog and clarify the entry on the breaking
change that sparked #12209.
2025-12-26 18:10:47 +01:00
Johannes Altmanninger
9460559345 fish_config theme save: don't add --theme=$theme marker nor react to colortheme
The theme marker is set by "fish_config theme choose" to allow
us to react to terminal color theme changes, and to tell future
"fish_config theme choose" invocations which variables it should erase
-- it should not erase color variables not set in the theme file,
like Git prompt colors.

I'm not sure if either really makes sense for "fish_config theme save".
Reacting to terminal color theme changes is weird for universals.

I'm not sure if "fish_config theme save" should erase universal
variables that are not defined in the theme.  Historically, it did
so for a hardcoded list of colors, which is hacky. For now let's
err on the side of leaving around color variables.

The "save" subcommand is deprecated; it's possible that this changes
in future (and we add support for "--theme" to it) but I'm not sure
if we have enough need for that.
2025-12-26 18:10:47 +01:00
Johannes Altmanninger
74af4f10de uvar migration: tell users to restart running sessions
Users who run the default theme are silently migrated to global
variables. Universal color variables are deleted, leaving existing
sessions uncolored. Tell the user to restart them, and make some
other improvements; now it looks like:

	fish: upgraded to version 4.3:
	* Color variables are no longer set in universal scope.
	  To restore syntax highlighting in other fish sessions, please restart them.
	* The fish_key_bindings variable is no longer set in universal scope by default.
	  Migrated it to a global variable set in  ~/.config/fish/conf.d/fish_frozen_key_bindings.fish

Same for users who do not use the default theme (who already got a
message before this change). For them, the first bullet point looks
like this:

	[...]
	* Color variables are no longer set in universal scope by default.
	  Migrated them to global variables set in ~/.config/fish/conf.d/fish_frozen_theme.fish
	  To restore syntax highlighting in other fish sessions, please restart them.
	[...]

Closes #12161
2025-12-26 18:10:47 +01:00
Johannes Altmanninger
b2f4befc7e themes: don't define option/keyword colors redundantly
These fall back to param/command roles, so there's no need to
duplicate the value.

Make sure the "set fish_color_o<TAB>" still works if they're not
defined.

Leave it as a comment in theme files I guess, since users copy-pasting
a theme might reasonably want to set it.

Closes #12209
2025-12-26 18:09:15 +01:00
xtqqczze
771b33b3a3 Use Option<OwnedFd> instead of AutoCloseFd
Closes #12199
2025-12-26 18:09:15 +01:00
Johannes Altmanninger
1cf4e191b3 docs syntax-highlighting: show how to restore default theme 2025-12-26 18:09:15 +01:00
Johannes Altmanninger
b88a5eaad5 Allow tracing bindings, event handlers etc. with fish_trace=all
Might have helped with cases like #12209 where an event handler stomps
user preferences.
2025-12-26 18:09:15 +01:00
Johannes Altmanninger
1c1baddf4f docs: one sentence per line 2025-12-26 07:56:52 +01:00
Daniel Rainer
107cbaddf0 strings: take IntoCharIter instead of wstr
Change the input of some functions to take `impl IntoCharIter`, allowing
them to accept more input. Implementing this efficiently means that no
owned types should be passed into these functions, because their
`IntoCharIter` implementation would require unnecessary allocations.
Instead, convert the uses which previously passed `WString` by prefixing
an `&`, so the borrowed `&WString` is passed instead.

To allow for wider use of the modified functions, `IntoCharIter`
implementations are added for `&String`, `&Cow<str>`, and `&Cow<wstr>`.

Closes #12207
2025-12-25 21:52:42 +00:00
Denys Zhak
daa554123f fish_indent: Keep braces on same line after conjunctions, time, not
Closes #12144
2025-12-25 15:22:53 +01:00
Johannes Altmanninger
979320063e readme: remove stale MAC_CODESIGN_ID
Removed in 9edd0cf8ee (Remove some now unused CMake bits, 2024-07-07).
The replacements are not documented in prose but in the GitHub
release workflow.
2025-12-25 15:22:52 +01:00
Johannes Altmanninger
fed0269762 Tweak language in "status language" output
Ref: https://github.com/fish-shell/fish-shell/pull/12106#discussion_r2636320834
2025-12-25 15:22:52 +01:00
Johannes Altmanninger
6d68dfe12b doc terminal-compatibility: clarify 2025-12-25 15:22:52 +01:00
Johannes Altmanninger
97c59fa991 doc terminal-compatibility: fix formatting error 2025-12-25 15:22:52 +01:00
Johannes Altmanninger
128fafce1e uvar migration: improve output on accidental early exit
fish_job_summary shows this as "$sh -c ...".  Make it "/bin/sh -c ...".
2025-12-25 15:22:52 +01:00
Johannes Altmanninger
f1c8e6995d On process exit, read output into buffer to fix ordering
This command

	echo $(/bin/echo -n 1; echo -n 2)

sometimes outputs "21" because we implement this as

	let bufferfill = IoBufferfill::create_opts(...);
	...
	let eval_res = parser.eval_with(...);
	let buffer = IoBufferfill::finish(bufferfill);

i.e. /bin/echo and builtin echo both output to the same buffer; the
builtin does inside parser.eval_with(), and the external process may
or may not output before that, depending on when the FD monitor thread
gets scheduled (to run item_callback).

(Unrelated to that we make sure to consume all available input in
"IoBufferfill::finish(bufferfill)" but that doesn't help with
ordering.)

Fix this by reading all available data from stdout after the child
process has exited.

This means we need to pass the BufferFill down to
process_mark_finished_children().

We don't need to do this for builtins like "fg" or "wait",
because commands that buffer output do not get job control, see
2ca66cff53 (Disable job control inside command substitutions,
2021-07-26).
We also don't need to do it when reaping from reader because there
should be no buffering(?).

fish still deviates from other shells in that it doesn't wait for
it's child's stdout to be closed, meaning that this will behave
non-deterministically.

	fish -c '
	    echo -n $(
	        sh -c " ( for i in \$(seq 10000); do printf .; done ) & "
	    )
	' | wc -c

We should fix that later.

Closes #12018
2025-12-25 14:35:54 +01:00
Daniel Rainer
02061be279 io: allow unescape+write of str
The existing functionality of converting a `&wstr` to bytes (unescaping
PUA codepoints) and writing these to a file descriptor can be reused for
Rust's built-in strings by making the input type generic. This is
simple, because the only functionality we need is converting the input
into a `char` iterator, which is available for both types.

While at it, rename the functions to have more accurate and informative
names.

Closes #12206
2025-12-25 01:48:02 +00:00
Daniel Rainer
c9b30b748d cleanup: remove duplicate functions
Closes #12205
2025-12-25 01:10:36 +00:00
Daniel Rainer
167cfd0892 gettext-extraction: fix outdated docs
Closes #12204
2025-12-24 01:01:47 +00:00
Daniel Rainer
5c3941f0dd check.sh: rename template to gettext template
This is done in preparation for a second temporary directory used for
Fluent ID extraction.

Closes #12203
2025-12-24 00:47:01 +00:00
Daniel Rainer
d4745b633b check.sh: don't build docs of dependencies
We only run `cargo doc` here to check for issues with fish's
documentation, so there is no need to build docs of dependencies.

Closes #12201
2025-12-24 00:21:41 +00:00
Fabian Boehm
dd97842964 completions/rustc: Don't autoinstall nightly toolchain
Just calling `rustc +nightly` is enough to trigger automatic
installation.

Fixes #12202
2025-12-23 19:49:42 +01:00
Peter Ammon
5715d143a5 Fix some clipplies 2025-12-23 08:44:10 -08:00
Peter Ammon
41571dec0f Minor simplification of history 2025-12-23 08:34:36 -08:00
Nahor
3c7517bf28 tests: disable tmux tests on Cygwin/MSYS
Those tests are unreliable and sometimes even block forever on
Cygwin/MSYS.
2025-12-21 12:21:25 +01:00
Nahor
81fce66269 test_driver: flush output after each test
When the output is redirected, Python buffer its whole output, unlike
a TTY output where only lines are buffered.
In GitHub actions in particular, it means that we can't see any progress
after each test. And if a test blocks forever, there is no output at all.

So flush the output after printing each result to see the progress
being made
2025-12-21 12:21:25 +01:00
Nahor
7b8f97c1ff Run fish_indent on select test scripts
Run fish_indent on test scripts that will be modified in a later
commit

Not running it on all the files because a quarter of them need fixing,
some of which are badly formatted on purpose
2025-12-21 12:21:25 +01:00
Daniel Rainer
9b75b6ee88 l10n: move po/ to localization/po/
This is done in preparation for Fluent's FTL files, which will be placed
in `localization/fluent/`. Having a shared parent reduces top-level
clutter in the repo and makes it easier to find the localization files
for translators, including realizing that both PO and FTL files exist.

We keep PO and FTL files in separate directories because we need to
rebuild on any changes in the PO directory (technically only when there
are changes to `*.po` files, but due to technical limitations we can't
reliably trigger rebuilds only if those changes but not other files in
the same directory.) Changes to FTL files do not require rebuilds for
dev builds, since for these `rust-embed` does not actually embed them
into the binary but rather loads them from the file system at runtime.

Closes #12193
2025-12-21 12:11:49 +01:00
Branch Vincent
1ebf750bc0 completions: add docker
The upstream completions have not been updated for some time, but the
docker binary can generate completions. These include dynamic
completions for image names and so on.

Closes #12197.
2025-12-21 12:57:06 +08:00
Daniel Rainer
dcd07d754d l10n: move wutil/gettext to localization module
Localization deserves its own module. As a first step, this module is
created here. This will be followed up by significant refactoring in
preparation for supporting Fluent alongside gettext.

`localization/mod.rs` is used instead of `localization.rs` because it is
planned to split this module into submodules.

Part of #12190
2025-12-19 19:37:11 +01:00
Johannes Altmanninger
26873d4ad2 Use cfg_if expression syntax to fix let-and-return 2025-12-19 19:37:11 +01:00
Daniel Rainer
17c35217b9 lints: warn on needless_return
The needless_return lint was disabled almost two years ago, alongside
several other lints. It might have been helpful for porting from C++.
Now, I think we can enable that lint again, since omitting the returns
results in equivalent, more concise code, which should not be harder to
read.

The only manual changes in this commit are removing the lint exception
from `Cargo.toml` and removing the unnecessary returns inside `cfg_if!`
macro invocations (in `src/fd_monitor.rs` and `src/proc.rs`).
All other changes were generated by
`cargo clippy --workspace --all-targets --fix && cargo fmt`

Closes #12189
2025-12-19 19:37:11 +01:00
Daniel Rainer
b62a312cba rename: crate::wchar::prelude -> crate::prelude
Having the prelude in wchar is not great. The wchar module was empty
except for the prelude, and its prelude included things from wutil.

Having a top-level prelude module in the main crate resolves this. It
allows us to completely remove the wchar module, and a top-level prelude
module makes more sense conceptually. Putting non-wchar things into the
prelude also becomes more sensible, if we ever want to do that.

Closes #12182
2025-12-19 19:37:11 +01:00
xtqqczze
3b976a3364 clippy: fix map_unwrap_or lint
https://rust-lang.github.io/rust-clippy/master/index.html#map_unwrap_or

Closes #12188
2025-12-19 19:37:11 +01:00
Asuka Minato
3df88597ca add git shortlog completion
Closes #12186
2025-12-19 19:37:11 +01:00
Johannes Altmanninger
3ec603fc55 Send OSC 7 on fresh prompt (child may have changed it)
After I run a child process like "fish -C 'cd /tmp'", the terminal
will have a stale working directory.

Let's send the OSC 7 notification also once for every fresh prompt
(which is less frequent than the calls to fish_prompt).

This is not fully correct, since it will not work for cases like bind
ctrl-g 'fish -C "cd /tmp"' which allow running external commands
without creating a fresh prompt. We can fix those later, using the
code paths for bracketed paste and friends.
A minor argument for not fixing this just yet is that some people
override "__fish_update_cwd_osc" to work around bugs in their terminal.

Closes #12191
Closes #11778
Closes #11777
2025-12-19 19:36:51 +01:00
Johannes Altmanninger
5545c648d9 builtin read: don't enable TTY protocols while echo is off
When I run "read" and press enter on the foot terminal, I see a "^[[I"
echoed in the TTY.  This is because

1. builtin read creates a TtyHandoff and runs enable_tty_protocols()
2. it runs Reader::readline(), which creates another TtyHandoff.
3. before Reader::readline() returns, it unsets shell modes
   (turning ECHO back on). It also drops its TtyHandoff,
   which enables TTY protocols again.
4. Enabling focus reporting causes this terminal to send
   focus-in event immediately.

This is our fault; we should not have TTY protocols enabled while
ECHO is on.

Fix this by removing the first TtyHandoff (which seems redundant),
meaning that the second one will not try to re-enable protocols.
2025-12-19 19:13:21 +01:00
Johannes Altmanninger
765305d0e4 tty_handoff: remove stale comment
Fixes 1fe5497b5d (Remove redundant saving of TTY flags, 2025-12-14).
2025-12-19 19:13:21 +01:00
Johannes Altmanninger
a261ca2aff Reapply "Refactor common::is_console_session"
This reverts commit 556be5c4a8.

See #12192
2025-12-19 19:13:21 +01:00
Fabian Boehm
556be5c4a8 Revert "Refactor common::is_console_session"
Breaks the build on OpenBSD.

This is another case of a nix feature being unavailable on some platforms,
so start documenting them.

This reverts commit d6108e5bc0.

Fixes #12192
2025-12-19 17:36:47 +01:00
Daniel Rainer
92c5da1b25 contributing: add section about commit history
Adding this info here should hopefully reduce the number of instances
where we need to tell new contributors about it in pull requests.

Closes #12162
2025-12-18 22:22:26 +00:00
Fabian Boehm
fb161e9f4d Fix error squiggles when they run into a newline
Our error marking code:

```
function foobar
^~~~~~~^
```

runs fish_wcswidth to figure out how wide the squiggly line should be.

That function returns -1 when it runs into a codepoint that wcwidth
returns -1 for, so the marking would stop at a single `^`.

In some cases, this happens because the error range includes a
newline.

Since we already find the end of the line, and can only mark one line,
we clamp the squiggles at the end of that line.

This improves some markings.

See discussion in #12171
2025-12-18 17:56:04 +01:00
Daniel Rainer
67d78fb258 fallback: extract into crate
For faster incremental builds and to enable subsequent extraction.

Closes #12183
2025-12-18 15:13:50 +01:00
Daniel Rainer
caef2c309d build: extract some OS detection into build helper
A subsequent commit will need to test for cygwin in a new crate. On
current stable Rust (1.92) this works via `#[cfg(target_os = "cygwin)]`,
but our MSRV (1.85) does not support this. To avoid code duplication,
the OS detection logic is extracted into the build helper crate. For
now, only `detect_cygwin` is needed, but it would be inconsistent to
extract that but not the same functions for other operating systems.

Part of #12183
2025-12-18 15:13:50 +01:00
Daniel Rainer
2f37eda9d9 wchar: extract logic into separate crate
Another reduction in size of the main crate. Also allows other crates to
depend on the new wchar crate.

The original `src/wchar.rs` file is kept around for now to keep the
prelude imports working.

Part of #12182
2025-12-18 15:13:50 +01:00
Daniel Rainer
5a35acf2e7 crate splitting: create fish-common crate
Dependencies between crates must form a DAG. This means that breaking up
the large library crate requires breaking dependency cycles. The goal of
this commit is creating a crate which contains some of the main crate's
functionality, without depending on the main crate.

To start off, we only move things required for extracting `src/wchar.rs`
and `src/wchar_ext.rs`, which will happen in a subsequent commit.

Part of #12182
2025-12-18 15:13:50 +01:00
phanium
e1a6b7ea5a Support BEL terminator in OSC responses
Needed for NeoVim's :terminal.
Upstream tracking issue: https://github.com/neovim/neovim/issues/37018

Closes #12185
2025-12-18 15:13:50 +01:00
Daniel Rainer
c9fcd31480 widecharwidth: extract into separate crate
This should help with improving incremental build speed. Extracting this
code is easy, since it does not have dependencies. It also unblocks
further extraction of code which depends on widecharwidth.

Closes #12181
2025-12-18 15:13:50 +01:00
xtqqczze
d6108e5bc0 Refactor common::is_console_session
- Use nix::unistd::ttyname
- Simplify logic with pattern matching

Closes #12179
2025-12-18 15:13:50 +01:00
Johannes Altmanninger
2611646232 commandline --cursor: respect transient command line
We have logic to prevent "commandline --cursor 123" inside "complete
-C" from setting the transient commandline's cursor.

But reading this cursor ("commandline --cursor")
is fine and expected to work by completion scripts.

I don't expect there is a use case for setting the cursor while
computing completions, so let's make that an error for now.
Could revisit that.

Closes #11993
2025-12-18 15:13:50 +01:00
Johannes Altmanninger
08600d012f tests/complete: don't remove $PWD
This test removes $PWD which would cause an error if it were to start
a new process.  Normaly we would "cd -" before the removal but later
assertions expect an empty $PWD, so stay there, but don't remove it
to prevent possible surprise.
2025-12-18 15:04:06 +01:00
Johannes Altmanninger
16f14f0e89 test_wwrite_to_fd: test take random bytes, not chars
This function is not passed arbitrary chars.  The only exception is
builtin printf, which we should fix (see parent commit).  Pass random
bytes instead.
2025-12-18 15:04:06 +01:00
Johannes Altmanninger
50bcc3cf4f Isolate hack for skipping internal separator
stage_wildcards has no need for INTERNAL_SEPARATOR. Remove it already
at this stage, to avoid the need to have the workaround in the generic
decoding routine.

Unfortunately we still can't add assert!(!fish_reserved_codepoint(c));
to wcs2bytes_callback, since builtin printf still passes arbitrary
characters. We should fix that later.

Test that printf now behaves correctly for INTERNAL_SEPARATOR.
Also add a regression test for 0c9b73e317.
2025-12-18 15:04:06 +01:00
Johannes Altmanninger
ee2d99ecf3 Fix crash on kitty when clicking in scrolled command line
When the command line occupies the whole screen such that no prompt
line is shown, we crash due to overflow. Fix that.

Fixes #12178
2025-12-18 15:04:06 +01:00
Johannes Altmanninger
81e1f6937f Address some non_upper_case_globals lints 2025-12-18 15:04:06 +01:00
Johannes Altmanninger
03a3a3b52f Silence non_upper_case_globals for log categories
For some reason r-a shows this diagnostic even though we suppress it
in Cargo.toml (I still need to create a bug report).

Making these upper case would be noisy at the call sites, and it
probably doesn't help since we don't think of these identifiers
as global variables (we never access their fields directly).
Silence the r-a warning for now.

See #12156
2025-12-18 15:04:06 +01:00
Daniel Rainer
074ab45049 gettext: move gettext_impl into dedicated crate
This is part of the larger effort of splitting up fish's huge main crate
to improve incremental build speed.

We could extract more logic from `src/wutil/gettext.rs` into the new
crate, but this would require putting wide-string handling into that
crate, which I'm not sure we want. Doing so would have the advantage
that crates which don't depend on fish's main crate (i.e. all crates
other than fish's main crate itself and the binary crates built on top
of it) could then localize messages as well. This will be less relevant
if we replace gettext with Fluent for messages originating from the Rust
sources.

Closes #12108
2025-12-18 15:04:06 +01:00
Daniel Rainer
aa8f5fc77e l10n: implement status language builtin
Based on the discussion in
https://github.com/fish-shell/fish-shell/pull/11967

Introduce a `status language` builtin, which has subcommands for
controlling and inspecting fish's message localization status.

The motivation for this is that using only the established environment
variables `LANGUAGE`, `LC_ALL`, `LC_MESSAGES`, and `LANG` can cause
problems when fish interprets them differently from GNU gettext.
In addition, these are not well-suited for users who want to override
their normal localization settings only for fish, since fish would
propagate the values of these variables to its child processes.

Configuration via these variables still works as before, but now there
is the `status language set` command, which allows overriding the
localization configuration.
If `status language set` is used, the language precedence list will be
taken from its remaining arguments.
Warnings will be shown for invalid arguments.
Once this command was used, the localization related environment
variables are ignored.
To go back to taking the configuration from the environment variables
after `status language set` was executed, users can run `status language
unset`.

Running `status language` without arguments shows information about the
current message localization status, allowing users to better understand
how their settings are interpreted by fish.

The `status language list-available` command shows which languages are
available to choose from, which is used for completions.

This commit eliminates dependencies from the `gettext_impl` module to
code in fish's main crate, allowing for extraction of this module into
its own crate in a future commit.

Closes #12106
2025-12-18 15:04:06 +01:00
Johannes Altmanninger
c0b95a0ee1 readme: fix macOS version requirement 2025-12-17 17:59:24 +01:00
Daniel Rainer
dd93a7e003 test_driver: stop printing tmpdir on failure
We delete the tmpdir unconditionally once all tests are completed, so
there is no point in printing a path which will no longer exist when
analyzing test failures. The paths don't contain any useful information,
so let's delete them to avoid confusion and useless output.
2025-12-17 16:58:07 +01:00
Daniel Rainer
8064a13af9 test_driver: print littlecheck errors after result
Before this, our test driver printed littlecheck's output before the
test result (test name, duration, PASSED/FAILED/SKIPPED).
This makes it harder to read the output and is inconsistent with the way
pexpect test failures are shown.

Starting with this commit, the result is printed first for both test
types, followed by details about failures, if any.
2025-12-17 16:58:07 +01:00
Fabian Boehm
ab7b522b64 tests/tmux: Unset CDPATH
This would fail in tmux_complete
2025-12-17 16:55:58 +01:00
Fabian Boehm
0c9b73e317 Restore ~$foo expansion
This reverts commit 52ea511768 ("cleanup: remove useless `INTERNAL_SEPARATOR` handling").

I don't know how to test this given that we don't know what users exist (maybe "root"?).

Fixes #12175
2025-12-17 16:52:57 +01:00
David Adam
b29a85f45f fish.spec: clean up dependencies 2025-12-17 10:32:20 +08:00
David Adam
f0b4921ccf Fix export test on openSUSE
openSUSE defines a MANPATHSET variable, so make the match a bit tighter
2025-12-17 10:27:24 +08:00
Fabian Boehm
1d3aca2b44 fish_vi_key_bindings: Stop using alias
`alias` is terrible, but the main downside of this is that it shows up
in the output of `alias`, which it shouldn't because the user didn't
define these.
2025-12-16 20:27:47 +01:00
Fabian Boehm
574a8728af cmake: Stop setting RUSTFLAGS
This appends "-g" to RUSTFLAGS if the cmake build type is debug or
RelWithDebInfo.

However, these are already mapped to cargo profiles that enable these
things, see https://doc.rust-lang.org/cargo/reference/profiles.html:

> The debug setting controls the -C debuginfo flag which controls the
amount of debug information included in the compiled binary.

(`rustc -g` is equivalent to `debuginfo=2`)

By setting $RUSTFLAGS in cmake, we bake it into the generated
makefile (/ninja thing), which is surprising.

See #12165
2025-12-16 16:52:25 +01:00
Johannes Altmanninger
e7c1a6a67d Fix build on macOS 2025-12-16 15:36:25 +01:00
David Adam
54127e1028 CMake: stop trying to install groff macros
Dropped in 377abde112.
2025-12-16 22:31:48 +08:00
David Adam
a5330c7ba2 RPM/Debian packaging: add sphinx and man dependencies 2025-12-16 21:49:28 +08:00
David Adam
377abde112 drop obsolete groff macros 2025-12-16 21:43:16 +08:00
Johannes Altmanninger
62628f6fb1 CI: respect dependency cooldown in "uv lock check"
Fixes 1db4dc4c3e (build_tools/update-dependencies.sh: add dependency
cooldown for Python packages, 2025-12-16).
2025-12-16 14:22:24 +01:00
Johannes Altmanninger
64da7ca124 Run build_tools/update-dependencies.sh
Still need to upgrade Cargo deps.
2025-12-16 13:25:27 +01:00
Johannes Altmanninger
1db4dc4c3e build_tools/update-dependencies.sh: add dependency cooldown for Python packages
See
https://blog.yossarian.net/2025/11/21/We-should-all-be-using-dependency-cooldowns
2025-12-16 13:19:16 +01:00
Johannes Altmanninger
ebc140a3ea Hack path component movement to skip escaped spaces
Path component movement is not aware of fish syntax -- and we should
be careful as we teach it some fish syntax, because it is expected
to be used on command lines that have unclosed quotes etc.

Tab completion typically uses backslashes to escape paths with spaces.
Using ctrl-w on such path components doesn't work well because it
stops at the escaped space.

Add a quick hack to change it to skip over backslashed spaces.  Note that
this isn't fully correct because it will treat backslashes inside
quotes the same way.  Not sure what we should do here.  We could have
ctrl-w erase all of this

	"this is"'only\ one 'path component

But that might be surprising.
Regardless of what we end up with, skipping over backslashed whitespace
seems totally fine, so add that now

Closes #2016
2025-12-16 13:16:20 +01:00
Johannes Altmanninger
5e401fc6ea tokenizer test: slim down macro 2025-12-16 13:16:20 +01:00
ELginas
608269320e Added backward-path-component, forward-path-component and kill-path-component
Closes issue #12127

Closes #12147
2025-12-16 13:16:20 +01:00
Johannes Altmanninger
c3a9edceac Truncate autosuggestion lines only at screen edge
From each logical line in the autosuggestion, we show all or nothing.
This means that we may truncate too early -- specifically 1  + the
number of soft-wrappings in this line. Fix that.

See also #12153
2025-12-16 13:16:20 +01:00
Johannes Altmanninger
32cee9caec screen: remove obsolete type 2025-12-16 13:16:20 +01:00
Asuka Minato
f417cbc981 Show soft-wrapped portions in autosuggestions
Co-authored-by: Johannes Altmanninger <aclopte@gmail.com>

Closes #12153
2025-12-16 13:16:20 +01:00
Johannes Altmanninger
92c814841a Work around clippy assertions_on_constants false positive
Upstream issue: https://github.com/rust-lang/rust-clippy/issues/16242

Closes #12159
2025-12-16 13:04:43 +01:00
Toyosatomimi no Miko
bf38e1beca Rename FLOG, FLOGF, to lowercase flog, flogf
Closes #12156
2025-12-16 13:04:43 +01:00
Toyosatomimi no Miko
17ba602acf Use PascalCase for Enums
Part of #12156
2025-12-16 13:04:43 +01:00
チセ
5d37698ef8 fix: __fish_systemctl_services mode handling
Closes #12157
2025-12-16 13:04:16 +01:00
Johannes Altmanninger
7a7c0d6490 __fish_systemctl_services: remove code clone 2025-12-16 13:04:16 +01:00
Johannes Altmanninger
d88c0674a3 __fish_systemctl_services: early return 2025-12-16 13:04:16 +01:00
Johannes Altmanninger
0306ec673f __fish_systemctl_services: remove unused argument 2025-12-16 13:04:16 +01:00
Nahor
b14b6c9f42 fish_git_prompt: fix incorrect variable assignment
The intent was to create two local variables, not to assign one's name
to the other
2025-12-16 08:00:24 +01:00
Fabian Boehm
8061c41c9b docs/math: Clarify what it is for
See #12163
2025-12-15 19:23:01 +01:00
Johannes Altmanninger
190d367bc4 Use globals for color variables, react to light/dark mode
Implicitly-universal variables have some downsides:
- It's surprising that "set fish_color_normal ..."
  and "set fish_key_bindings fish_vi_key_bindings" propagate to other
  shells and persist, especially since all other variables (and other
  shells) would use the global scope.
- they don't play well with tracking configuration in Git.
- we don't know how to roll out updates to the default theme (which is
  problematic since can look bad depending on terminal background
  color scheme).

It's sort of possible to use only globals and unset universal variables
(because fish only sets them at first startup), but that requires
knowledge of fish internals; I don't think many people do that.

So:
- Set all color variables that are not already set as globals.
  - To enable this do the following, once, after upgrading:
    copy any existing universal color variables to globals, and:
    - if existing universal color variables exactly match
      the previous default theme, and pretend they didn't exist.
    - else migrate the universals to ~/.config/fish/conf.d/fish_frozen_theme.fish,
      which is a less surprising way of persisting this.
    - either way, delete all universals to do the right thing for most users.
- Make sure that webconfig's "Set Theme" continues to:
  - instantly update all running shells
    - This is achieved by a new universal variable (but only for
      notifying shells, so this doesn't actually need to be persisted).
      In future, we could use any other IPC mechanism such as "kill -SIGUSR1"
      or if we go for a new feature, "varsave" or "set --broadcast", see
      https://github.com/fish-shell/fish-shell/issues/7317#issuecomment-701165897
      https://github.com/fish-shell/fish-shell/pull/8455#discussion_r757837137.
  - persist the theme updates, completely overriding any previous theme.
    Use the same "fish_frozen_theme.fish" snippet as for migration (see above).
    It's not meant to be edited directly. If people want flexibility
    the should delete it.
    It could be a universal variable instead of a conf snippet file;
    but I figured that the separate file looks nicer
    (we can have better comments etc.)
- Ask the terminal whether it's using dark or light mode, and use an
  optimized default. Add dark/light variants to themes,
  and the "unknown" variant for the default theme.
  Other themes don't need the "unknown" variant;
  webconfig already has a background color in context,
  and CLI can require the user to specify variant explicitly if
  terminal doesn't advertise colors.
- Every variable that is set as part of fish's default behavior
  gets a "--label=default" tacked onto it.

  This is to allow our fish_terminal_color_theme event handler to
  know which variables it is allowed to update. It's also necessary
  until we revert 7e3fac561d (Query terminal only just before reading
  from it, 2025-09-25) because since commit, we need to wait until
  the first reader_push() to get query results.  By this time, the
  user's config.fish may already have set variables.

  If the user sets variables via either webconfig, "fish_config theme
  {choose,save}", or directly via "set fish_color_...", they'd almost
  always remove this label.
- For consistency, make default fish_key_bindings global
  (note that, for better or worse, fish_add_path still remains as
  one place that implicitly sets universal variables, but it's not
  something we inject by default)
- Have "fish_config theme choose" and webconfig equivalents reset
  all color variables. This makes much more sense than keeping a
  hardcoded subset of "known colors"; and now that we don't really
  expect to be deleting universals this way, it's actually possible
  to make this change without much fear.

Should have split this into two commits (the changelog entries are
intertwined though).

Closes #11580
Closes #11435
Closes #7317
Ref: https://github.com/fish-shell/fish-shell/issues/12096#issuecomment-3632065704
2025-12-14 17:03:03 +01:00
Johannes Altmanninger
f1f14cc8fa input: extract function for enqueuing query response 2025-12-14 16:29:14 +01:00
Johannes Altmanninger
707bfe3ce6 fish_config theme show: list default scheme first
Webconfig does the same ("Add the current scheme first, then the
default.").
2025-12-14 16:29:14 +01:00
Johannes Altmanninger
d8f1a2a24f Move sample_prompts/themes to share/
They are used by "fish_config" CLI too, so no need to make them
private to webconfig.  Putting them at top-level seems simpler overall.
2025-12-14 16:29:14 +01:00
Johannes Altmanninger
dbdecaba6d fish_config: remove hardcoded set of colors to erase
This is incomplete, and we'll solve the problem differently. For now,
leave colors that are not mentioned in the theme.  This causes problems
for sparse themes, but a following commit will fix that by making
"fish_config theme choose" erase all variables set by a previous
invocation (but not erase variables set by the user).  Only webconfig
won't do that since it (historically) uses copy semantics, but we
could change that too if needed.

This also breaks the guarantee mentioned by this comment in webconfig:

> Ensure that we have all the color names we know about, so that if the
> user deletes one he can still set it again via the web interface

which should be fine because:
1. a following commit will always set all globals at interactive init,
   so colors should only be missing in edge cases ("fish -c fish_config").
2. it's easy to recover from by setting a default theme.
2025-12-14 16:26:14 +01:00
Johannes Altmanninger
66f6493fbf fish_config theme dump: speed up
For better or worse, "set -L" prints all of $history, which makes
"fish_config theme show" very slow.  Fix this by only printing the
relevant variables.  While at, make the escaping function use the
shared subset of fish and POSIX shell quoting syntax, to allow a
following commit to use shlex.split().
2025-12-14 16:25:14 +01:00
Johannes Altmanninger
76e0f9a3e8 fish_config: extract function for iterating over themes 2025-12-14 16:24:13 +01:00
Johannes Altmanninger
697afdefeb fish_config: extract some functions for reading theme files
A following commit wants to add some more logic and call some of
fish_config's private APIs from webconfig.  We could keep it all in
one file but I'm not sure we should so try the splitting we usually do.
2025-12-14 16:23:53 +01:00
Johannes Altmanninger
aba89f9088 docs: one sentence per line 2025-12-14 16:23:37 +01:00
Johannes Altmanninger
344187e01a fish_config: extract function 2025-12-14 16:23:37 +01:00
Johannes Altmanninger
9f11de24d4 webconfig.py: remove dead code 2025-12-14 16:23:37 +01:00
Johannes Altmanninger
7996637db5 Make fish immediately show color changes again
Historically, fish tried to re-exec the prompt and repaint immediately
when a color variable changed.

Commit f5c6306bde (Do not repaint prompt on universal variable events,
but add event handler for fish_color_cwd, 2006-05-11) restricted this
to only variables used in the prompt like "fish_color_cwd".

Commit 0c9a1a56c2 (Lots of work on web config Change to make fish
immediately show color changes, 2012-03-25) added repainting back
for all colors (except for pager colors).

Commit ff62d172e5 (Stop repainting in C++, 2020-12-11) undid that.

Finally, 69c71052ef (Remove __fish_repaint, 2021-03-04) removed the
--on-variable repaint handlers added by the first commit.

So if color changes via either
1. webconfig
2. an event handler reacting to the terminal switching between light/dark mode
3. a binding etc.

then we fail to redraw. Affects both colors used in prompts and those
not used in prompts.

Fix that by adding back the hack from the second commit.  This is
particularly important for case 2, to be added by a following commit.

In future we can remove this hack by making "--on-variable" take
a wildcard.
2025-12-14 16:23:37 +01:00
Johannes Altmanninger
d67cdf5f6f Update changelog 2025-12-14 16:23:37 +01:00
Johannes Altmanninger
7dd2004da7 Re-enable focus reporting on non-tmux
I can no longer reproduce the issue described in bdd478bbd0 (Disable
focus reporting on non-tmux again for now, 2024-04-18).  Maybe the
TTY handoff changes fixed this.  Let's remove this workaround and
enable focus reporting everywhere.
2025-12-14 16:23:37 +01:00
Johannes Altmanninger
4000503c03 DRY DSR sequences a bit 2025-12-14 16:23:37 +01:00
Johannes Altmanninger
7c994cd784 fish_config: extract some functions for finding theme variables etc.
To be used in a following commit.
2025-12-14 16:23:37 +01:00
Johannes Altmanninger
e68ea35f02 fish_config: improve consistency
The theme variable filter applies to whole lines, so it's weird to
only apply it to the first token, and we don't do that elsewhere.
2025-12-14 16:21:16 +01:00
Johannes Altmanninger
5cc953b18d Default theme variants specialized for light/dark mode
Start by converting the "default" theme's colors to RGB, using
XTerm colors since they are simple, see
https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit.

Then make the following changes:

for both default-light and default-dark:
- Reinstate fish_color_command/fish_color_keyword as blue since one
  of the reasons in 81ff6db62d (default color scheme: Make commands
  "normal" color, 2024-10-02) doesn't hold anymore.
- bravely replace "fish_pager_color_selected_background -r" with
  something that hopefully matches better.
  Note we can't trivially use the fallback to
  "fish_color_search_match", since for unknown reasons,
  "fish_pager_color_selected_background" is only for background and
  the others are for foreground.

for default-light:
- brgreen (00ff00) looks bad on light background, so replace it with green (00cd00).
  This means that we no longer use two different shades of green in the default theme
  (which helps address the "fruit salad" mentioned 81ff6db62d).
- yellow (cdcd00) looks bad on light background, make it darker (a0a000)
- fish_pager_color_progress's --background=cyan (00cdcd) seems a bit too bright, make it darker
  - same for other uses of cyan (also for consistency)
  - this means fish_color_operator / fish_color_escape can use 00cdcd I guess.
for default-dark:
- use bright green (00ff00) for all greens
- use bright blue (5c5cff) instead of regular blue for command/keyword
- make autosuggestions a bit lighter (9f9f9f instead of 7f7f7f) 
- etc.. I think I made the two themes mostly symmetrical.

Part of #11580
2025-12-14 16:21:16 +01:00
Johannes Altmanninger
f264ee0b10 webconfig theme: rename "fish-default" theme
The "fish-" prefix is not needed here and it would add more noise to
a following commit which adds default-{dark,light} variants that use
24 bit RGB colors.
2025-12-14 15:44:58 +01:00
Johannes Altmanninger
3c6978c038 webconfig theme: minor changes to default theme
Don't set fish_pager_color_completion,
it already falls back to fish_color_normal.

Also remove a comment, it's obvious and maybe no longer
true, since 8 bit colors are widely available now, see
https://github.com/fish-shell/fish-shell/issues/11344#issuecomment-3568265178

Though we prefer 24 bit colors wherever we can.
2025-12-14 15:44:58 +01:00
Johannes Altmanninger
d5732b132e webconfig themes: consistent quoting 2025-12-14 15:44:58 +01:00
Johannes Altmanninger
ae22cc93db webconfig themes: shell-friendly filenames
For historical reasons (namely the webconfig origin), our theme
names contain spaces and uppercase letters which can be inconvenient
when using the "fish_config theme choose" shell command.  Use more
conventional file names.

Web config still uses the pretty names, using the ubiquitous "# name:"
property.
2025-12-14 15:44:58 +01:00
Johannes Altmanninger
51e551fe5f doc/fish_config: fix copy-paste errors 2025-12-14 15:44:58 +01:00
Johannes Altmanninger
33cb8679ba fish_config theme show: remove unused argument 2025-12-14 15:44:58 +01:00
Johannes Altmanninger
655b1aa7a1 fish_prompt: remove stray initialization of fish_color_status
I can't reproduce the problem mentioned in 0420901cb2 (default prompt:
Set fish_color_status if unset, 2021-04-11).
2025-12-14 15:44:58 +01:00
Johannes Altmanninger
daba5fdbcd fish_delta: acknowledge workaround for no-stdin-in-cmdsub 2025-12-14 15:44:58 +01:00
Johannes Altmanninger
01bd380d00 webconfig.py: reuse "fish_config theme dump" 2025-12-14 15:44:58 +01:00
Johannes Altmanninger
801c4f8158 webconfig.py: simplify "functions" output parsing
This outputs one-item-per-line if stdout is a terminal.
2025-12-14 15:44:58 +01:00
Johannes Altmanninger
e331e30e38 __fish_config_interactive: minor style change 2025-12-14 15:44:58 +01:00
Johannes Altmanninger
7bd30ac3c4 __fish_config_interactive: inline function 2025-12-14 15:44:58 +01:00
Johannes Altmanninger
5631a7ec86 Fix color variable filter regex 2025-12-14 15:44:58 +01:00
Johannes Altmanninger
a9c43e7396 webconfig js: remove redundant code clone
The server side (webconfig.py) will already reset missing colors
to empty.
2025-12-14 15:44:58 +01:00
Johannes Altmanninger
2a6c0e4437 webconfig js: remove obsolete workaround
I cannot reproduce.
2025-12-14 15:44:58 +01:00
Johannes Altmanninger
7f224d0dfd DRY color variable names 2025-12-14 15:42:56 +01:00
Johannes Altmanninger
f818002f38 webconfig.py: use full color names
Optimize for ease of maintenance.
2025-12-14 15:42:56 +01:00
Johannes Altmanninger
6b8e82946a webconfig.py: remove dead code
Both descriptions for bindings and color variables are unused.
2025-12-14 15:42:56 +01:00
Johannes Altmanninger
faaff2754b webconfig.py: fix stale return type
This function returns a heterogeneous list (containing dicts/lists)
by accident. Fix that and reduce code duplication.  Fixes c018bfdb4d
(Initial work to add support for angularjs, 2013-08-17).
2025-12-14 15:42:12 +01:00
Johannes Altmanninger
5c0e72bb89 webconfig.py: simplify 2025-12-14 15:40:03 +01:00
Johannes Altmanninger
b3b7d2cb00 webconfig js: remove debug log statement 2025-12-14 15:40:03 +01:00
Johannes Altmanninger
f503dcb92d webconfig js: resolve a comment 2025-12-14 15:37:46 +01:00
Johannes Altmanninger
7f1b53a9f1 webconfig.py: remove a workaround for Python 2 2025-12-14 15:37:46 +01:00
Johannes Altmanninger
938e780007 fish_config theme save: remove dead code 2025-12-14 15:37:46 +01:00
Johannes Altmanninger
3e7c5ae399 __fish_config_interactive: make config file initialization independent of uvars
Helps the following commits.
2025-12-14 15:37:46 +01:00
Johannes Altmanninger
548f37eabb Simplify make_tarball.sh
Note that we don't need to set the mtime anymore -- it was added in
5b5b53872c (tarball generation: include config.h.in, set mode and
ownership, 2013-09-09) for autotools' multi-stage builds.
2025-12-14 15:37:46 +01:00
Johannes Altmanninger
135fc73191 Remove man/HTML docs from tarball, require Sphinx instead
Advantages of prebuilt docs:
- convenient for users who compile the tarball
- convenient for packagers who don't have sphinx-build packaged
  (but packaging/installing that should be easy nowadays?
  see https://github.com/fish-shell/fish-shell/issues/12052#issuecomment-3520336984)

Disadvantages:
- Extra build stage / code path
- Users who switch from building from tarball to building from source
  might be surprised to lose docs.
- People put the [tarballs into Git repositories](https://salsa.debian.org/debian/fish), which seems weird.

Remove the tarball.

Let's hope this is not too annoying to users who build on outdated
distros that don't have sphinx -- but those users can probably use
our static builds, skipping all compilation.

To avoid breaking packagers who use `-DBUILD_DOCS=OFF` (which still
installs prebuilt docs), rename the option.

Closes #12088
2025-12-14 15:37:46 +01:00
Johannes Altmanninger
1fe5497b5d Remove redundant saving of TTY flags
The logic added by 2dbaf10c36 (Also refresh TTY timestamps
after external commands from bindings, 2024-10-21) is obsoleted
by TtyHandoff.  That module is also responsible for calling
reader_save_screen_state after it writes to the TTY, so we don't
actually need to check if it wrote anything.
2025-12-14 15:37:46 +01:00
Johannes Altmanninger
6b85450dea Silence error log for legacy escape specifically
This happens after pressing escape while kitty keyboard protocol is
disabled (or not supported).
2025-12-14 15:37:46 +01:00
Johannes Altmanninger
2309c27a2d Replace ifdef with cfg! 2025-12-14 10:24:49 +01:00
exploide
8b5d66def8 completions: added arp-scan
Closes #12158
2025-12-14 08:44:08 +01:00
xtqqczze
27852a6734 fix: clippy::ptr_as_ptr
https://rust-lang.github.io/rust-clippy/master/index.html#ptr_as_ptr

Closes #12136
2025-12-11 17:46:58 +01:00
xtqqczze
cc29216ea9 fix: clippy::ptr_cast_constness
https://rust-lang.github.io/rust-clippy/master/index.html#ptr_cast_constness

Part of #12136
2025-12-11 17:46:58 +01:00
xtqqczze
831411ddd5 fix: clippy::ref_as_ptr
https://rust-lang.github.io/rust-clippy/master/index.html#ref_as_ptr

Part of #12136
2025-12-11 17:46:58 +01:00
xtqqczze
ec77c34ebe fix: clippy::borrow_as_ptr
https://rust-lang.github.io/rust-clippy/master/index.html#borrow_as_ptr

Part of #12136
2025-12-11 17:46:58 +01:00
Johannes Altmanninger
d1c7a4b6e7 Don't silence errors in fish_key_bindings/fish_user_key_bindings
We silence erros from the key binding function since 2c5151bb78 (Fix
bug in key binding code causing unneeded error messages, 2007-10-31).

Reasons are
1. fish_key_bindings is not a valid function
2. fish_key_bindings runs "bind -k" for things that are not supported (#1155)

Both reasons are obsolete:
1. we already check that earlier
2. "-k" is gone. (Also, we could have silenced "bind -k" invocations instead).
2025-12-11 17:46:58 +01:00
Nahor
7fc27e9e54 cygwin: improve handling of .exe file extension
- Prefer the command name without `.exe` since the extension is optional
when launching application on Windows...
- ... but if the user started to type the extension, then use it.
- If there is no description and/or completion for `foo.exe` then
use those for `foo`

Closes #12100
2025-12-10 16:15:41 +01:00
Johannes Altmanninger
a4b949b0ca Remove uname= prefix from query-os-name
Discussion with terminal authors indicates a slight preference for
removing the prefix.  We don't need it at this point, since we only
use it to detect macOS clients.
2025-12-10 16:15:41 +01:00
Johannes Altmanninger
64196a2a9e complete: fix erasing wrapped functions
Two issues:
1. "complete -e foo" doesn't erase wrap definitions
2. "complete -e foo --wraps" erases things other than the wrap definitions

Fix them.

There's another issue, the second erase command leaves around an
extra complete entry. Let's leave that for later.

Fixes #12150
2025-12-10 16:15:41 +01:00
Johannes Altmanninger
353ecfadaf complete: fix naming convention 2025-12-10 16:15:41 +01:00
Johannes Altmanninger
0e9ceb154e fish_config theme dump: check for extra arguments 2025-12-10 16:15:41 +01:00
Johannes Altmanninger
baaf06b2c6 cmake/Tests: enable Cargo features
For unknown reasons, we don't enable Cargo features on the test target.
Let's try to, simplifying things overall.

Ref: https://github.com/fish-shell/fish-shell/issues/12120#issuecomment-3627842316
2025-12-10 16:15:41 +01:00
Johannes Altmanninger
106f7b86dc cmake/Tests: split long line 2025-12-10 16:15:41 +01:00
Daniel Rainer
64e3b419b6 ci: disable pexpect and tmux tests in sanitizer jobs
These tests are unreliable in CI when running with address sanitiation
enabled, resulting in intermittent CI failures.
Disable them to get rid of the many false positives to reduce annoyance
and to avoid desensitization regarding failures of the asan CI job.

Suggested in
https://github.com/fish-shell/fish-shell/pull/12132#issuecomment-3605639954

Closes #12142
Closes #12132
Closes #12126
2025-12-10 16:15:41 +01:00
Kristof Mattei
3237efc582 fix: invoke the rm command, bypassing custom rm functions which might block
Closes #12141
2025-12-10 16:15:41 +01:00
xtqqczze
717d301b7f refactor: replace addr_of! macros with raw pointer syntax
`addr_of!` and `addr_of_mut!` have been soft-deprecated as of Rust 1.82.0.

Closes #12139
2025-12-10 16:15:41 +01:00
Daniel Rainer
6a36d92173 lint: fix function_casts_as_integer lint in nightly
This lint is intended to make it harder to unintentionally cast a
function to an int. We do want to store function pointers in a usize
here, so add the intermediate cast suggested by the lint.

Closes #12131
2025-12-10 16:15:41 +01:00
Daniel Rainer
75c005a4d4 lint: convert is_some+unwrap into if let
This fixes an `unnecessary_unwrap` lint shown by nightly Clippy.

Closes #12130
2025-12-10 16:15:41 +01:00
Johannes Altmanninger
07389055f1 fish_indent: handle invalid arguments 2025-12-10 16:15:41 +01:00
Johannes Altmanninger
692e6d57cf fish_indent --ansi to emit SGR0 before final newline
Buggy programs parsing "fish_indent --ansi" output break because
we wemit SGR0 after the final newline.  I suppose this is weird,
and there's no need to wait until after the \n to emit SGR0 so let's
move it before that.

Closes #12096
2025-12-10 16:15:41 +01:00
Johannes Altmanninger
7952545460 Prefer cfg! over #[cfg] for embedding
We should isolate conditionally-compiled code as much as possible,
to allow the compiler to do more work, and to simplify code.
Do that for the embedding definition for __fish_build_paths, like we
already do for "Docs".  Duplicate the workaround we use to set the
embedded struct to a "virtually empty" directory.  Don't set it to
"$FISH_RESOLVED_BUILD_DIR", because that directory can contain >50k
files, and in debug mode listing files (even if all are excluded)
would take a second.

Ref: https://github.com/fish-shell/fish-shell/pull/12103#issuecomment-3592280477

This should also fix #12120.
2025-12-10 16:15:41 +01:00
Johannes Altmanninger
4aa967cd5d builtins: extract struct for input value from arg or stdin line 2025-12-10 16:15:07 +01:00
Daniel Rainer
3e2336043a gettext-extract: fix race condition
Multiple gettext-extraction proc macro instances can run at the same
time due to Rust's compilation model. In the previous implementation,
where every instance appended to the same file, this has resulted in
corruption of the file. This was reported and discussed in
https://github.com/fish-shell/fish-shell/pull/11928#discussion_r2488047964
for the equivalent macro for Fluent message ID extraction. The
underlying problem is the same.

The best way we have found to avoid such race condition is to write each
entry to a new file, and concatenate them together before using them.
It's not a beautiful approach, but it should be fairly robust and
portable.

Closes #12125
2025-12-10 16:15:07 +01:00
Johannes Altmanninger
c1db2744cf Revert "translations: Add Spanish translation"
This reverts commit 0fb5ab4098 because
review comments have not yet been addressed.
2025-12-10 16:15:07 +01:00
Daniel Rainer
c6252967ab rust-embed: update to 8.9.0
This eliminates the proc-macro panic occasionally observed in CI,
instead ignoring paths which cannot be canonicalized.
See #12120.

While this does not address the underlying issue of why the proc-macro
fail happens, it should result in builds no longer failing, and since
they failed in the case where no embedding is desired, there should be
no issue with ignoring failed path canonicalization, since we do not
want to embed anything in these cases.
2025-12-09 11:34:08 +08:00
Julio Napurí
0fb5ab4098 translations: Add Spanish translation
Closes #12089
2025-12-08 18:34:15 +01:00
Daniel Rainer
de3d390391 cleanup: remove unused import
Closes #12151
2025-12-08 17:08:51 +00:00
Daniel Rainer
76b0961e91 tempfile: use new logic for uvar tests
The old approach does not properly protect from concurrent tests
accessing the same tempdir. Fix this by moving to the new tempfile
functionality. This also eliminates the need to explicitly create and
delete the directory. There is also no longer a reason to specify names
for the temporary directories, since name collisions are avoided using
more robust means, and there is little benefit to having the names in
the directory name.

Closes #12030
2025-12-08 16:51:20 +00:00
Daniel Rainer
c0f91a50fa fix: avoid race conditions of mkstemp
The `mkstemp` function opens files without setting `O_CLOEXEC`. We could
manually set this using `fnctl` once the file is opened, but that has
the issue of introducing race conditions. If fish `exec`s in another
thread before the `fnctl` call completes, the file would be left open.

One way of mitigating this is `mkostemp`, but that function is not
available on all systems fish supports, so we can't rely on it.

Instead, build our own tempfile creation logic which uses the `rand`
crate for getting entropy and relies on Rust's stdlib for the rest.
The stdlib functions we use set `O_CLOEXEC` by default.

For directory creation we keep using `mkdtemp`, since there we don't
open anything. We could replace this by extending our custom logic a
bit, which would allow us to drop the `nix` dependency for our
`tempfile` crate, but since the code is simpler as it is now and we need
nix in fish's main crate, there is no need to modify the directory
creation code.

Part of #12030
2025-12-08 16:51:20 +00:00
Daniel Rainer
77fbd0a005 rand: use ThreadRng wherever reseeding is ok
`SmallRng` was chosen in part due to limitation of old macOS versions.
This is no longer relevant, since the affected versions are not
supported by Rust anymore.

Switch everything which does not need fixed sequences based on a seed to
`ThreadRng`, which has better cryptographic properties and is
occasionally reseeded. Performance differences should not matter much,
since initialization of `ThreadRng` is not that expensive and it's
generation speed is easily fast enough for our purposes.

In some cases, like tests and the `random` builtin, we want a PRNG which
consistently produces the same sequence of values for a given seed.
`ThreadRng` does not do this, since it is occasionally reseeded
automatically. In these cases, we keep using `SmallRng`.

Part of #12030
2025-12-08 16:51:20 +00:00
Daniel Rainer
c9ab2c26aa Update rand crate to 0.9.2
Function names containing `gen` have been deprecated to avoid conflicts
with the Rust 2024 keyword, so this commit also switches to the new
names.

Part of #12030
2025-12-08 16:51:20 +00:00
Daniel Rainer
b1769658f5 cleanup: remove obsolete comment
Since we changed our MSRV to 1.85, macOS < 10.12 is no longer supported,
so the comment removed here is no longer relevant.

The workaround for old macOS was introduced in
9337c20c2 (Stop using the getrandom feature of the rand crate, 2024-10-07)

We might want to reconsider which RNGs and other features of the `rand`
crate we use, but there is no immediate need to do so, since the current
approach seems to have worked well enough.

Part of #12030
2025-12-08 16:51:20 +00:00
Gleb Smirnov
3518d4f6ad fix: treat run0 and please as a prefix in __fish_man_page
Closes #12145
2025-12-08 21:30:29 +08:00
Jesse Harwin
aa4ebd96f9 Fixed typo
Missed a spot in the first attempt #12135 as pointed out by [xtqqczze](https://github.com/fish-shell/fish-shell/pull/12135#issuecomment-3609441130)

Small typo found in doc_src/cmds/fish_opt.rst and tests/checks/argparse.fish. `valu` to `value`
2025-12-08 21:19:43 +08:00
Asuka Minato
656b39a0b3 Also show case-insensitive prefix matches in completion pager
[ja: made some changes and added commit message]

Fixes #7944
Closes #11910
2025-12-05 16:12:34 +01:00
Johannes Altmanninger
fceb600be5 math: remove logb
As discussed in #12112, this is a false friend (the libc logb()
does something else), and without keyword arguments or at least
function overloading, this is hard to read.
Better use "/ log(base)" trick.
2025-12-05 16:06:22 +01:00
PowerUser64
47c773300a feat(math): add logb function
Closes #12112
2025-11-30 09:20:33 +01:00
Daniel Rainer
2d29749eae printf: improve Unicode escape + PUA handling
The old handling of Unicode escape sequences seems partially obsolete
and unnecessarily complicated. For our purposes, Rust's u32 to char
parsing should be exactly what we want.

Due to fish treating certain code points specially, we need to check
if the provided character is among the special chars, and if so we need
to encode it using our PUA scheme. This was not done in the old code,
but is now.
Add tests for this.
Fixes #12081

Rework the error message for invalid code points.
The old message about invalid code points not yet being supported seems
odd. I don't think we should support this, so stop implying that we
might do so in the future.
In the new code, indicating that a Unicode character is
out of range is also not ideal, since the range is not contiguous.
E.g. `\uD800` is invalid, but \U0010FFFF is valid.
Refrain from referring to a "range" and instead just state that the
character is invalid.

Move formatting of the escape sequence into Rust's `format!` to simplify
porting to Fluent.

Closes #12118
2025-11-30 09:20:33 +01:00
Daniel Rainer
22a252d064 gettext: rebuild extract macro on env var change
While it's not necessary to rebuild the proc macro for extraction when
the env var controlling the output location changes, this way everything
using the macro will automatically be rebuilt when this env var changes,
making it impossible to forget adding this to other `build.rs` files.

For now, keeping the rebuild instructions in fish's main crate's
`build.rs` would be fine as well, but if we start breaking this crate
into smaller parts, it would become annoying to add the rebuild command
in every crate depending on gettext extraction.

Closes #12107
2025-11-30 09:20:33 +01:00
Daniel Rainer
4642b28ea7 gettext: enable default features for extraction
There was a mismatch between the extraction done from
`build_tools/check.sh` and the one done in
`build_tools/fish_xgettext.fish`, resulting in messages guarded by
default features being extracted by the former but not the latter.
This brings them in sync.

Ideally, we would enable all features for extraction, but compiling with
`--all-features` is broken and manually keeping the features lists
updated is tedious and error prone, so we'll settle on only using
default features for now.

Closes #12103
2025-11-30 09:20:33 +01:00
Daniel Rainer
b8662f9c7f cleanup: move use statements to start of module
Closes #12102
2025-11-30 09:20:33 +01:00
Daniel Rainer
9af85f4c3b gettext: separate catalog lookup from interning
Improve separation of concerns by handling catalog lookup in the
`gettext_impl` module, while taking care of string interning and string
type conversion in the outer `gettext` function as before.

This improves isolation, meaning we no longer have to expose the
catalogs from `gettext_impl` to its parent module.

It also helps with readability.

Part of #12102
2025-11-30 09:20:33 +01:00
Daniel Rainer
aa742f0b57 refactor: eliminate duplicate enum variant spec
Modify the `str_enum!` macro to be able to handle multiple strings per
enum variant. This means that no separate step is required for defining
the enum. Instead definition of the enum and implementation of the
string conversion functions is now combined into a single macro
invocation, eliminating code duplication, as well as making it easier to
add and identify aliases for an enum variant.

Closes #12101
2025-11-30 09:20:33 +01:00
Daniel Rainer
e648da98da cleanup: sort StatusCmd variants alphabetically
Part of #12101
2025-11-30 09:20:33 +01:00
Daniel Rainer
94367b08ba cleanup: do not set enum variant to value
This seems to be a left-over detail from the C++ version. Setting the
first element to 0 does not have any effect, since that's the default,
and setting it to 1 seems to serve no purpose in the current code.

Part of #12101
2025-11-30 09:20:33 +01:00
Daniel Rainer
97b45dc705 cleanup: remove duplicate enum variants
There is no difference in how these two variants are treated. Keeping
the old command name around for compatibility is nice, but it does not
need to have its own enum variant.

Part of #12101
2025-11-30 09:20:33 +01:00
Johannes Altmanninger
198768a1c7 CONTRIBUTING: remove -n from sphinx-build, add cmake target
The -n flag adds warnings about preexisting problems because we don't
check it in CI, so let's not recommend that.

Not everyone uses cmake but it's still the source of truth for docs,
so mention the cmake incantation.  Though it seems like the direct
sphinx-build invocation works just fine, so keep it first.
2025-11-30 09:20:33 +01:00
Johannes Altmanninger
7c27c1e7d0 editorconfig / doc_src: trim trailing whitespace
Commit 0893134543 (Added .editorconfig file (#3332) (#3313),
2016-08-25) trimmed trailing whitespace  for Markdown file (which do
have significant trailing whitespace) but ReStructuredText does not,
and none of our Markdown files cares about this, so let's clean up
whitespace always.
2025-11-30 09:20:33 +01:00
Daniel Rainer
9f8d8ebc2c cleanup: remove unused message
This message is no longer used since we unconditionally embed files now.
The `#[allow(dead_code)]` annotation was needed to avoid warnings while
ensuring that message extraction was not broken.

Closes #12099
2025-11-30 09:20:33 +01:00
Johannes Altmanninger
87a312ccba test/tmux-prompt: fix quoting that looks like a bug 2025-11-30 09:20:33 +01:00
Johannes Altmanninger
838f48a861 Show completions from separator only if there are no whole-token ones
Completions for "foo bar=baz" are sourced from
1. file paths (and custom completions) where "bar=baz" is a subsequence.
2. file paths where "baz" is a subsequence.

I'm not sure if there is ever a case where 1 is non-empty and we
still want to show 2.

Bravely include this property in our completion ranking, and only
show the best ones.

This enables us to get rid of the hack added by b6c249be0c (Back out
"Escape : and = in file completions", 2025-01-10).

Closes #5363
2025-11-30 09:20:33 +01:00
Johannes Altmanninger
52286f087d builtins set: only one space between list elements 2025-11-30 09:20:33 +01:00
Johannes Altmanninger
902d4be664 __fish_git_remotes: use POSIX regex syntax
Fixes https://github.com/fish-shell/fish-shell/pull/11941#issuecomment-3574089216
2025-11-30 09:19:03 +01:00
Johannes Altmanninger
16a91f8e3c Fix regression interpreting prompt y on multiline commandlines
Fixes a772470b76 (Multi-line autosuggestions, 2025-05-18)
Fixes #12121
2025-11-30 08:09:28 +01:00
Johannes Altmanninger
3cac5ff75e Fix "cargo-deny" check 2025-11-30 08:09:28 +01:00
Daniel Rainer
5210c16bfa printf: simplify conversion specifiers
This is another case where we can don't need to use complicated
formatting specifiers. There is also no need to use `wgettext_fmt` for
messages which don't contain any localizable parts.

The instances using `sprintf` could be kept as is, but I think it's
better to keep the width computation at the place where it can sensibly
be done, even though it is not done correctly at the moment because it
does not use grapheme widths.

Removing complicated conversion specifiers from localized messages helps
with the transition to Fluent.

Closes #12119
2025-11-30 00:40:52 +00:00
Daniel Rainer
8a75bccf00 printf: simplify conversion specifier
We already compute the length of the substring we want to print in Rust.
Passing that length as the precision to let printf formatting limit the
length is brittle, as it requires that the same semantics for "length"
are used.

Simplifying conversion specifiers also makes the transition to Fluent
easier.

Part of #12119
2025-11-30 00:40:52 +00:00
David Adam
5130fc6f17 build_tools: add script to get supported Ubuntu versions 2025-11-29 00:05:24 +08:00
David Adam
b0a04f8648 release.sh: update Debian changelog as part of release 2025-11-28 21:21:27 +08:00
David Adam
60f41a738d Debian packaging: add historical changelog 2025-11-27 23:39:47 +08:00
David Adam
9814bae727 Debian packaging: upgrade to debhelper compat 13 2025-11-26 22:55:33 +08:00
David Adam
63cc800cd1 Debian packaging: fix variable exports in debian/rules
This ended up setting the variable to "true ", which cargo did not
understand.
2025-11-26 22:05:35 +08:00
David Adam
47c139b916 Debian packaging: drop obsolete dependencies 2025-11-26 21:03:52 +08:00
David Adam
107352c000 Debian packaging: update to Debian policy 4.6.2 2025-11-26 20:58:17 +08:00
David Adam
26cb522140 Debian packaging: move to contrib/debian directory
This is the location requested by Debian's Upstream Guide, and means it
can be included in tarballs, simplifying the build process.
2025-11-25 21:43:36 +08:00
oliwia
7db3009968 docs: typo 2025-11-25 10:30:47 +08:00
Daniel Rainer
13e296db76 license: allow fish's own license identifiers
The newly added `cargo deny check licenses` command complains about the
licenses added in this commit not being explicitly allowed, so add them
to the config here. There is no intended change in semantics.

Closes #12097
2025-11-23 16:25:12 +01:00
Johannes Altmanninger
6fa992c8d3 sphinx: exclude *.inc.rst files
Sections like "Synopsis" wrongly show up in the toctree in
build/user_doc/html/commands.html.  Skip them.
2025-11-23 12:30:22 +01:00
Johannes Altmanninger
7ca78e7178 share/functions: fix path to /bin/sh on android
As mentioned in https://github.com/fish-shell/fish-shell/issues/12055#issuecomment-3554869126

> instances of `/bin/sh` as freestanding commands within `.fish`
> files are most likely not automatically handled by `termux-exec`

and

> This topic is complicated by the fact that some Android ROMs _do_
> contain real `/bin/sh` files

Core uses /system/bin/sh on Android.  Let's do the same from script
(even if /bin/sh exists), for consistency.
2025-11-23 12:30:22 +01:00
Daniel Rainer
2ee4f239d1 build_helper: add rebuild function for embedded path change
For paths embedded via `rust-embed`, we only need to rebuild on path
changes if the files are actually embedded.

To avoid having to remember and duplicate this logic for all embedded
paths, extract it into the build helper.

Closes #12083
2025-11-23 12:30:22 +01:00
Johannes Altmanninger
4ffa06fb7e Fix section names in suggested "help" commands
Fixes 2cd60077e6 (help: get section titles from Sphinx, 2025-11-05)
Fixes #12082
2025-11-23 12:30:22 +01:00
Johannes Altmanninger
a1baf97f54 Do not embed man pages in CMake builds
Commit 0709e4be8b (Use standalone code paths by default, 2025-10-26)
mainly wanted to embed internal functions to unbreak upgrade scenarios.

Embedding man pages in CMake has small-ish disadvantages:
1. extra space usage
2. less discoverability
3. a "cyclic" dependency:
   1. "sphinx-docs" depends on "fish_indent"
   2. "fish_indent" via "crates/build-man-pages" depends on "doc_src/".
   So every "touch doc_src/foo.rst && ninja -Cbuild sphinx-docs"
   re-builds fish, just to re-run sphinx-build.

The significant one is number 3.  It can be worked around by running
sphinx-build with stale "fish_indent" but I don't think we want to
do that.

Let's backtrack a little by stopping embedding man pages in CMake
builds; use the on-disk man pages (which we still install).

The remaining "regression" from 0709e4be8b is that "ninja -Cbuild
fish" needs to rebuild whenever anything in "share/" changes.  I don't
know if that's also annoying?

Since man pages for "build/fish" are not in share/, expose the exact
path as $__fish_man_dir.
2025-11-23 12:30:22 +01:00
Johannes Altmanninger
2a7c57035e Readme: remove INSTALL_DOCS
As mentioned in b5aea3fd8b (Revert "[cmake] Fix installing docs",
2018-03-13), this should not be set by the user.
2025-11-23 12:30:22 +01:00
Johannes Altmanninger
19e1ad7cfe config_paths: don't fall back to compiled-in DOC_DIR from relocatable tree
When $RELOCATED_PREFIX/bin/fish detects that
$RELOCATED_PREFIX/share/fish and $RELOCATED_PREFIX/etc/fish exist,
it uses paths from $RELOCATED_PREFIX (which is determined at runtime,
based on $argv), and not the prefix determined at compile time.

Except we do use DOCDIR (= ${CMAKE_INSTALL_FULL_DOCDIR}). This
seems like a weird side effect of commit b758c0c335 (Relax the
requirement that we find a working 'doc' directory in order for fish
to be relocatable.  2014-01-17) which enabled relocatable logic in
scenarios where $PREFIX/share/doc/fish was not installed.

This is weird; fish's "help" command should not take docs from a
different prefix.

Always use the matching docdir. This shouldn't make any practical
difference because since commit b5aea3fd8b (Revert "[cmake] Fix
installing docs", 2018-03-13), $PREFIX/share/doc/fish/CHANGELOG.rst
is always installed.
2025-11-23 12:30:22 +01:00
Johannes Altmanninger
2ea3da4819 config_paths: disable the relocatable tree logic on Cargo builds
This only makes sense for builds that install directories like
$PREFIX/share/fish, $PREFIX/etc/fish.
2025-11-23 12:30:22 +01:00
Johannes Altmanninger
3b100fce2d Fix __fish_help_dir when running from build directory
When running fish from a CMake build directory ("build/fish"),
"__fish_help_dir" is wrong because we assume the tarball layout. Fix
that.
2025-11-23 12:30:22 +01:00
Johannes Altmanninger
0c67d0565a Commit help_sections data file
The help_sections.rs file was added to the tarball only as a quick hack.
There is a cyclic dependency between docs and fish:

"fish_indent" via "crates/build-man-pages" depends on "doc_src/".
So every "touch doc_src/foo.rst && ninja -Cbuild sphinx-docs"
re-builds fish.

In future "fish_indent" should not depend on "crates/build-man-pages".
Until then, a following commit wants to break this cyclic dependency
in a different way: we won't embed man pages (matching historical
behavior), which means that CMake builds won't need to run
sphinx-build.

But sphinx-build is also used for extracting help sections.

Also, the fix for #12082 will use help sections elsewhere in the code.

Prepare to remove the dependency on doc_src by committing the help
sections (we already do elsewhere).
2025-11-23 12:30:22 +01:00
Johannes Altmanninger
95aeb16ca2 Remove embed-data feature flag
This mode still has some problems (see the next commit) but having
it behind a feature flag doesn't serve us. Let's commit to the parts
we want to keep and drop anything that we don't want.

To reduce diff noise, use "if false" in the code paths used by man
pages; a following commit will use them.
2025-11-23 12:30:22 +01:00
Johannes Altmanninger
4770ef2df8 Remove comment
There are lots of places that assume this.
2025-11-23 12:30:22 +01:00
Johannes Altmanninger
0ee0f5df97 Remove stale comment
See e895f96f8a (Do not rely on `fish_indent` for version in Sphinx, 2025-08-19).
2025-11-23 12:30:22 +01:00
Johannes Altmanninger
4f5cad977c release.yml: assert that Sphinx is installed on macOS package builder 2025-11-23 12:30:22 +01:00
Johannes Altmanninger
bed2da9b83 Check license of dependencies in CI 2025-11-23 12:30:22 +01:00
Johannes Altmanninger
462fa9077a Fix wcwidth() on systems without C.UTF-8 locale
macOS has en_US.UTF-8 but not C.UTF-8, which leads to a glitch when
typing "🐟". Fix that by trying the user's locale first, restoring
historical behavior.

Fixes 71a962653d (Be explicit about setlocale() scope, 2025-10-24).

Reported-by: Ilya Grigoriev <ilyagr@users.noreply.github.com>
2025-11-23 12:30:22 +01:00
Fabian Boehm
0f9749c140 docs/set: Try to make it a little clearer that you can also query -x
Fixes #12094
2025-11-23 09:59:52 +01:00
Johannes Altmanninger
acae88e618 test tmux-first-prompt: disable in ASAN
Tracking issue: #11815
Closes #12084
2025-11-21 08:21:11 +01:00
Fabian Boehm
75bf46de70 Disable posix_spawn on android
Apparently it's broken:

9cbb0715a9/packages/fish/0001-build.rs.patch

Part of #12055
2025-11-19 17:42:41 +01:00
Fabian Boehm
f598186574 Move posix_spawn detection to build.rs
This is *simpler*, and would have made us detect the issue with broken
includes before.

Part of #12055
2025-11-19 17:42:35 +01:00
Fabian Boehm
d99aa696db Fix includes for systems without posix_spawn
Fixes:

9cbb0715a9/packages/fish/0002-fix-import-when-posix-spawn-disabled.patch

Part of #12055
2025-11-19 17:42:17 +01:00
Johannes Altmanninger
790beedbb0 Prefer terminal (client) OS for selecting native key bindings
When running fish inside SSH and local and remote OS differ, fish
uses key bindings for the remote OS, which is weird.  Fix that by
asking the terminal for the OS name.

This should be available on foot and kitty soon, see
https://codeberg.org/dnkl/foot/pulls/2217#issuecomment-8249741

Ref: #11107
2025-11-19 17:13:58 +01:00
Johannes Altmanninger
b1e681030b Add OSC 133 prompt end marker
iTerm2 displays commands in other UI widgets such as in Command History
(View → Toolbelt → Command History).  This needs prompt end marker
so the terminal can distinguish prompt from the command line.

Closes #11837
2025-11-19 17:13:58 +01:00
Johannes Altmanninger
5225b477ff io: minor cleanup 2025-11-19 17:13:58 +01:00
Johannes Altmanninger
c53b787339 Don't try to use partially-parsed colors on error
Historically, "fish_color_*" variables used a hand-written option
parser that would try to recover from invalid options.

Commit 037c1896d4 (Reuse wgetopt parsing for set_color for internal
colors, 2025-04-13) tried to preserve this recovering, but that
breaks WGetopter invariants.

I don't think this type of fallback is important, because
there's no reason we can't parse color variables (except maybe
forward-compatibility in future). Let's turn errors into the default
style; this should tell the user that their color is unsupported.

Fixes #12078
2025-11-19 17:13:58 +01:00
Johannes Altmanninger
64cb4398c6 Longer timeout on invalid escape sequences
For historical reasons, fish does not implement the VT state
machine but uses a relatively low timeout when reading
escape sequences.  This might be causing issues like
https://github.com/fish-shell/fish-shell/issues/11841#issuecomment-3544505235
so let's cautiously increase the timeout.

Make it opt-in and print a noisy error when we time out, so we can
find affected terminals.
2025-11-19 17:13:58 +01:00
Johannes Altmanninger
9165251a0b Feature flag for eventually disabling terminal workarounds
We've removed several terminal-specific workarounds but also added
some recently.  Most of the non-Apple issues have been reported
upstream.  Many of our workarounds were only meant to be temporary.
Some workarounds are unreliable and some can cause introduce other
problems.

Add a feature flag we can use later to let users turn off workarounds.

This doesn't disable anything yet, mostly because because despite being
off-by-default, this might surprise people who use "fish_features=all".
The fix would be "fish_features=all,no-omit-term-workarounds".
So we'd want a high degree of confidence.

For now we'll use this only with the next commit.

Closes #11819
2025-11-19 17:06:25 +01:00
Johannes Altmanninger
7e86e07fb0 Rename method for reading trailing escape sequence bytes 2025-11-19 16:42:45 +01:00
Johannes Altmanninger
02a6afd2b0 Link terminal workarounds with comments
It's hard to get rid of these workarounds. Let's at least brand them.

Ref: #11819
2025-11-19 16:42:45 +01:00
Johannes Altmanninger
0b414b9662 __fish_print_help: proper error message when 'man' is missing
Commit 3f2e4b71bc (functions/__fish_print_help: bravely remove
fallback to mandoc/groff, 2025-11-09) savagely made commands like
"abbr -h" require man, or else it prints a noisy stack trace.
Some packages have not yet replaced "nroff/mandoc" with "man"
as dependency, and, independent of that, man is still an optional
dependency.

Make missing "man" a proper error, which is easier to read tan the
stack trace.
2025-11-19 16:40:57 +01:00
Johannes Altmanninger
012007ce7b Test balloon for ST OSC terminator
Use \e\\ as sequence terminator for the first OSC 133 prompt start
marker.  The intention is to find out if a terminal fails to parse
this. If needed, the user can turn it off by adding "no-mark-prompt"
to their feature flags; but the shell is still usable without this.

Part of #12032
2025-11-19 16:40:57 +01:00
Daniel Rainer
031d501381 history: move consts into function
These consts are only used in a single function, so they don't need to
be defined outside of the function.

c323a2d5fe (r170141065)

Closes #12075
2025-11-19 16:40:57 +01:00
Johannes Altmanninger
b0773890ea Fix inconsistent usage of /bin/sh vs. sh
For now, we mostly use "/bin/sh" for background tasks; but sometimes
we call it as "sh". The former does not work on android, but I'm not
yet sure how we should fix that.

Let's make things consistent first, so they are easier to change
(we might remove some background tasks, or reimplement them in fish
script).
2025-11-19 16:40:57 +01:00
Johannes Altmanninger
55b3b6af79 __fish_anypython: remove hardcoded list of minor versions
We always use python3 but don't use, say python3.999 until we update
our hardcoded list.  This is inconsistent (we're careful about the
latter but not the former).  Fix this by always picking the highest
minor version (>= 3.5+) there is. This also reduces maintenance work.

Note that NetBSD is the only OS we know about that doesn't provide
the python3 symlink OOTB.  In future, the NetBSD package should
add a patch to replace "python3" in __fish_anypython.fish
with the correct path.  Downstream discussion is at
https://mail-index.netbsd.org/pkgsrc-users/2025/11/17/msg042205.html
2025-11-19 16:40:57 +01:00
Johannes Altmanninger
1bcfc64e13 status list-files: support multiple arguments
This fixes an issue in fish_config, see
ee94272eaf (commitcomment-170660405)
2025-11-19 16:36:14 +01:00
Johannes Altmanninger
7b4802091a cmake: install fish_{indent,key_reader} as hardlinks to fish
As mentioned in
https://github.com/fish-shell/fish-shell/issues/11921#issuecomment-3540587001,
binaries duplicate a lot of information unnecessarily.

	$ cargo b --release
	$ du -h target/release/fish{,_indent,_key_reader}
	15M	target/release/fish
	15M	target/release/fish_indent
	4.1M	target/release/fish_key_reader
	34M	total

Remove the duplication in CMake-installed builds by creating hard
links. I'm not sure how to do that for Cargo binaries yet (can we
write a portable wrapper script)?

This is still a bit weird because hardlinks are rarely used like
this; but symlinks may cause issues on MSYS2.  Maybe we should write
a /bin/sh wrapper script instead.
2025-11-19 16:36:14 +01:00
Zhizhen He
7774c74826 Fix typos
Closes #12071
2025-11-19 16:36:14 +01:00
Johannes Altmanninger
97e58f381b Fix warning when libc::c_char is unsigned (ARM) 2025-11-19 16:36:14 +01:00
Johannes Altmanninger
015f247998 build.rs: use the correct target OS where easily possible
This might help cross-compilation; even if it doesn't matter in
practice, this is more correct.  While at it, get rid of $TARGET in
favor of the more accurate $CARGO_CFG_TARGET_OS.
Not yet sure how to do it for "has_small_stack".
2025-11-19 16:36:14 +01:00
Johannes Altmanninger
ef3923c992 Clean up cfg() definitions
Sort. Use idiomatic names. Use cfg_if.
2025-11-19 16:36:14 +01:00
Johannes Altmanninger
7fdb1b4d1f dir_iter: unexport a test-only getter 2025-11-19 16:36:14 +01:00
Juho Kuisma
fb83a86c17 Fix broken translations
Fixes 302c33e377 (Deduplicate and fix broken translations, 2025-11-16)
2025-11-16 19:16:07 +01:00
Johannes Altmanninger
289057f981 reset_abandoning_line: actually clear line on first prompt
Frequently when I launch a new shell and type away, my input is
echoed in the terminal before fish gets a chance to set shell modes
(turn off ECHO and put the terminal into non-canonical mode).

This means that fish assumption about the cursor x=0 is wrong, which
causes the prompt (here '$ ') to be draw at the wrong place, making
it look like this:

	ececho hello

This seems to have been introduced in 4.1.0 in a0e687965e (Fix
unsaved screen modification, 2025-01-14). Not sure how it wasn't a
problem before.

Fix this by clearing to the beginning of the line after turning off
ECHO but before we draw anything to the screen.

This turns this comment in the patch context into a true statement:

> This means that `printf %s foo; fish` will overwrite the `foo`

Note that this currently applies per-reader, so builtin "read" will
also clear the line before doing anything.
We could potentially change this in future, if we both
1. query the cursor x before we output anything
2. refactor the screen module to properly deal with x>0 states.

But even if we did that, it wouldn't change the fact that we want
to force x=0 if the cursor has only been moved due to ECHO, so I'm
not sure.
2025-11-16 11:47:47 +01:00
Johannes Altmanninger
b48106a741 reset_abandoning_line: extract function
Helps the next commit.
2025-11-16 11:33:11 +01:00
Johannes Altmanninger
fbad0ab50a reset_abandoning_line: remove redundant allocations 2025-11-16 11:33:11 +01:00
Johannes Altmanninger
a8bf4db32d release.sh: minor fixes
After pushing to the fish-site repo, make sure to update the local
repo's view of origin/master to what we have successfully pushed.
2025-11-16 11:33:11 +01:00
huaji2369
b33bad1258 add waydroid completions
Closes #12056
2025-11-16 11:27:02 +01:00
seg6
29024806e5 tests: minimum python version validation for user facing scripts
Adds [`Vermin`](https://github.com/netromdk/vermin) to make sure our
user facing Python scripts conform to the proper minimum Python version
requirements.

The tool parses Python code into an AST and checks it against a database
of rules covering Python 2.0-3.13.

Testing Python version compatibility is tricky because most issues only
show up at runtime. Type annotations like `str | None` (Python 3.10+)
compile just fine (under pyc) and they don't throw an exception until
you actually call the relevant function.

This makes it hard to catch compatibility bugs without running the code
(through all possible execution paths) on every Python version.

Signed-off-by: seg6 <hi@seg6.space>

Closes #12044
2025-11-16 11:21:18 +01:00
seg6
4ef1f993a1 share: functions: __fish_anypython: update Python 3 version list
Signed-off-by: seg6 <hi@seg6.space>

Part of #12044
2025-11-16 11:21:18 +01:00
seg6
7297178091 share: tools: create_manpage_completions: drop Python 2 related code
Signed-off-by: seg6 <hi@seg6.space>

Part of #12044
2025-11-16 11:21:18 +01:00
seg6
3786c20dcf share: tools: web_config: drop Python 2 related code
Signed-off-by: seg6 <hi@seg6.space>

Part of #12044
2025-11-16 11:21:18 +01:00
Nahor
125fc142ba Add mutex around flock on Cygwin
Issue #11933 stems from Cygwin's flock implementation not being thread
safe. Previous code fixed the worst behavior (deadlock), at least in
some circumstance but still failed the history tests.

This new workaround correctly make flock usage thread safe by surrounding
it with a mutex lock.
The failing test can now pass and is much faster (5s instead of 15 on
my machine)

Upstream bug report: https://cygwin.com/pipermail/cygwin/2025-November/258963.html

Closes #12068
Closes #11933
2025-11-16 11:21:18 +01:00
exploide
d716b32bed completions/john: updated and improved completions
Closes #12051
2025-11-16 11:21:18 +01:00
Daniel Rainer
a56b1099aa tempfile: use std::env:temp_dir
This is a more robust implementation of our custom `get_tmpdir`.

Closes #12046
2025-11-16 11:21:18 +01:00
Johannes Altmanninger
f3f231cf70 __fish_apropos: assume only /usr/bin/apropos is broken
As discovered in #12062, man-db as installed from brew is not affected
by the "read-only-filesystem" problem what makewhatis suffers from
(though users do need to run "gmandb" once).

Restrict the workaround to the path to macOS's apropos; hopefully
that's stable.

This breaks people who define an alias for apropos; I guess for those
we could check "command -v" instead, but that's weird because the thing
found by type is the actual thing we're gonna execute.  So I'd first
rather want to find out why anyone would override this obscure command.
2025-11-16 11:21:18 +01:00
Johannes Altmanninger
c49ff931b1 __fish_apropos: remove stale version check
Most macOS versions are affeced nowadays.  Let's make this more
predictable by applying the workaround to them all.
2025-11-16 11:12:30 +01:00
Johannes Altmanninger
d3c3dfda7d Extract workaround for calling man/apropos without manpager
See ec939fb22f (Work around BSD man calling pager when stdout is
not a TTY, 2024-10-30).
2025-11-16 11:12:30 +01:00
Juho Kuisma
302c33e377 Deduplicate and fix broken translations
Co-authored-by: Johannes Altmanninger <aclopte@gmail.com>
2025-11-16 11:12:30 +01:00
Johannes Altmanninger
e77b1c9744 __fish_cached: tolerate trailing newline
In POSIX sh, ";" is not a valid statement, leading to errors when the
__fish_cached callback argument has a trailing newline (5c2073135e
(Fix syntax error in __fish_print_port_packages.fish, 2025-11-14)).

Use a newline instead of ";", to avoid this error.

While at it, replace rogue tab characters.
2025-11-16 11:04:23 +01:00
Tair Sabirgaliev
5c2073135e Fix syntax error in __fish_print_port_packages.fish
Fixes #12063 

NOTE: I'm not fish expert, please suggest a better way/place to fix this
2025-11-14 18:25:18 +01:00
Juho Kuisma
58cc0ad760 Update all translations 2025-11-14 23:30:12 +08:00
Juho Kuisma
41387a6a3a Fix funced error message when $VISUAL is set 2025-11-14 23:30:12 +08:00
Fabian Boehm
ee94272eaf fish_config: Remove superfluous grep
`grep -Fx` will match fixed strings over the entire line.

`status list-files foo` will match anything that starts with "foo".

Since we always pass a suffix here, that's the same thing.
If we really cared, we could do `string match "*.$suffix"` or similar.

Fixes #12060
2025-11-14 16:13:43 +01:00
Johannes Altmanninger
dd6000f1fd start new cycle
Created by ./build_tools/release.sh 4.2.1
2025-11-13 13:32:43 +01:00
Johannes Altmanninger
3bc896bd89 Release 4.2.1
Created by ./build_tools/release.sh 4.2.1
2025-11-13 13:09:28 +01:00
Johannes Altmanninger
80b46fbc28 release.sh: create next minor version milestone
Also stop creating patch milestones automatically. The Web UI doesn't
allow deleting them, only the API does.
2025-11-13 13:06:23 +01:00
Johannes Altmanninger
b9af3eca9f Include prebuilt man pages again
Historically, Sphinx was required when building "standalone" builds,
else they would have no man pages.

This means that commit 0709e4be8b (Use standalone code paths by
default, 2025-10-26) broke man pages for users who build from a
tarball where non-standalone builds would use prebuilt docs.

Add a hack to use prebuilt docs again.

In future, we'll remove prebuilt docs, see #12052.
2025-11-13 12:58:29 +01:00
王宇逸
840efb76d0 zh_TW: fill tier1 translations
Co-authored-by: Lumynous <lumynou5.tw@gmail.com>

Closes #12043
2025-11-13 12:57:01 +01:00
王宇逸
8a845861f3 zh_CN: fill tier1 translations
Co-authored-by: Lumynous <lumynou5.tw@gmail.com>

Part of #12043
2025-11-13 12:57:01 +01:00
Johannes Altmanninger
39d6443b6b github sponsors link
In future we should make an opencollective or liberapay team.
2025-11-13 12:57:01 +01:00
Johannes Altmanninger
1c9d4e77df Fix webconfig import
Fixes 78f71971cb (fix: Python 3.5+ compatibility in webconfig.py
type hints, 2025-11-09).
Fixes #12053
2025-11-12 09:55:22 +01:00
Johannes Altmanninger
15f9d6d279 start new cycle
Created by ./build_tools/release.sh 4.2.0
2025-11-10 10:19:14 +01:00
Johannes Altmanninger
cf2f7eb785 CI: remove tmate used for debugging
Also remove dead code selecting pip version
2025-11-10 10:15:48 +01:00
Johannes Altmanninger
e7d740785d tests/help-completions: fix for macOS awk 2025-11-10 10:15:48 +01:00
Johannes Altmanninger
8cc25fe772 tests/man: work around man idiosyncracy on macOS/FreeBSD
This man implementation fails to remove control characters when stdout
is not a TTY. Upstream tracking issue:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=282414
2025-11-10 10:15:48 +01:00
Johannes Altmanninger
896f0606cd Release 4.2.0
Created by ./build_tools/release.sh 4.2.0
2025-11-10 08:19:40 +01:00
Johannes Altmanninger
2649f8d591 tests/sphinx-markdown-changelog: also disable when pushing a tag
Also, fix the command that should only filter out the current tag.
2025-11-10 08:18:53 +01:00
Johannes Altmanninger
e77102d73e Install Sphinx in macOS CI/CD
Looks like macOS packages didn't have docs??
I noticed via our Cargo warning about sphinx-build.

macOS has a variety of pythons installed:

	bash-3.2$ type -a python python3
	python is /Library/Frameworks/Python.framework/Versions/Current/bin/python
	python3 is /opt/homebrew/bin/python3
	python3 is /usr/local/bin/python3
	python3 is /Library/Frameworks/Python.framework/Versions/Current/bin/python3
	python3 is /usr/bin/python3

by default, "uv --no-managed-python" uses python3 (homebrew), but
"python" (and "pip") use the other one.  Make uv use the same as
our scripts.  Not all uv commands support "--python" today, so set
UV_PYTHON.
2025-11-10 08:18:53 +01:00
Johannes Altmanninger
ac94bc774b Update changelog 2025-11-10 07:28:35 +01:00
Johannes Altmanninger
83eca32111 release.sh: build local tarball with pinned Sphinx versions
Use the pinned versions of Sphinx + dependencies, for reproducibility
and correctness. (Specifically, this gives us proper OSC 8
hyperlinks when /bin/sphinx-build is affected by a packaging bug,
see https://github.com/orgs/sphinx-doc/discussions/14048)
2025-11-10 07:28:35 +01:00
Johannes Altmanninger
f5662d578e release-notes.sh: extract authors from trailers
Ideally we want to credit reported-by/helped-by etc. but we'd need
to ask the GitHub API for this information.

Also we should use %(trailers) if possible.
2025-11-10 07:02:08 +01:00
Daniel Rainer
80363314aa cleanup: remove obsolete comments
These comments were made obsolete in c323a2d5fe
("Continued refactoring of history", 2025-11-09)

Closes #12041
2025-11-10 07:02:08 +01:00
Daniel Rainer
6ce3bb858d cleanup: fix swapped comments
Part of #12041
2025-11-10 07:02:08 +01:00
Daniel Rainer
1c34fb064a cleanup: remove obsolete comment
This comment should have been removed in 3736636d99
("msrv: update to Rust 1.85", 2025-10-19)

Part of #12041
2025-11-10 07:02:08 +01:00
Johannes Altmanninger
366b85beb2 completions/help: fix bad description
Fixes 2cd60077e6 (help: get section titles from Sphinx, 2025-11-05).
2025-11-09 22:20:52 +01:00
Peter Ammon
82038e236d Revert "Add history file format internal docs"
This reverts commit 458fe1be2f.

This was a proposal which ought not to have been pushed.
2025-11-09 10:47:31 -08:00
Peter Ammon
f72fc7f09b Remove HistoryIdentifier
HistoryIdentifier was an over-engineered way of annotating history items
with the paths that were found to be valid, for autosuggestion hinting.
It wasn't persisted to the file. Let's just get rid of this.
2025-11-09 10:37:05 -08:00
Peter Ammon
c323a2d5fe Continued refactoring of history
Use fstat() instead of lseek() to determine history file size.
Pass around the file_id instead of recomputing it.

This saves a few syscalls; no behavior change is expected.
2025-11-09 10:03:45 -08:00
Peter Ammon
662b55ee6b Continue refactoring history
Simplify some logic and group related items together.
2025-11-09 10:03:45 -08:00
Peter Ammon
2e92255032 Factor history item offsets into an iterator
More idiomatic.
2025-11-09 10:03:45 -08:00
Peter Ammon
5182901bcc Factor history files better
Preparation for eventually cleaning this up. No user-visible changes
expected.
2025-11-09 10:03:45 -08:00
Peter Ammon
248eb2eb4a Move history.rs into its own module 2025-11-09 10:03:45 -08:00
Peter Ammon
458fe1be2f Add history file format internal docs 2025-11-09 10:03:45 -08:00
Johannes Altmanninger
8589231742 functions/__fish_print_help: work around for FreeBSD's man missing -l
This fixes "man abbr" on macOS and FreeBSD.

Upstream feature request:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=290911

Note that this workarond requires another one, copied from ec939fb22f
(Work around BSD man calling pager when stdout is not a TTY,
2024-10-30).

Closes #12037
2025-11-09 13:10:46 +01:00
Johannes Altmanninger
59658b44a9 functions/man: reuse __fish_print_help for viewing built-in man-pages
Historically,
- our "man" wrapper prepends /usr/share/fish/man to $MANPATH
- "__fish_print_help" only operates on /usr/share/fish/man, to it
  accesses that directly

However standalone builds -- where /usr/share/fish/man may not exist
-- have complicated things; we temporarily materialize a fake man
directory.

Reuse __fish_print_help instead of duplicating this.

Part of #12037
2025-11-09 13:08:47 +01:00
Johannes Altmanninger
3f2e4b71bc functions/__fish_print_help: bravely remove fallback to mandoc/groff
I don't know if anyone has installed mandoc/groff but not man.
Since 4.1 we officially require "man" as dependency (hope that works
out; we're missing some standardization, see #12037).  Remove the
fallback with the old mandoc/nroff logic.  This makes the next commit
slightly simpler -- which is not enough reason by itself, but we want
to do this anyway at some point.
2025-11-09 13:08:47 +01:00
Johannes Altmanninger
9b42051ba7 functions/man: don't export MANPATH unnecessarily
We always try to prepend our man path to $MANPATH before calling man.
But this is not necessary when we're gonna display the output of
"status get-file man/man1/abbr.1".

Overriding man pages can cause issues like
https://github.com/fish-shell/fish-shell/issues/11472
https://gitlab.com/man-db/man-db/-/merge_requests/15

which by themselves are maybe not enough reason to avoid exporting
MANPATH, but given that embedded man pages might become the only
choice in future (see #12037), we should reduce the scope of our
custom MANPATH.
2025-11-09 13:08:47 +01:00
Johannes Altmanninger
674e93d127 functions/{__fish_print_help,man}: extract function for resolving builtin docs
These are code clones, apart from the fact that __fish_print_help
doesn't have the '{' case, because alt-h/f1 will never find that.
But adding it doesn't really hurt because it's unlikely that the user
will have a manpage for '{'. Extract a function.
2025-11-09 13:08:47 +01:00
Johannes Altmanninger
b1472827e7 Update BSD sourcehut images
Part of #12037
2025-11-09 13:08:47 +01:00
Daniel Rainer
856e649487 zh_TW.po: remove empty comments
These were added automatically when we used the `--strict` flag with
gettext commands. We stopped using this flag, but existing empty
comments are not automatically deleted, so it is done here manually.

Closes #12038
2025-11-09 13:08:47 +01:00
Johannes Altmanninger
bc71a1662d Update changelog 2025-11-09 13:08:47 +01:00
Johannes Altmanninger
33bf808084 fish_tab_title: fix tab title accidentally including window title
Also use the correct OSC number.

Note that this only works on few terminals (such as iTerm2).  Not sure
if it's worth for us to have this feature but I guess multiple users
have requested it.
2025-11-09 13:08:47 +01:00
seg6
78f71971cb fix: Python 3.5+ compatibility in webconfig.py type hints
Signed-off-by: seg6 <hi@seg6.space>

Closes #12039
Closes #12040
2025-11-09 13:04:05 +01:00
ridiculousfish
b4fc5160ba Set FISH_TEST_NO_CURSOR_POSITION_QUERY in pexpect tests
This was causing query timeouts with high parallelism in the tests.
2025-11-08 18:28:41 -08:00
SandWood Jones
9d3acbdd82 fix(abbr) --command conflicts
Fixes #11184

Closes #12021
2025-11-08 21:24:28 +01:00
Johannes Altmanninger
873ede7a77 CONTRIBUTING: modernize
The section on build_tools/style.fish was stale.  That tool does not
automagically format unstaged changes or the last commit's changes
anymore.  Relying on such tools is bad practice anyway, people should
configure their editor to fix the style violations at the source.
Replace "before committing" with neutral phrasing.

Remove the redundant mention of "cargo fmt" and "clippy".  Use of
clippy goes without saying for Rust projects.  Instead, add another
mention of "build_tools/checks" which also does clippy as well as
translation update checks (which are commonly needed).

Drop the "testing with CMake" part since it's a legacy thing and
basically never needed, especially by new faces.

Use semantic line breaks in the paragraphs starting at "When in doubt".
2025-11-08 21:24:28 +01:00
Johannes Altmanninger
d7581dbaa4 CONTRIBUTING: remove Git pre-push hook
- this is not specific to fish and only relevant to people who push
  directly to master
- we don't push directly to master as often anymore
- I don't think we used it much in practice (when we should have).
- a good portion of contributions is pushed with jj which probably
  does this differently

Let's remove it even though this is a nice piece of documentation.
I guess we could add it back to doc_internal/ if we have the capacity
to maintain it.
2025-11-08 21:21:13 +01:00
Daniel Rainer
71e4d7ba87 tempfile: utilize new tempfile crate
Closes #12029
2025-11-08 21:18:25 +01:00
Daniel Rainer
46f7f47bda util: add crate for creating tempfiles
ja: the motivation for our own crate is
1. the tempfile crate is probably overkill for such a small
   piece of functionality (given that we already assume Unix)
2. we want to have full control over the few temp files we
   do create

Closes #12028
2025-11-08 21:18:25 +01:00
Johannes Altmanninger
4046df7412 Disable parallelism in macOS CI
Since the parent commit, these tests fail repeatedly in macOS GitHub
Actions CI: complete-group-order.py, nullterm.py, scrollback.py and
set_color.py. They run fine in isolation.

We'll fix the flaky system tests soon (#11815) but until then, remove
parallelism from macOS CI.
2025-11-08 21:18:25 +01:00
Johannes Altmanninger
a772470b76 Multi-line autosuggestions
Unlike other shells, fish tries to make it easy to work with multiline
commands. Arguably, it's often better to use a full text editor but
the shell can feel more convenient.

Spreading long commands into multiple lines can improve readability,
especially when there is some semantic grouping (loops, pipelines,
command substitutions, quoted parts). Note that in Unix shell, every
quoted string can span multiple lines, like Python's triple quotes,
so the barrier to writing a multiline command is quite low.

However these commands are not autosuggested. From
1c4e5cadf2 (commitcomment-150853293)

> the reason we don't offer multi-line autosuggestion is that they
> can cause the command line to "jump" to make room for the second
> and third lines, if you're at the bottom of your terminal.

This jumping (as done by nushell for example) might be surprising,
especially since there is no limit on the height of a command.

Let's maybe avoid this jumping by rendering only however many lines
from the autosuggestion can fit on the screen without scrolling.

The truncation is hinted at by a single ellipsis ("…") after the
last suggested character, just like when a single-line autosuggestion
is truncated. (We might want to use something else in future.)

To implement this, query for the cursor position after every command,
so we know the y-position of the shell prompt within the terminal
window (whose height we already know).

Also, after we register a terminal window resize, query for the cursor
position before doing anything else (until we od #12004, only height
changes are relevant), to prevent this scenario:

	1. move prompt to bottom of terminal
	2. reduce terminal height
	3. increase terminal height
	4. type a command that triggers a multi-line autosuggestion
	5. observe that it would fail to truncate properly

As a refresher: when we fail to receive a query response, we always
wait for 2 seconds, except if the initial query had also failed,
see b907bc775a (Use a low TTY query timeout only if first query
failed, 2025-09-25).

If the terminal does not support cursor position report (which is
unlikely), show at most 1 line worth of autosuggestion.  Note that
either way, we don't skip multiline commands anymore.  This might make
the behavior worse on such terminals, which are probably not important
enough.  Alternatively, we could use no limit for such terminals,
that's probably the better fallback behavior. The only reason I didn't
do that yet is to stay a little bit closer to historical behavior.

Storing the prompt's position simplifies scrollback-push and the mouse
click handler, which no longer need to query.  Move some associated
code to the screen module.

Technically we don't need to query for cursor position if the previous
command was empty. But for now we do, trading a potential optimization
for andother simplification.

Disable this feature in pexpect tests for now, since those are still
missing some terminal emulation features.
2025-11-08 21:18:25 +01:00
Johannes Altmanninger
e1ce53fe15 screen: fix inconsistent initialization order 2025-11-08 21:18:25 +01:00
Johannes Altmanninger
77bdd4fbde reader: use unqualified enum variants in match statement
This reduces noise although the indentation is not great.
2025-11-08 21:18:25 +01:00
Johannes Altmanninger
3fdaa543ed reader: remove unused parameter 2025-11-08 21:18:25 +01:00
Johannes Altmanninger
336be1e36d termsize: better types
The u16 is implied by libc::winsize.
2025-11-08 21:18:25 +01:00
Johannes Altmanninger
382027663f termsize: try to simplify a little bit
Also add "safe_" prefix to functions we require to be
async-signal-safe.
2025-11-08 21:18:25 +01:00
Johannes Altmanninger
1d58b84637 mouse handling: fish's screen always starts at x=0
We already assume elsewhere that e.g. \r will return us to x=0
(fish coordinates).
2025-11-08 21:18:25 +01:00
Johannes Altmanninger
88ead18709 Move query-interrupt event-variant into query-result enum
I think the interruption event is grouped next to the check-exit one
because it used to be implemented as check exit but with a global flag
(I didn't check whether that applied to master).

Move it to the logical place.
2025-11-08 21:18:25 +01:00
Johannes Altmanninger
70058bdee2 reader: remove unused check
The readline state is never finished before the very first loop
iteration.  Move the check for rls.finished next to the one that
implements "read -n1" -- in future we might use the return value
for both.
2025-11-08 21:18:25 +01:00
Johannes Altmanninger
d1c85966d9 __fish_echo: fully overwrite lines, take 2
For the same reason as before (upcoming multi-line autosuggestions),
reapply 1fdf37cc4a (__fish_echo: fully overwrite lines, 2025-09-17)
after it was reverted in b7fabb11ac (Make command run by __fish_echo
output to TTY for color detection, 2025-10-05)
 (Make command run by __fish_echo output
to TTY for color detection, 2025-10-05).  Use clear-to-end-of-screen
to allow making "ls" output directly to the terminal.

Alternatively, we could create a pseudo TTY (e.g. call something like
"unbuffer ls --color=auto").
2025-11-08 21:18:25 +01:00
Daniel Rainer
0679d98950 printf: do not check for I flag
This flag is not supported by our sprintf, so remove it here, to avoid
suggesting that it might be supported.

Closes #11874
2025-11-08 21:18:25 +01:00
Johannes Altmanninger
a8b7d89ba5 doc terminal-compatibility: document Unicode characters used in output
Not sure if this will be useful but the fact that we use very
few Unicode characters, suggests that we are insecure about
this. Having some kind of central and explicit listing might help
future decision-making.  Obviously, completions and translations use
more characters, but those are not as central.
2025-11-08 21:18:25 +01:00
Fabian Boehm
828773b391 __fish_print_help: Also add "-l"
mandoc refuses to open files without.

See #12037
2025-11-08 15:30:47 +01:00
John Paul Adrian Glaubitz
35f4eb8e9a Fix build on Linux/SPARC by disabling SIGSTKFLT 2025-11-08 14:56:25 +01:00
Fabian Boehm
8c69e62a78 terminal-compatibility: Remove "Origin" column
This isn't very useful, makes the table very wide and invites discussion on who exactly invented
what.

Let's leave that to the historians.

Fixes #12031
2025-11-08 14:54:57 +01:00
Fabian Boehm
8e4fa9aafb functions/man: Pass "-l" to get man to open a file
Supported by mandoc, man-db and NetBSD man, and mandoc now requires
this.

Fixes #12037
2025-11-08 14:50:10 +01:00
Johannes Altmanninger
d6ed5f843e fish_tab_title to set terminal tab title independent of window title
Some modern terminals allow creating tabs in a single window;
this functionality has a lot of overlap with what a window manager
already provides, so I'm not sure if it's a good idea.  Regardless,
a lot of people still use terminal tabs (or even multiple levels of
tabs via tmux!), so let's add a fish-native way to set the tab title
independent of the window title.

Closes #2692
2025-11-06 13:02:23 +01:00
Daniel Rainer
ba7bc2be13 cleanup: remove unused variable
Closes #12023
2025-11-06 13:02:23 +01:00
ken
199475b6ca Stop disabling mouse tracking
Commit eecc223 (Recognize and disable mouse-tracking CSI events,
2021-02-06) made fish disable mouse reporting whenever we receive a
mouse event.  This was because at the time we didn't have a parser
for mouse inputs.  We do now, so let's allow users to toggle mouse
support with

	printf '\e[?1000h'
	printf '\e[?1000l'

Currently the only mouse even we support is left click (to move cursor
in commandline, select pager items).

Part of #4918
See #12026

[ja: tweak patch and commit message]
2025-11-06 13:02:23 +01:00
Johannes Altmanninger
60b50afefd Fix missing ICANON regression after read in noninteractive shell
Since commit 7e3fac561d (Query terminal only just before reading
from it, 2025-09-25),

	fish -c 'read; cat'

fails to turn ICANON back on for cat.

Even before that commit, I don't know how this ever worked.  Before or
after, we'd call tcsetattr() only to set our shell modes, not the
ones for external commands (term_donate)

I also don't think there's a good reason why we set modes twice
(between term_donate () and old_modes), but I'll make a minimal (=
safer) change for now until I understand this.

The only change from 7e3fac561d was that instead of doing things in
this order:

	terminal_init()
		set_shell_modes
	read
		reader_push()
		reader_readline()
			save & restore old_modes
	cat

we now do

	read
		reader_push()
			terminal_init()
				set_shell_modes()
		reader_readline()
			save & restore old_modes
	cat

So we call set_shell_modes() just before saving modes,
which obviously makes us save the wrong thing.
Again, not sure how that wasn't a problem before.

Fix it by saving modes before calling terminal_init().

Fixes #12024
2025-11-06 13:02:23 +01:00
Johannes Altmanninger
7aa64dc423 help: use "introduction" instead of "index" in user-visible section title
The new completions are like

	help index#default-shell

Add a hack to use the "introduction" here.

Not sure if this is worth it but I guess we should be okay because
we at least have test for completions.

In future, we should find a better way to declare that "introduction"
is our landing page.
2025-11-06 13:01:08 +01:00
Johannes Altmanninger
7a59540517 docs: use :doc: role when referencing entire pages
No need to define "cmd-foo" anchors; use :doc:`foo <cmds/foo>`
instead. If we want "cmd-foo" but it should be tested.

See also 38b24c2325 (docs: Use :doc: role when linking to commands,
2022-09-23).
2025-11-06 12:58:59 +01:00
Johannes Altmanninger
2cd60077e6 help: get section titles from Sphinx
functions/help and completions/help duplicate a lot of information
from doc_src. Get this information from Sphinx.

Drop short section titles such as "help globbing" in favor of the
full HTML anchor:

	help language#wildcards-globbing 

I think the verbosity is no big deal because we have tab completion,
we're trading in conciseness for consistency and better searchability.

In future, we can add back shorter invocations like "help globbing"
(especially given that completion descriptions often already repeated
the anchor path), but it should be checked by CI.

Also
- Remove some unused Sphinx anchors
- Remove an obsoleted script.
- Test that completions are in sync with Sphinx sources.
  (note that an alternative would be to check
  in the generated help_sections.rs file, see
  https://internals.rust-lang.org/t/how-fail-on-cargo-warning-warnings-from-build-rs/23590/5)

Here's a list of deleted msgids. Some of them were unused, for others
there was a better message (+ translation).

	$variable $variable 变量
	(command) command substitution (命令) 命令替换
	< and > redirections < 和 > 重定向
	Autoloading functions 自动加载函数
	Background jobs 后台作业
	Builtin commands 内建命令
	Combining different expansions 合并不同的展开
	Command substitution (SUBCOMMAND) 命令替换 (子命令)
	Defining aliases 定义别名
	Escaping characters 转义字符
	Help on how to reuse previously entered commands 关于如何重复使用先前输入的命令的帮助
	How lists combine 列表如何组合
	Job control 作业控制
	Local, global and universal scope 局域、全局和通用作用域
	Other features 其他功能
	Programmable prompt 可编程提示符
	Shell variable and function names Shell 变量和函数名
	Some common words 一些常用词
	The status variable 状况变量
	Variable scope for functions 函数的变量作用域
	Vi mode commands Vi 模式命令
	What set -x does `set -x` 做什么
	Writing your own completions 自己写补全
	ifs and elses if 和 else
	var[x..y] slices var[x..y] 切片
	{a,b} brace expansion {a,b} 大括号展开
	~ expansion ~ 展开


Closes #11796
2025-11-06 12:58:59 +01:00
Johannes Altmanninger
2c68a6704f Don't escape '#' in some cases where it's not necessary
This is useful for the next commit where tab completion produces
tokens like "foo#bar". Some cases are missing though, because we
still need to tell this function what's the previous character.
I guess next commit could also use a different sigil.
2025-11-06 12:58:59 +01:00
Johannes Altmanninger
cc95cef165 crates/build-man-pages: try to improve style 2025-11-06 12:08:10 +01:00
Johannes Altmanninger
cd76c2cb26 help/man: support \{ 2025-11-06 12:06:05 +01:00
Johannes Altmanninger
c586210306 help: more style changes
Seems better to propagate return code?
Otherwise only style changes.
2025-11-06 12:06:05 +01:00
Johannes Altmanninger
ec3cd4f4cb help: style changes and fixes 2025-11-06 12:06:05 +01:00
Johannes Altmanninger
eef5a7ff2b Use path to sphinx-build from CMake
Commit 0709e4be8b (Use standalone code paths by default, 2025-10-26)
made CMake builds enable the embed-data feature.  This means that
crates/build-man-pages/build.rs will run "sphinx-build" to create
man pages for embedding, now also for CMake builds.

Let's use the sphinx-build found by CMake at configuration-time.

This makes VARS_FOR_CARGO depend on cmake/Docs.cmake, so adjust the
order accordingly.
2025-11-05 17:34:21 +01:00
Johannes Altmanninger
988985727f Disable failing fish_config test for now
This has probably been failing intermittently in CI ever since it
was introduced. We have a reproducible test now, so let's disable
this test in CI for now to reduce noise.

See #12018
2025-11-04 14:48:40 +01:00
Shigure Kurosaki
dad58ac20a fix(edit_command_buffer): ignore cat alias
Signed-off-by: Shigure Kurosaki <shigure@hqsy.net>

Closes #12007
2025-11-04 14:13:22 +01:00
Johannes Altmanninger
3f9d8db5b7 builtin ulimit: extract function 2025-11-04 14:13:22 +01:00
Johannes Altmanninger
0b6afbd17b Prefer commandline case over same-length autosuggestion
If I run

	history append 'echo -X'

and type "echo -x", it renders as "echo -X".

This is not wrong but can be pretty confusing, (since the
autosuggestion is the same length as the command line).

Let's favor the case typed by the user in this specific case I guess.
Should add a full solution later.

Part of #11452
2025-11-04 14:13:22 +01:00
Daniel Rainer
e9936bc5ed cleanup: use let-else to reduce indentation
Closes #12019
2025-11-04 11:51:25 +01:00
Daniel Rainer
068a1ab95c refactor: make wwrite_to_fd more idiomatic
There is no need to use `'\0'`, we can use `0u8` instead.

`maxaccum` does not clearly indicate what it represents; use
`accum_capacity` instead.

To get the size of `accum`, we can use `accum.len()`, which is easier to
understand.

Use `copy_from_slice` instead of `std::ptr::copy`. This avoids the
unsafe block, at the cost of a runtime length check. If we don't want
this change for performance reasons, we might consider using
`std::ptr::copy_nonoverlapping` here (which is done by `copy_from_slice`
internally).

Part of #12008
2025-11-04 11:51:09 +01:00
Daniel Rainer
74d9a3537c gettext: fall back to all language variants
If a language is specified using only the language code, without a
region identifier, assume that the user prefers translations from any
variant of the language over the next fallback option. For example, when
a user sets `LANGUAGE=zh:pt`, assume that the user prefers both `zh_CN` and
`zh_TW` over the next fallback option. The precedence of the different
variants of a language will be arbitrary. In this example, with the
current set of relevant available catalogs (`pt_BR`, `zh_CN`, `zh_TW`),
the effective precedence will be either `zh_CN:zh_TW:pt_BR` or
`zh_TW:zh_CN:pt_BR`.

Users who want more control over the order can
specify variants to get the results they want.
For example:
- `LANGUAGE=zh_TW:zh:pt` will result in `zh_TW:zh_CN:pt_BR`.
- `LANGUAGE=zh_CN:pt:zh` will result  in `zh_CN:pt_BR:zh_TW`.
- `LANGUAGE=zh_CN:pt` will result  in `zh_CN:pt_BR`.
English is always used as the last fallback.

This approach (like the previous approach) differs from GNU gettext
semantics, which map region-less language codes to on specific "default"
variant of the language, without specifying how this default is chosen.
We want to avoid making such choices and believe it is better to utilize
translations from all language variants we have available when users do
not explicitly specify their preferred variant. This way, users have an
easier time discovering localization availability, and can be more
explicit in their preferences if they don't like the defaults.
If there are conflicts with gettext semantics, users can also set locale
variables without exporting them, so fish uses different values than its
child processes.

Closes #12011
2025-11-03 17:13:42 +00:00
Johannes Altmanninger
143a4aca0f Readme: fix RST syntax 2025-11-03 09:17:00 +01:00
Johannes Altmanninger
20e66ad990 Add workaround for terminals confused by MSYS2 paths
Some terminals handle invalid OSC 7 working directories by falling
back to the home directory, which is worse than if they didn't support
OSC 7.  Try to work arond the common case (when $MSYSTEM is set).

	local wezterm = require 'wezterm'
	local config = wezterm.config_builder()
	config.default_prog = {
	     'C:\\msys64\\msys2_shell.cmd',
	    '-ucrt64',
	    '-defterm',
	    '-here',
	    '-no-start',
	    '-shell', 'fish'
	}
	config.default_cwd = 'C:\\msys64\\home\\xxx'
	return config

Upstream issues:
- https://github.com/wezterm/wezterm/discussions/7330
- https://invent.kde.org/utilities/konsole/-/merge_requests/1136

Closes #11981
2025-11-03 09:17:00 +01:00
Johannes Altmanninger
ceec382161 Disable repaint on WINCH again for VTE/Konsole/WezTerm
This was accidentally turned on because c31e769f7d (Use XTVERSION for
terminal-specific workarounds, 2025-09-21) used the wrong argument
order.  Fix that.
2025-11-03 09:17:00 +01:00
Johannes Altmanninger
782916930a Work around failing asan tests
I could reproduce both
tests/checks/tmux-empty-prompt.fish
tests/pexpects/autosuggest.py

failing in ASan CI. I didn't bisect it, since I don't think there is
a problematic code change. Bump the timeout a bit.

Closes #12016
2025-11-03 09:17:00 +01:00
Johannes Altmanninger
a767739c06 doc terminal-compatibility: fix inconsistent parameter wildcard notation 2025-11-03 09:17:00 +01:00
Peter Ammon
cf3c9d75d7 Don't run the man check test if FISH_BUILD_DOCS is 0 2025-11-01 13:12:58 -07:00
Peter Ammon
1846d7fd7e Merge branch 'cleanup-thread-pool'
This merges changes that make thread pools instanced. We no longer have
a single global thread pool. This results in significant simplifications
especially in the reader (no more "canary").
2025-11-01 11:46:25 -07:00
Johannes Altmanninger
b8c7ee3a85 Fix Dockerfile syntax
Enigmatic error:

	   1 | >>> FROM alpine:3.22 # updatecli.d/docker.yml
	ERROR: failed to build: failed to solve: dockerfile parse error on line 1: FROM requires either one or three arguments

Fixes daadd81ab6 (More automation for updating dependencies, 2025-10-31).
2025-11-01 13:11:33 +01:00
Johannes Altmanninger
0709e4be8b Use standalone code paths by default
When users update fish by replacing files, existing shells might
throw weird errors because internal functions in share/functions/
might have changed.

This is easy to remedy by restarting the shell,
but I guess it would be nice if old shells kept using old data.
This is somewhat at odds with lazy-loading.

But we can use the standalone mode.  Turn that on by default.

Additionally, this could simplify packaging.  Some packages incorrectly
put third party files into /usr/share/fish/completion/ when they ought
to use /usr/share/fish/vendor_completions.d/ for that.  That packaging
mistake can make file conflicts randomly appearing when either fish
or foo ships a completion for foo.  Once we actually stop installing
/usr/share/fish/completions, there will no longer be a conflict (for
better or worse, things will silently not work, unless packagers
notice that the directory doesn't actually exist anymore).

The only advantage of having /usr/share/fish/ on the file system is
discoverability. But getting the full source code is better anyway.

Note that we still install (redundant) $__fish_data_dir when using
CMake.  This is to not unnecessarily break both
1. already running (old) shells as users upgrade to 4.2
2. plugins (as mentioned in an earlier commit),

We can stop installing $__fish_data_dir once we expect 99% of users
to upgrade from at least 4.2.

If we end up reverting this, we should try to get rid of the embed-data
knob in another way, but I'm not sure how.

Closes #11921

To-do:
- maybe make it a feature flag so users can turn it off without
  recompiling with "set -Ua no-embed-data".
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
328f9a9d16 Readme: reword the "Building fish with Cargo" section
The next commit will make embed-data the default also for CMake builds.

Even if we revert that, from a user perspective we better call it
"Building fish with Cargo" rather than "Building fish with embedded
data".

While at it, let's list the user-facing differences when building
with Cargo as opposed to CMake.

I suppose it's not needed to mention :

> An empty ``/etc/fish/config.fish`` as well as empty directories
> ``/etc/fish/{functions,completions,conf.d}``

because that's obvious.

Since installation via Cargo is already aimed at developers, maybe
add "uv run" here to reliably install a recent version of Sphinx.
A small extra step up-front seems better than not having docs.
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
1d9233abc7 Fix CMake build with embed-data 2025-11-01 12:58:13 +01:00
Johannes Altmanninger
c9cc2a4069 config_paths: inline function again
Now that the dust has settled, there is only one caller of the path
detection logic, so we don't need the enum.  Remove it.  No functional
change.
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
e0a2fa35cc Define __fish_{data,help}_dir again on standalone builds
As mentioned in a previous commit ("Don't special-case __fish_data_dir
in standalone builds"), we want to enable embed-data by default.
To reduce the amount of breakage, we'll keep installing files,
and keep defining those variables at least for some time.

We have no use for $__fish_data_dir apart from helping plugins and
improving upgrade experience, but we still use $__fish_help_dir;
so this will allow installed "standalone" builds to use local docs
via our "help" function.
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
da5a57890a env: extract function for setting our config path variables
While at it, reorder the assignments to match the order in ConfigPaths.
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
c7772db4fb build.rs: remove unused LOCALEDIR override
Implied by bee1e122f9 (Remove unused locale path code, 2025-09-16).
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
f00b775172 config_paths: remove unused clone() 2025-11-01 12:58:13 +01:00
Johannes Altmanninger
a5cbbd7f10 Revert "config_paths: separate ifdef'd path logic into functions"
To prepare for defining __fish_data_dir/__fish_help_dir again on
embed-data builds, reverts commit 04a2398c90. No functional change.
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
c409e816df Don't branch on __fish_data_dir[1] in standalone builds
We use absence of "$__fish_data_dir[1]" as criteria to use the
"standalone" code paths that use "status list-files/get-file" instead
of $__fish_data_dir.

However, third party software seems slow to react to such breaking
changes, see https://github.com/ajeetdsouza/zoxide/issues/1045

So keep $__fish_data_dir for now to give plugins more time.
This commit makes us ignore $__fish_data_dir on standalone builds
even if defined; a  following commit will actually define it again.

I guess the approach in b815fff292 (Set $__fish_data_dir to empty
for embed-data builds, 2025-04-01) made sense back when we didn't
anticipate switching to standalone builds by default yet.
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
8d02987c64 config_paths: reduce differences between standalone/installed builds
Some packagers such as Homebrew use the "relocatable-tree" logic,
i.e. "fish -d config" shows paths like:

	/usr/local/etc/fish
	/usr/local/share/fish

Other packagers use -DSYSCONFDIR=/etc, meaning we get

	/etc/fish
	/usr/share/fish

which we don't treat as relocatable tree,
because "/usr/etc/fish" does **not** exists.

To get embed-data in shape for being used as a default for installed
builds, we want it to support both cases.

Today, embed-data builds only handle the "in-build-dir" logic.
Teach them also about the relocatable-tree logic.  This will make
embed-data builds installed via Homebrew (i.e. CMake) use the correct
sysconfdir ("/usr/local/etc").

This means that if standalone fish is moved to ~/.local/bin/fish
and both ~/.local/share/fish as well as ~/.local/etc/fish exist,
fish will use the relocatable tree paths.

But only embedded files will be used, although a following commit will
make standalone builds define $__fish_data_dir and $__fish_help_dir
again; the latter will be used to look up help.
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
e091bc3ba2 config_paths: rename "base_path" to "prefix"
This matches the convention used by Make/CMake and others.
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
4f9c9b5be4 build.rs: sysconf dir defaults to $prefix/etc, not $prefix/share/etc
(This doesn't matter in practice because we always override SYSCONFDIR
in CMake builds.)

According to https://cmake.org/cmake/help/latest/command/install.html
default paths look like

	Type    variable                    default
	INCLUDE ${CMAKE_INSTALL_INCLUDEDIR} include
	SYSCONF ${CMAKE_INSTALL_SYSCONFDIR} etc
	DATA    ${CMAKE_INSTALL_DATADIR}    <DATAROOT dir>
	MAN     ${CMAKE_INSTALL_MANDIR}     <DATAROOT dir>/man

so "etc" is supposed to be a sibling of "include", not a child of DATA
(aka "share/").

This allows us to remove a hack where we needed to know the data dir
in non-standalone builds.
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
10e0515d50 Also embed __fish_build_paths.fish
Today, this file is only supported in CMake builds.  This is the only
place where CMake builds currently need $__fish_data_dir as opposed
to using "status get-file".

Let's embed __fish_build_paths so we can treat it like other assets.

This enables users of "embed-data" to do "rm -rf $__fish_data_dir"
(though that might break plugins).
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
bae735740c Rename FISH_BUILD_DIR variable, to assert that CMake is used
It's always the CMake output directory, so call it
FISH_CMAKE_BINARY_DIR. It's possible to set it via some other build
system but if such builds exist, they are likely subtly broken, or
at least with the following commit which adds the assumption that
"share/__fish_build_paths.fish.in" exists in this directory.

We could even call it CMAKE_BINARY_DIR but let's namespace it to make
our use more obvious. Also, stop using the $CMAKE environment variable,
it's not in our namespace.
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
3b0fa95870 embed-data: remove code clone
Seems to save only 1KiB in binary size (might be noise).
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
d4390c2fad Use cfg_if for embed-data checks 2025-11-01 12:58:13 +01:00
Johannes Altmanninger
9845074a53 create_manpage_completions: run for standalone builds too
On first startup, we run this script, but not for standalone
(embed-data) builds.  Rectify that.
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
e7dc1c4635 fish_update_completions: use status get-file instead of temp files
This helps the next commit.
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
07e26518fc create_manpage_completions: include deroff.py directly
Enables the next commit.
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
034b3b758d create_manpage_completions: ignore gcloud-* man pages
Google cloud CLI ships >10k man pages for subcommands, but the
completions are not useful because they don't know to replace
underscores by spaces, e.g. in:

	complete -c gcloud_access-approval_requests_approve

We also ship gcloud completions, so the generated ones should not
be used.
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
ea5d77ad6f tests/man: try to fix intermittent failure in CI
This failed once in Ubuntu CI because there was one extra space in
the first column (after "ABBR(1)").
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
cb320e17ed Sign releases again
The new automation workflow doesn't sign the Git tag or the tarball as
we used to.  Since the tag is still created locally, sign it directly.

For signing the tarball; build it locally and compare the extracted
tarball with the one produced by GitHub.

Closes #11996
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
ca8b18cad5 build_tools/make_tarball.sh: make it reproducible when building a tag
When building from a clean tag, set the date at the bottom of the
manpages to the tag creation date.  This allows to "diff -r" the
extracted tarball to check that CI produces the same as any other
system.

Part of #11996
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
aec459c795 Upgrade and pin Sphinx version
In future, we should ask "renovatebot" to update these version. I
don't have an opinion on whether to use "uv" or something else, but
I think we do want lockfiles, and I don't know of a natural way to
install Sphinx via Cargo.

No particular reason for this Python version.

Part of #11996
2025-11-01 12:58:13 +01:00
Johannes Altmanninger
13d62d5851 tests/sphinx-markdown-changelog: work around shallow clones in CI
GitHub CI uses shallow clones where no Git tags available, which
breaks tests/checks/sphinx-markdown-changelog.fish.

Somehow tests/checks/sphinx-markdown-changelog.fish doesn't seem to
have run CI before the next commit (or perhaps the python3 change
from commit "tests/sphinx-markdown-changelog: workaround for mawk",
2025-10-26?).

Anway, to prevent failure, disable that part of this test in CI
for now; the point of the test is mostly to check the RST->Markdown
conversion and syntax.
2025-11-01 12:55:01 +01:00
Johannes Altmanninger
d8516139c8 release-notes.sh: compute stats only when needed 2025-11-01 12:55:01 +01:00
Johannes Altmanninger
7f8263b625 release-notes.sh: simplify previous version computation 2025-11-01 12:55:01 +01:00
Johannes Altmanninger
daadd81ab6 More automation for updating dependencies
- Convert update checks in check.sh to mechanical updates.
  - Use https://www.updatecli.io/ for now, which is not as
    full-featured as renovatebot or dependabot, but I found it easier
    to plug arbitrary shell scripts into.
- Add updaters for
  - ubuntu-latest-lts (which is similar to GitHub Action's "ubuntu-latest").
  - FreeBSD image used in Cirrus (requires "gcloud auth login" for now,
    see https://github.com/cirruslabs/cirrus-ci-docs/issues/1315)
  - littlecheck and widecharwidth
- Update all dependencies except Cargo ones.
- As a reminder, our version policies are arbitrary and can be changed
  as needed.
- To-do:
  - Add updaters for GitHub Actions (such as "actions/checkout").
    Renovatebot could do that.
2025-11-01 12:55:01 +01:00
Johannes Altmanninger
c0b7167082 Remove unused docker images for frozen OS releases
Most of our docker images are for an OS release which is past EOL. Most
are not checked in CI, which leads to more staleness. It's not
obvious which docker are expected to work and which are best-effort.
I've updated all of them in the past, which would be slightly easier
if we got rid of the redundancy.

Remove most unused ones for now, to reduce confusion and maintenance
effort. Some Ubuntu images are replaced by
docker/ubuntu-latest-lts.Dockerfile
docker/ubuntu-oldest-supported.Dockerfile

Leave around the fedora:latest and opensuse/tumbleweed:latest images
for now, though I don't think there's a reason to publish them in
build_docker_images until we add CI jobs.

We can add some images back (even past-EOL versions) but preferrably
with a documentted update policy (see next commit) and CI tests
(could be a nightly/weekly/pre-release check).
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
ff50e761dd Upgrade sphinx-markdown-builder 2025-11-01 12:45:17 +01:00
Johannes Altmanninger
7c61fc5151 tests/sphinx-markdown-changelog: workaround for mawk
awk is mawk on Ubuntu.
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
ab39fab68c Fix a wrong path to fish_indent on OpenBSD
If fish is invoked as

	execve("/bin/fish", "fish")

on OpenBSD, "status fish-path" will output "fish".  As a result,
our wrapper for fish_indent tries to execute "./fish" if it exists.

We actually no longer need to call any executable, since "fish_indent"
is available as builtin now.

Stop using the wrapper, fixing the OpenBSD issue.
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
9953edb9ab config_paths: don't try to use "$PWD/fish" as exec path
As mentioned in earlier commits, "status fish-path" is either an
absolute path or "fish".  At startup, we try to canonicalize this
path. This is wrong for the "fish" case -- we'll do subtly wrong
things if a file with that name happens to exist in the current
working directory.
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
8d2dabbded Extract function for program name 2025-11-01 12:45:17 +01:00
Johannes Altmanninger
708703b9ec Reimplement should_suppress_stderr_for_tests() for some tests
"cargo test" captures stdout by default but not stderr.

So it's probably still useful to suppress test output like

	in function 'recursive1'
	in function 'recursive2'
	[repeats many times]

This was done by should_suppress_stderr_for_tests() which has been
broken. Fix that, but only for the relevant cases instead of setting
a global.
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
def9230ad6 fish-path: remove needless UTF-8 requirement and code clone
At least on our MSRV, strip_suffix() also exists for byte slices,
not just str.
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
4ef0e37011 status fish-path: remove dead code
This value is either "fish" or an absolute path (as promised by the
docs of std::env::current_exe()); it can't be empty.
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
ce82577d2f Actually fix stripping of " (deleted)" suffix
Commit 7b59ae0d82 (Unbreak hack to strip " (deleted)" suffix from
executable path, 2025-10-02) accidentally droped the "!".
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
f6584225c2 Pin down "status fish-path" at startup
On some platforms, Rust's std::env::current_exe() may use relative
paths from at least argv[0].  That function also canonicalizes the
path, so we could only detect this case by duplicating logic from
std::env::current_exe() (not sure if that's worth it).

Relative path canonicalization seems potentially surprising, especially
after fish has used "cd". Let's try to reduce surprise by saving the
value we compute at startup (before any "cd"), and use only that.

The remaining problem is that

	creat("/some/directory/with/FISH");
	chdir("/some/directory/with/");
	execve("/bin/fish", "FISH", "-c", "status fish-path")

surprisingly prints "/some/directory/with/FISH" on some platforms.

But that requires the user actively trying to break things (passing
a relative argv[0] that doesn't match the cwd).
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
a0a8a0b817 Move get_fish_path to a meaningful module 2025-11-01 12:45:17 +01:00
Johannes Altmanninger
f88b1fd393 Don't use argv[0] directly when computing executable path
When "status fish-path" fails, we fall back to argv[0],
hoping that it contains an absolute path to fish, or at
least is equal to "fish" (which can happen on OpenBSD, see
https://github.com/rust-lang/rust/issues/60560#issuecomment-489425888).

I don't think it makes sense to duplicate logic that's probably
already in std::env::current_exe().
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
bd720ec9f6 Use early return in get_executable_path 2025-11-01 12:45:17 +01:00
Johannes Altmanninger
56555f6319 Remove obsolete Unicode char reinitialization code path
Since c8001b5023 (encoding: use UTF-8 everywhere, 2025-10-18), a
change in locale variables can no longer cause us to toggle between
"…" or "...".  Have the control flow reflect this.
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
71a962653d Be explicit about setlocale() scope
We use the following locale-variables via locale-aware C functions
(to look them up, grep for "libc::$function_name"):

- LC_CTYPE:    wcwidth
- LC_MESSAGES: strerror, strerror 
- LC_NUMERIC:  localeconv/localeconv_l, snprintf (only in tests)
- LC_TIME:     strftime

Additionally, we interpret LC_MESSAGES in our own code.

As of today, the PCRE2 library does not seem to use LC_MESSAGES
(their error messages are English-only); and I don't think it uses
LC_CTYPE unless we use "pcre2_maketables()".

Let's make it more obvious which locale categories are actually used
by setting those instead of LC_ALL.

This means that instead of logging the return value of «
setlocale(LC_ALL, "") » (which is an opaque binary string on Linux),
we can log the actual per-category locales that are in effect.
This means that there's no longer really a reason to hardcode a log
for the LC_MESSAGES locale. We're not logging at early startup but
we will log if any locale var had been set at startup.
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
732942ec62 Force libc wcwidth to use UTF-8 locale again
Commit 046db09f90 (Try to set LC_CTYPE to something UTF-8 capable
(#8031), 2021-06-06) forced UTF-8 encoding if available.

Since c8001b5023 (encoding: use UTF-8 everywhere, 2025-10-18) we no
longer override LC_CTYPE, since we no longer use it for anything like
mbrtowc or iswalpha.

However there is one remaining use: our fallbacks to system wcwidth().
If we are started as

	LC_ALL=C fish

then wcwidth('😃') will fail to return the correct value, even if
the UTF-8 locale would have been available.

Restore the previous behavior, so locale variables don't affect
emoji width.

This is consistent with the direction in c8001b5023 which stops us
from falling back to ASCII characters if our desired multibyte locale
is missing (that was not the ideal criteria).

In future we should maybe stop using wcwidth().
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
5eebeff5a9 Retire our "use-LC_NUMERIC-internally" workaround
Commit 8dc3982408 (Always use LC_NUMERIC=C internally (#8204),
2021-10-13) made us use LC_NUMERIC=C internally, to make C library
functions behave in a predictable way.

We no longer use library functions affected by LC_NUMERIC[*]..

Since the effective value of LC_NUMERIC no longer matters, let's
simplify things by using the user locale again, like we do for the
other locale variables.

The printf crate still uses libc::snprintf() which respects LC_NUMERIC,
but it looks like "cargo test" creates a separate process per crate,
and the printf crate does not call setlocale().
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
f6d7198317 printf tests: extract function for calling libc::sprintf 2025-11-01 12:45:17 +01:00
Johannes Altmanninger
dc553ac628 Minor style change in read_locale() 2025-11-01 12:45:17 +01:00
Johannes Altmanninger
6643b8c3e1 Document LANGUAGE as :envvar: too 2025-11-01 12:45:17 +01:00
Johannes Altmanninger
2954ff3991 Update docs on locale variables
* since c8001b5023 (encoding: use UTF-8 everywhere, 2025-10-18)
  we always use UTF-8, which simplifies docs.
* emphasize that we (as of an earlier commit) document only the locale
  variables actually used by fish. We could change this in future,
  as long as the docs make it obvious whether it's about fish or
  external programs.
* make things a bit more concise
* delete a stale comment - missing encoding support is no longer a problem
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
ab69ef4b83 Remove unused LC_COLLATE and LC_MONETARY
We may have used LC_COLLATE in the past via libc functions but I
don't think we do today.  In future, we could document the variables
not used by fish, but we should make it obvious what we're documenting.
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
e8c0b3df24 Extract some setlocale() calls; use C-string literals 2025-11-01 12:45:17 +01:00
Johannes Altmanninger
5a12247572 Extract function for listing all locale variables
These include variables that are ignored by fish, which seems
questionable for __fish_set_locale?  The the effect seems benign
because __fish_set_locale will do nothing if any of those variables
is defined.  Maybe we can get rid of this function eventually.
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
58eec96a5b Document fish-specific bits about locale vars
Link to history, printf and "builtin _" which are the only(?) users
of LC_TIME, LC_NUMERIC and LC_MESSAGES respectively (besides the core
equivalent of "builtin _").
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
2be3f34f2c Remove more obsolete uses of LC_CTYPE
Our test driver unsets all LC_* variables as well as LANGUAGE, and
it sets LANG=C, to make errors show up as

	set_color: Unknown color 'reset'

rather than

	set_color: Unknown color “reset”

It also sets LC_CTYPE which is hardly necessary since c8001b5023
(encoding: use UTF-8 everywhere, 2025-10-18).

The only place where we need it seems to be the use of GNU sed as
called in tests/checks/sphinx-markdown-changelog.fish.

In future we might want to avoid these issues by setting LANG=C.UTF-8
in the test_driver again.
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
7bd6e577d9 Remove obsolete uses of LC_CTYPE
These are obsolete as of c8001b5023 (encoding: use UTF-8 everywhere,
2025-10-18). The only place where we still read the user's LC_CTYPE
is in libc::wcwidth(), but that's kind of a regression -- we should
always be using a UTF-8 LC_CTYPE if possible -- which will be fixed
by a following commit.
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
e09583e99e Double-down on using non-ASCII characters even if MB_CUR_MAX==1
Commit c8001b5023 (encoding: use UTF-8 everywhere, 2025-10-18)
removed some places where we fallback to ASCII if no UTF-8 encoding
is available.  That fallback may have been a reasonable approximator
for glyph availability in some cases but it's probably also wrong in
many cases (SSH, containers..).

There are some cases where we still have this sort of fallback.
Remove them for consistency.
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
d1983b29c1 Reword warnings about missing sphinx-build/msgfmt
Also merge them into one warning because some of these lines wrap
on a small (80 column) terminal, which looks weird.  The reason they
wrap might be the long prefix ("warning: fish-build-man-pages@0.0.0:").
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
c0a988da21 Re-enable tests/checks/locale in CI
We don't currently run tsan tests anywhere.
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
f5544fe2ae Fix libc import convention
Functions are always qualified with "libc::".  This is important for
finding who still uses "setlocale()".
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
75be4e3f6a tests/config-paths-standalone: skip on installed builds
This fails:

	tests/test_driver.py ~/.local/opt/fish/bin tests/checks/config-paths-standalone.fish

because  we don't expect to run from a relocatable tree.
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
6c267e88a1 __fish_macos_set_env: match macOS "path_helper" if MANPATH is overridden
Try to match
b33f386ac4/path_helper/path_helper.c
1. don't add empty segments
2. For MANPATH specifically, always add an empty segment at the end

See #10684
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
27f49b9523 __fish_macos_set_env: extract function to make it testable 2025-11-01 12:45:17 +01:00
Johannes Altmanninger
b8f12ed857 More build fixes for Illumos' msgfmt
Their msgfmt doesn't support --output-file=- yet, so use a temporary
file if "msgfmt" doesn't support "--check-format".  Else we should
have GNU gettext which supports both.

See #11982
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
5cad71c081 Fix weird indentation in macro_rules 2025-11-01 12:45:17 +01:00
Johannes Altmanninger
f331f6a8a9 Relax test_close_during_select_ebadf
It failed for me on Linux.  Same as abf3f50bb9 (Relax test
`test_dup2_during_select_ebadf` (#11976), 2025-10-19).
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
461670c36a alt-p binding: don't add extra space character before pipe 2025-11-01 12:45:17 +01:00
Kaya Arro
0f32866980 docs: corrected some section title conflicts
Part of #11796
2025-11-01 12:45:17 +01:00
Kaya Arro
c123126991 help: fix anchor link to intropages
Part of #11796
2025-11-01 12:45:17 +01:00
Johannes Altmanninger
1302ac16f0 printf: remove unused re-export of en_US locale
As suggested in
https://github.com/fish-shell/fish-shell/pull/11992#discussion_r2464108030,
I don't know if anyone wants to use the re-exports rather than using
the `locale` crate.
2025-11-01 12:45:17 +01:00
Daniel Rainer
cc51d91e77 cleanup: avoid allocation in autoloader
There is no need to allocate a new box in these cases.
Flagged by nightly clippy.

There's also no need for the box at all; the comment is no longer
valid, especially because Rust const-propagates by default.

Closes #12014
2025-11-01 12:45:17 +01:00
Daniel Rainer
2d1c34c36a ci: update stable Rust version to 1.91
Closes #12013
2025-11-01 12:44:48 +01:00
Daniel Rainer
6422139fe0 cleanup: derive Default where possible
Not doing so triggers a clippy lint on Rust >= 1.91.

Part of #12013
2025-11-01 12:44:48 +01:00
Daniel Rainer
f511ef69c3 gettext: don't cache messages outside of gettext
Using gettext by calling it once on initialization and then reusing the
result prevents changes to the messages as when locale variables change.
A call to the gettext implementation should be made every time the
message is used to handle language changes.

Closes #12012
2025-11-01 12:42:55 +01:00
Johannes Altmanninger
525c9bbdcb Move Rust tests to implementation files
For historical reasons[^1], most of our Rust tests are in src/tests,
which
1. is unconventional (Rust unit tests are supposed to be either in the
   same module as the implementation, or in a child module).
   This makes them slightly harder to discover, navigate etc.
2. can't test private APIs (motivating some of the "exposed for
   testing" comments).

Fix this by moving tests to the corresponding implementation file.
Reviewed with

        git show $commit \
            --color-moved=dimmed-zebra \
            --color-moved-ws=allow-indentation-change

- Shared test-only code lives in
  src/tests/prelude.rs,
  src/builtins/string/test_helpers.rs
  src/universal_notifier/test_helpers.rs
  We might want to slim down the prelude in future.
- I put our two benchmarks below tests ("mod tests" followed by "mod bench").

Verified that "cargo +nightly bench --features=benchmark" still
compiles and runs.

[^1]: Separate files are idiomatic in most other languages; also
separate files makes it easy to ignore when navigating the call graph.
("rg --vimgrep | rg -v tests/").  Fortunately, rust-analyzer provides
a setting called references.excludeTests for textDocument/references,
the textDocument/prepareCallHierarchy family, and potentially
textDocument/documentHighlight (which can be used to find all
references in the current file).

Closes #11992
2025-11-01 12:42:55 +01:00
Johannes Altmanninger
7bc560190f Fix warning about unused test_notifiers on windows 2025-11-01 12:42:55 +01:00
Johannes Altmanninger
54b39be7e7 build_tools/style.fish: check that {rustfmt,Cargo}.toml edition specs are in sync
Commit 1fe6b28877 (rustfmt.toml: specify edition to allow 2024 syntax,
2025-10-19) mentions that "cargo fmt" has different behavior than
"rustfmt" before that commit.  Probably because when .rustfmt.toml
exists, rustfmt implicitly uses a different edition (2018?)  that
doesn't support c"" yet.  That commit bumped the edition to 2024,
which caused yet another deviation from "cargo fmt":

    Error writing files: failed to resolve mod `tests`: cannot parse /home/johannes/git/fish-shell/src/wutil/tests.rs
    error: expected identifier, found reserved keyword `gen`
      --> /home/johannes/git/fish-shell/src/tests/topic_monitor.rs:48:9
       |
    48 |     for gen in &mut gens_list {
       |         ^^^ expected identifier, found reserved keyword

This has since been fixed by
00784248db (Update to rust 2024 edition, 2025-10-22).

Let's add a test so that such changes won't randomly break "rustfmt"
again.

Fix that by using 2021 edition, like we do in Cargo.toml.

In future, rustfmt should probably default to a current edition (or
maybe read the edition from Cargo.toml?)  Not yet sure which one is the
upstream issue, maybe https://github.com/rust-lang/rustfmt/issues/5650
2025-11-01 12:42:55 +01:00
kerty
578f46c008 build_tools/style.fish: improve style and consistency 2025-11-01 12:42:55 +01:00
Johannes Altmanninger
b1cbbf7ce5 build_tools/style.fish: extract function 2025-11-01 12:42:55 +01:00
Johannes Altmanninger
af9b03625b build_tools/style.fish: reuse variable 2025-11-01 12:42:55 +01:00
Johannes Altmanninger
71f0e75651 Remove dead misc_init() 2025-11-01 12:42:55 +01:00
Johannes Altmanninger
3c4243fdd2 clang-format fish_test_helper 2025-11-01 12:42:55 +01:00
Peter Ammon
1a1da0649a Clean up Debounces and remove the global thread pool
Prior to this commit, there was a singleton set of "debouncers" used to run
code in the background because it might perform blocking I/O - for example,
for syntax highlighting or computing autosuggestions. The complexity arose
because we might push or pop a reader. For example, a long-blocking, stale
autosuggestion thread might suddenly complete, but the reader it was for
(e.g. for `builtin_read`) is now popped. This was the basis for complex
logic like the "canary" to detect a dead Reader.

Fix this by making the Debouncers per-reader. This removes some globals and
complicated logic; it also makes this case trivial: a long-running thread
that finishes after the Reader is popped, will just produce a Result and
then go away, with nothing reading out that Result.

This also simplifies tests because there's no longer a global thread pool
to worry about. Furthermore we can remove other gross hacks like ForceSend.
2025-10-31 19:40:13 -07:00
Peter Ammon
69ccc9be18 Factor Debounce out of threads.rs
Preparation to clean this up.
2025-10-31 19:40:12 -07:00
Peter Ammon
61d6a83661 Migrate threads into its own submodule
Preparation for improving its factoring.
2025-10-31 19:40:11 -07:00
Peter Ammon
2f5260aabd Make a reader-specific thread pool
This concerns threads spawned by the reader for tasks like syntax
highlighting that may need to perform I/O.

These are different from other threads typically because they need to
"report back" and have their results handled.

Create a dedicated module where this logic can live.
This also eliminates the "global" thread pool.
2025-10-31 19:40:10 -07:00
Peter Ammon
eca19006ad Use a separate thread pool for history file detection 2025-10-31 19:40:08 -07:00
Peter Ammon
d22b5910c2 Remove the "cant_wait" variants of thread pool execution
This is now handled via separate thread pools.
2025-10-31 19:40:07 -07:00
Peter Ammon
a868be6ba4 Factor fill_history_pager_complete into its own function 2025-10-31 19:40:06 -07:00
Peter Ammon
8822ba3035 Migrate reader into a submodule.
Support future breaking up of this big module. No functional change.
2025-10-31 19:40:05 -07:00
Peter Ammon
e20b06df1a Background threads to use a separate pool from reader
Sometimes we need to spawn threads to service internal processes. Make
this use a separate thread pool from the pool used for interactive tasks
(like detecting which arguments are files for syntax highlighting).
2025-10-31 19:40:03 -07:00
Peter Ammon
e299b71560 Stop using io_thread pool in test_universal
Just use ordinary threads.

Also allow universal variable tests to run in parallel, by using real
temporary paths.
2025-10-31 19:40:00 -07:00
Peter Ammon
d6f0e1fdf2 Make Debounce hold a thread pool
Allow these to be instanced.
2025-10-31 17:40:21 -07:00
Peter Ammon
4a5bce3fb8 Use OnceLock instead of once_cell::race in debouncers
No reason to be fancy here; and OnceLock is lock-free in the fast path
2025-10-31 17:40:21 -07:00
Peter Ammon
7f1dc80b9c Get rid of WorkerThread
Now that ThreadPool itself is behind Arc we can do without this type.
2025-10-31 17:40:21 -07:00
Peter Ammon
43731c88bd Migrate ThreadPool's Arc to the outside
This will simplify debouncing and allowing for multiple pools.
2025-10-31 17:40:21 -07:00
Peter Ammon
332712866c Move some iothread functions into ThreadPool
Continue to get away from singletons.
2025-10-31 17:40:20 -07:00
Peter Ammon
b0d643c4ce Move MAIN_THREAD_QUEUE into ThreadPool
Continue to remove globals and improve ThreadPool testability.
2025-10-31 17:40:20 -07:00
Peter Ammon
2b9967bf01 Migrate NOTIFY_SIGNALLER into ThreadPool
Help remove some globals; prepare ThreadPool for certain tests.
2025-10-31 17:40:20 -07:00
Peter Ammon
9d53d61141 Remove a Mutex around ThreadPool
This is not in fact needed.
2025-10-31 17:40:20 -07:00
Peter Ammon
c66fa682e9 Fix some clipplies 2025-10-31 17:38:37 -07:00
David Adam
819759840e Debian packaging: use MSRV compiler if available
Allows the Ubuntu builds to work when using the cargo-VERSION packages.
2025-10-28 05:55:10 +08:00
David Adam
ccde87c4e3 Debian packaging: force name of build directory
make uses the GNUMakefile in the source directory otherwise
2025-10-28 05:51:01 +08:00
David Adam
3a9c5c7dc0 Debian packaging: pass buildsystem argument to all dh invocations 2025-10-28 05:48:55 +08:00
David Adam
d27537c4fc CMake: use configured Rust_CARGO for tests, not the cargo on $PATH 2025-10-27 06:07:41 +08:00
Peter Ammon
973f0f6134 Fix tmux-commandline.fish test harder
Make this pass on both macOS and Linux.

This was an obnoxious and uninteresting test to debug and so I used
claude code. It insists this is due to differences in pty handling between
macOS and Linux. Specifically it writes:

    The test was failing inconsistently because macOS and Linux have different
    PTY scrollback behavior after rendering prompts with right-prompts.

    Root cause: After fish writes a right-prompt to the rightmost column,
    different PTY drivers position the cursor differently:
    - macOS PTY: Cursor wraps to next line, creating a blank line
    - Linux PTY: Cursor stays on same line, no blank line

    This is OS kernel-level PTY driver behavior, not terminal emulator behavior.

    Fix: Instead of hardcoding platform-specific offsets, detect the actual
    terminal behavior by probing the output:
    1. Capture with -S -12 and check if the first line is blank
    2. If blank (macOS behavior), use -S -13 to go back one more line
    3. If not blank (Linux behavior), use -S -12

    Also split the C-l (clear-screen) command into its own send-keys call
    with tmux-sleep after it, ensuring the screen clears before new output
    appears. This improves test stability on both platforms.

    The solution is platform-independent and adapts to actual terminal
    behavior rather than making assumptions based on OS.
2025-10-26 13:34:35 -07:00
ridiculousfish
1973f3110e Make tmux-multiline-prompt.fish pass reliably on macOS 2025-10-26 12:06:35 -07:00
Peter Ammon
95e7977e70 Rename some constants to UPPER_CASE 2025-10-26 11:28:04 -07:00
Peter Ammon
15d06f964d Make tmux-commandline.fish pass reliably on macOS 2025-10-25 19:36:34 -07:00
Peter Ammon
5f96a4e665 Make test_fish_update_completions.fish pass on macOS 2025-10-25 11:56:43 -07:00
Henrik Hørlück Berg
075e4040be Remove resolver="2" to opt into resolver="3" default
This makes dependecy-resolving rust-version aware.

See: https://doc.rust-lang.org/edition-guide/rust-2024/cargo-resolver.html#cargo-rust-version-aware-resolver

This changes to lockfile to V4, which was released with rust 1.78
https://doc.rust-lang.org/nightly/cargo/CHANGELOG.html#cargo-178-2024-05-02,
and became the default with rust 1.83 https://doc.rust-lang.org/nightly/cargo/CHANGELOG.html#cargo-183-2024-11-28

Closes #11990
2025-10-24 13:48:19 +02:00
Henrik Hørlück Berg
7d41158b1d Bravely revert if let => match edition changes
See: https://doc.rust-lang.org/edition-guide/rust-2024/temporary-if-let-scope.html

I dot believe drop order matters in any of these cases.

Part of #11990
2025-10-24 13:48:19 +02:00
Henrik Hørlück Berg
00784248db Update to rust 2024 edition
This bravely avoids changing expr to expr_2021 in macros, which seems
extremely unlikely to be silently breaking anything.

See: https://doc.rust-lang.org/edition-guide/rust-2024/macro-fragment-specifiers.html

I do not believe we have any macros where this is relevant

Part of #11990
2025-10-24 13:48:19 +02:00
Henrik Hørlück Berg
b47b61ea08 Ignore noisy rule
This lint will be triggered by a forthcoming change, see
https://github.com/fish-shell/fish-shell/pull/11990#discussion_r2455299865

It bans the usage of

```rust
fn hello() -> impl Debug {
    let useful_name = xxx;
    useful_name
}
```

in favour of

```rust
fn hello() -> impl Debug {
    xxx
}
```
Which is less humanly-understandable.

Part of #11990
2025-10-24 13:48:19 +02:00
Johannes Altmanninger
787c6a443d Remove redundant per-module lints; fix some
As mentioned in 6896898769 (Add [lints] table to suppress lints
across all our crates, 2024-01-12), we can use workspace lints in
Cargo.toml now that we have MSRV >=1.74 and since we probably don't
support building without cargo.

This implies moving some lints from src/lib.rs to "workspace.lints".
While at it, address some of them insrtead.
2025-10-24 13:48:19 +02:00
kerty
f075c58eb5 Try to make tmux-transient-prompt.fish more consistent 2025-10-23 11:48:24 +02:00
kerty
07f0b1816e Wait until any output when initalasing tmux tests
Previously, if test setup didn't output word 'prompt' it would wait 5 second
timeout. This affected tmux-wrapping.fish and tmux-read.fish tests.

Change it so initialization function wait until any output and error out
on timeout.
2025-10-23 11:48:24 +02:00
kerty
73696da21c Allow for attaching to test tmux session without resizing 2025-10-23 11:48:24 +02:00
kerty
e22d90cbad Instead of variable pass args to tmux fish directly 2025-10-23 11:48:24 +02:00
kerty
c7fdb8dc6b Simplify behavior of ScreenData.cursor
Let `y=0` be the first line of the rendered commandline. Then, in final
rendering, the final value of the desired cursor was measured from
`y=scroll_amount`. This wasn't a problem because
```
if !MIDNIGHT_COMMANDER_HACK.load() {
    self.r#move(0, 0);
}
```
implicitly changed the actual cursor to be measured from `y=0` to `y=scroll_amount`.
This happened because the cursor moved to `y=scroll_amount` but had its
`y` value set to 0. Since the actual and desired cursors were both measured
from the same line, the code was correct, just unintuitive.

Change this to always measure cursor position from the start of the
rendered commandline.
2025-10-23 11:48:24 +02:00
kerty
f7359751c9 Small refactoring of Screen::write 2025-10-23 11:48:24 +02:00
kerty
0b7ab5a1b5 Fix not preserving empty last line in multiline prompts
Reproduction:
fish -C '
    function fish_prompt
        echo left-prompt\n
    end
    function fish_right_prompt
        echo right-prompt
    end
'
and pressing Enter would not preserve the line with right prompt.

This occurred because Screen::cursor_is_wrapped_to_own_line assumed
the last prompt line always had index 0. However, commit 606802daa (Make
ScreenData track multiline prompt, 2025-10-15) changed this so the last
prompt line's index is now `Screen.actual.visible_prompt_lines - 1`.

Screen::cursor_is_wrapped_to_own_line also didn't account for situations
where commandline indentation was 0.

Fix Screen::cursor_is_wrapped_to_own_line and add tests for prompts with
empty last lines.
2025-10-23 11:48:24 +02:00
kerty
e7ad7e5cf6 Fix missing right prompt when left prompt ends with empty line
Reproduction:
fish -C '
    function fish_prompt
        echo left-prompt\n
    end
    function fish_right_prompt
        echo right-prompt
    end
'

This was caused by an off-by-one error in initial Screen.desired resizing
from commit 606802daa (Make ScreenData track multiline prompt, 2025-10-15).
2025-10-23 11:48:24 +02:00
Étienne Deparis
9ccd6fb2d2 Add me as french maintainer
Part of #11842
2025-10-22 10:57:36 +02:00
Étienne Deparis
e7e97833a3 Improve some french translations
Closes #11842
2025-10-22 10:57:36 +02:00
Étienne Deparis
2dd6a7ba22 Sort recommended translations in french po file
Part of #11842
2025-10-22 10:57:36 +02:00
Johannes Altmanninger
034cd7ea35 Always handle mktemp failure in user-facing code
mktemp might be missing, see #11972
2025-10-22 10:57:36 +02:00
Johannes Altmanninger
037a399746 Add test for brace in command position with trailling text
See #11962
2025-10-22 10:57:36 +02:00
Johannes Altmanninger
6a86974b96 Fix build on Illumos
Fixes #11982
2025-10-22 10:57:36 +02:00
Johannes Altmanninger
3c468054bd completions/iwctl: fix spurious error output
Regressed in 4.1 in c94eddaf4b (Replaced all uses of argparse -i
with argparse -u, 2025-08-30).

Closes #11983
2025-10-22 10:57:36 +02:00
David Adam
6fd1304e52 Debian packaging: broaden packages for rustc to support Ubuntu 2025-10-21 11:33:54 +08:00
Nahor
a51b2f4023 Enable CI testing for MSYS 2025-10-21 04:25:30 +02:00
Nahor
abf3f50bb9 Relax test test_dup2_during_select_ebadf (#11976)
On MSYS/Cygwin, when select/poll wait on a descriptor and `dup2` is used
to copy into that descriptor, they return the descriptor as "ready",
unlike Linux (timeout) and MacOS (EBADF error).

The test specifically checked for Linux and MaxOS behaviors, failing on
Cygwin/MSYS. So relax it to also allow that behavior.
2025-10-21 04:25:30 +02:00
Nahor
20a6ac947b Disable invalid Windows filename character tests
Colons and backslashes are valid on Posix but not on Windows. So
remove those checks on Cygwin/MSYS
2025-10-21 04:25:30 +02:00
Nahor
b158ba1523 Disable permission tests on MSYS/Cygwin
POSIX permissions on Windows is problematic. MSYS and Cygwin have
a "acl/noacl" when mounting filesystems to specify how hard to try.

MSYS by default uses "noacl", which prevents some permissions to be set.
So disable the failing checks.

Note: Cygwin by default does use "acl", which may allow the check to
pass (unverified). But to be consereative, and because MSYS is the only
one providing a Fish-4.x package, we'll skip.
2025-10-21 04:25:30 +02:00
Nahor
372a65aa15 Temporary workaround for #11933 on Cygwin
Without the sleep, `flock` sometimes returns an error 14 "bad addr".
This puts the application into a deadlock.
2025-10-21 04:25:30 +02:00
Nahor
804bda5ba6 Disable test_history_races on Cygwin
The test always fail on Cygwin (with rare exceptions) so disable it
for now.
A likely cause is issue #11933, so this change should be revisited
once that issue is fixed.
2025-10-21 04:25:30 +02:00
Nahor
2f07df717d Disable symlink tests on Cygwin
Symbolic links on Windows/Cygwin are complicated and dependent on
multiple factors (env variable, file system, ...). Limitations in the
implementation causes the tests failures and there is little that Fish
can do about it. So disable those tests on Cygwin.
2025-10-21 04:25:30 +02:00
David Adam
1d0de5ce71 debian packaging: find alternative up-to-date Rust
Also drop cmake-mozilla, which disappeared a long time ago.
2025-10-20 19:00:26 +08:00
Daniel Rainer
c8001b5023 encoding: use UTF-8 everywhere
Assume that UTF-8 is used everywhere. This allows for significant
simplification of encoding-related functionality. We no longer need
branching on single-byte vs. multi-byte locales, and we can get rid of
all the libc calls for encoding and decoding, replacing them with Rust's
built-in functionality, or removing them without replacement in cases
where their functionality is no longer needed.

Several tests are removed from `tests/checks/locale.fish`, since setting
the locale no longer impacts encoding behavior. We might want more
rigorous testing of UTF-8 handling instead.

Closes #11975
2025-10-20 03:42:38 +02:00
kerty
755d5ae222 Try to always maintain prompt marker at (0, 0)
First, print prompt marker on repaint even if prompt is not visible.
Second, if we issue a clear at (0, 0) we need to restore marker.

This is necessary for features like Kitty's prompt navigation (`ctrl-shift-{jk}`),
which requires the prompt marker at the top of the scrolled command line
to actually jump back to the original state.

Closes #11911
2025-10-19 14:09:27 +02:00
Aditya Bhargava
5cfcfc64d8 Add tests for final prompt having fewer lines than initial (transient)
Part of #11911
2025-10-19 14:09:27 +02:00
kerty
606802daaf Make ScreenData track multiline prompt
Instead of pretending that prompt is always 1 line, track multiline
prompt in ScreenData.visible_prompt_lines and ScreenData.line_datas as
empty lines.

This enables:
- Trimming part of the prompt that leaves the viewport.
- Removing of the old hack needed for locating first prompt line.
- Fixing #11875.

Part of #11911
2025-10-19 14:09:27 +02:00
kerty
71b619bab0 Refactor prompt printing and var names in Screen::update
Part of #11911
2025-10-19 14:09:27 +02:00
kerty
a033a5d0e7 Instead of prompt line_breaks track line_starts
It makes it easier to do manipulations with prompt lines.

Part of #11911
2025-10-19 14:09:27 +02:00
Kabakov Grigoriy
3f2c58a269 Remove unused PromptLayout.last_line_width
Part of #11911
2025-10-19 14:09:27 +02:00
kerty
f946e5ec73 Remove redundant getter Screen::scrolled
Part of #11911
2025-10-19 14:09:27 +02:00
kerty
9d06302778 Add ScreenData::clear_lines() instead of ScreenDate::resize(0)
Part of #11911
2025-10-19 14:09:27 +02:00
kerty
bb7180a2d8 Fix off-by-one pager height error on empty lines
Commit 7db9553 (Fix regression causing off-by-one pager height on
truncated autosuggestion) adds line to pager if cursor located at
the start of line and previous line is softwrapped, even if line was
softwrapped normally and not by autosuggestion, giving pager too much space.

Fix that.

Part of #11911
2025-10-19 14:09:27 +02:00
kerty
6f5644a77c Disable fish_transient_prompt in tmux test setup
Part of #11911
2025-10-19 14:09:27 +02:00
Daniel Rainer
d79273089f lint: update clippy annotations
Some annotations are no longer needed with more recent clippy (1.85+),
so let's remove them.

Closes #11964
2025-10-19 14:09:27 +02:00
Daniel Rainer
68d02916e2 stdlib: use map_break to simplify code
Part of #11964
2025-10-19 14:09:27 +02:00
Daniel Rainer
d414967b79 stdlib: use fchown from stdlib instead of libc
Part of #11964
2025-10-19 14:09:27 +02:00
Daniel Rainer
448471bd50 stdlib: remove is_none_or backport
The backport is no longer necessary with our new MSRV.

Part of #11964
2025-10-19 14:09:27 +02:00
Daniel Rainer
15fd99072b stdlib: remove is_sorted_by backport
The backport is no longer necessary with our new MSRV.

Part of #11964
2025-10-19 14:09:27 +02:00
Daniel Rainer
61ee695e56 refactor: use bytes instead of string
Some string handling functions deal with `Vec<u8>` or `&[u8]`, which
have been referred to as `string` or `str` in the function names. This
is confusing, since they don't deal with Rust's `String` type. Use
`bytes` in the function names instead to reduce confusion.

Closes #11969
2025-10-19 14:09:27 +02:00
Johannes Altmanninger
1fe6b28877 rustfmt.toml: specify edition to allow 2024 syntax
cargo fmt works but "rustfmt src/env_dispatch.rs" fails,

	error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `"C"`
	   --> src/env_dispatch.rs:572:63
	    |
	572 |     let loc_ptr = unsafe { libc::setlocale(libc::LC_NUMERIC, c"C".as_ptr().cast()) };
	    |                                                               -^^

Fix that as suggested
2025-10-19 14:09:27 +02:00
Johannes Altmanninger
4f48797a09 build_tools/check.sh: allow to check for dependency updates
Opt-in because we don't want failures not related to local changes,
see d93fc5eded (Revert "build_tools/check.sh: check that stable rust
is up-to-date", 2025-08-10).

For the same reason, it's not currently checked by CI, though we should
definitely have "renovatebot" do this in future.

Also, document the minimum supported Rust version (MSRV) policy.  There's no
particular reason for this specific MSRV policy, but it's better than nothing,
since this will allow us to always update without thinking about it.

Closes #11960
2025-10-19 14:08:11 +02:00
Daniel Rainer
3736636d99 msrv: update to Rust 1.85
Update our MSRV to Rust 1.85.

Includes fixes for lints which were previously suppressed due to them
relying on features added after Rust 1.70.

Rust 1.85 prints a warning when using `#[cfg(target_os = "cygwin")]`, so
we work around the one instance where this is a problem for now. This
workaround can be reverted when we update to Rust 1.86 or newer.

Certain old versions of macOS are no longer supported by Rust starting
with Rust 1.74, so this commit raises our macOS version requirement to
10.12.
https://blog.rust-lang.org/2023/09/25/Increasing-Apple-Version-Requirements/
https://github.com/fish-shell/fish-shell/pull/11961#discussion_r2442415411

Closes #11961
2025-10-19 14:08:10 +02:00
Johannes Altmanninger
16f2135976 cirrus: update alpine, make jammy use rustup to get Rust>=1.85
See https://github.com/fish-shell/fish-shell/pull/11961#discussion_r2439033959

I didn't find a good way to add ~/.cargo/bin to $PATH only for
fishuser, so hardcode it for all users for now.  The default rustup
behavior (source it in ~/.bashrc) only works for interactive shells,
so it doesn't work in CI.

I updated the images manually for now, because
I'm not sure I want to test on master (see
https://github.com/fish-shell/fish-shell/pull/11884 and
https://github.com/fish-shell/fish-shell/pull/11961#discussion_r2439033959)

	sed -i '/if: github.repository_owner/d' .github/workflows/build_docker_images.yml
	git commit
	# Upload new docker images.
	repo_owner=krobelus
	git push $repo_owner HEAD:tmp
	gh --repo=$repo_owner/fish-shell \
	    workflow run --ref=tmp \
	    .github/workflows/build_docker_images.yml
	# https://github.com/$repo_owner/fish-shell/actions/workflows/build_docker_images.yml
	sleep 3m
	# Enable Cirrus CI on fork.
	sed -i "s/OWNER == 'fish-shell'/OWNER == '$repo_owner'/g" .cirrus.yml
	git commit
	git push $repo_owner HEAD:tmp

Part of #11961
2025-10-19 13:27:16 +02:00
Lumynous
73fe50f6b1 l10n: Add zh-TW translation
Adds human-translated tier-1 strings.

Closes #11967
2025-10-18 13:52:09 +02:00
Johannes Altmanninger
0b5f82a5f0 Enable history-races test in CI
Also remove the check for WSL again, since that failure may be
covered by us checking for flock() success (else there's a bug in our
implementation or in WSL); we'll see if anyone runs into this again..

Closes #11963
2025-10-18 13:45:32 +02:00
Johannes Altmanninger
02725b66b3 README: move file dependency to optional deps 2025-10-18 13:42:33 +02:00
Daniel Rainer
52ea511768 cleanup: remove useless INTERNAL_SEPARATOR handling
There does not seem to be a good reason for treating
`INTERNAL_SEPARATOR` (`\u{fdd8}`) specially in this function.

Related discussion:
https://github.com/fish-shell/fish-shell/discussions/11949#discussioncomment-14712851

Closes #11971
2025-10-18 12:59:52 +02:00
Daniel Rainer
c65748c098 refactor: replace getcwd with current_dir
The `std::env::current_dir` function calls `getcwd` internally and saves
us from having to deal with the `libc` call directly.

Closes #11970
2025-10-18 12:58:39 +02:00
Daniel Rainer
8aeafa13c9 format strings: remove length modifier
This length modifier was reintroduced in
b7fe3190bb, which reverts
993b977c9b, a commit predating the removal
of redundant length modifiers in format strings.

Closes #11968
2025-10-18 12:55:36 +02:00
Johannes Altmanninger
07514c5df0 build-man-pages: use multiline string literal 2025-10-18 09:29:50 +02:00
Daniel Rainer
43f8d7478e style: change rustfmt edition to 2024
This commit adds `style_edition = "2024"` as a rustfmt config setting.
All other changes are automatically generated by `cargo fmt`.

The 2024 style edition fixes several bugs and changes some defaults.
https://doc.rust-lang.org/edition-guide/rust-2024/rustfmt-style-edition.html

Most of the changes made to our code result from a different sorting
method for `use` statements, improved ability to split long lines, and
contraction of short trailing expressions into single-line expressions.

While our MSRV is still 1.70, we use more recent toolchains for
development, so we can already benefit from the improvements of the new
style edition. Formatting is not require for building fish, so builds
with Rust 1.70 are not affected by this change.

More context can be found at
https://github.com/fish-shell/fish-shell/issues/11630#issuecomment-3406937077

Closes #11959
2025-10-18 09:29:50 +02:00
Daniel Rainer
1c3a6a463d style: move postfix comments to line above
These comments should be placed on top of the line they're commenting on.
Multi-line postfix comments will no longer be aligned using rustfmt's
style edition 2024, so fix this now to prevent formatting issues later.
For consistency, single-line postfix comments are also moved.

Part of #11959
2025-10-18 09:29:50 +02:00
Johannes Altmanninger
41636c8e35 Fix build on Linux/MIPS
Fixes #11965
2025-10-18 09:29:50 +02:00
Daniel Rainer
78e8f87e54 tests: remove duplicates
These were made duplicates by removing length modifiers.

Closes #11951
2025-10-16 16:43:03 +02:00
Daniel Rainer
8cb5ad9693 lints: avoid unwrapping after .is_ok() succeeded
This was flagged by nightly Rust.

Closes #11950
2025-10-16 16:43:03 +02:00
Daniel Rainer
83ece2161d lints: remove unused imports reported by nightly Rust
Part of #11950
2025-10-16 16:43:03 +02:00
Luca Weiss
63cda65815 completions/git: fix remotes missing in e.g. git fetch
Update the regex to allow remote names which are allowed in git, like
`foo-bar`, `foo.bar` or `😜`. Do not try to artificially limit the
allowed remote names through the regex.

Closes #11941
2025-10-16 16:43:03 +02:00
traal
165e0d0ed5 man.fish: fix for commands ! . : [
[ja: add test]

Closes #11956
2025-10-16 16:43:03 +02:00
王宇逸
cab6b97539 fs: open file with O_RDWR before fsync
On Cygwin, fsync() on the history and uvar file fails with "permission
denied". Work around this by opening the file in read-write mode
instead of read-only mode.

Closes #11948
2025-10-16 14:14:22 +02:00
Johannes Altmanninger
1c853a4d24 tests fish_{config,delta}: fix for BSD sed and BusyBox cat 2025-10-15 12:51:20 +02:00
Johannes Altmanninger
73fbd5d994 tests/fish_config prompt choose: no "embedded:functions/foo.fish" via source
Today fish script can't produce this type of behavior:

	$ type fish_prompt
	# Defined in embedded:functions/fish_prompt.fish @ line 2

The above is only created for autoloaded functions.

On standalone builds, "fish_config prompt choose" uses the "source"
builtin, making this line say is "Defined via `source`".

In future, we might want to make things consistent (one way or
the other).
2025-10-15 12:00:24 +02:00
Johannes Altmanninger
9a43acd77b fish_config theme choose: better variable name 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
28e8f45828 fish_config theme choose: correct error message for standalone builds 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
ac8ef4da9e fish_config: don't redo __fish_bin_dir computation
__fish_bin_dir is already computed exactly like this.
2025-10-15 12:00:24 +02:00
Johannes Altmanninger
52241712b4 fish_vi_key_bindings: hack to prevent error when overriding fish_vi_cursor
As discovered in https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$BFAjMPXBA9UczLT8h-7XpiyGUDv0Cz5g6ijbgdEVl_w
2025-10-15 12:00:24 +02:00
Johannes Altmanninger
584a21b34b tests/fish_config theme {choose,save} 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
b82920dc26 fish_delta: share logic between standalone and installed builds 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
ea69133e48 tests/fish_delta 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
f72ebca1e4 fish_delta: fix spurious output in standalone builds 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
40d772fde3 share: share logic between standalone and installed builds 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
d4837f9ef1 fish_config prompt choose: reset mode prompt and load it like right prompt
Fixes #11937
2025-10-15 12:00:24 +02:00
Alan Wu
b44209e14e Nim sample prompt: Don't print replace_one mode twice
Previously, it showed `[R]` twice when  `fish_bind_mode` is `replace_one`:

```console
┬─[user@hostname:~]─[00:00:01 PM][R]
─[R]
╰─>$ 
```

Closes #11942
2025-10-15 12:00:24 +02:00
Johannes Altmanninger
531269bb84 fish_config theme {choose,save}: share logic between standalone and installed builds 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
80faf5e805 fish_config theme show: load fish_config's internal functions too
To be used in the next commit.
The comment seems incorrect.
2025-10-15 12:00:24 +02:00
Johannes Altmanninger
0d5fd181be tests/fish_config: share logic between standalone and installed builds 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
8c279b854d fish_config theme {choose,save}: explode color list
Easier to cross-reference and update this way.
2025-10-15 12:00:24 +02:00
Johannes Altmanninger
f1f95c6867 fish_config theme {choose,save}: use early return 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
ecedd8caed fish_config theme: share logic between standalone and installed mode 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
ce5b5ec053 fish_config prompt {choose,save}: delete code clone
The "choose" one did not define fish_prompt unconditionally but that
looks like a bug.
2025-10-15 12:00:24 +02:00
Johannes Altmanninger
37e0a5ae8d fish_config prompt save: don't define right prompt unnecessarily
If no "fish_right_prompt" is defined, then we also don't need to
define and save an empty one.  We can do nothing, which seems cleaner.
It's also what "fish_config prompt choose" does.  Git blame shows no
explicit reason for for this inconsistency.

Probably the implicit reason is that when both styles where introduced
(both in 69074c1591 (fish_config: Remove right prompt in `choose` and
`save`, 2021-09-26)), that was before the "fish_config prompt choose:
make right prompt hack less weird" commit, so the "prompt choose"
code path didn't know whether the prompt existed until after checking,
hence "--erase" was more suitable.. but that inconsistency is gone.
2025-10-15 12:00:24 +02:00
Johannes Altmanninger
5792df9738 fish_config prompt: share logic between standalone and installed mode 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
73f0e14d90 tests/fish_config {prompt,theme} list 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
a216cfdd2f fish_{config,update_completions}: extract function for standalone builds 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
fad0e39cfa tests/fish_update_completions: simple system test 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
4532fc0c1b builtin status: sort list-files, like globs
This is important for deterministic behavior across both standalone
and installed builds in "fish_config prompt list".

I later realized that we could use "path sort" I suppose, but why
not fix the problem for everyone.
2025-10-15 12:00:24 +02:00
Johannes Altmanninger
03d21edd63 builtin status list-files: extract loop 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
f72b833e38 fish_config theme save: reset prompts in standalone builds too 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
45a3f4f1d6 fish_config prompt {choose,save}: remove dead code
Introduced by dd0d45f88f (fish_config prompt: remove dead code,
2025-09-28).
2025-10-15 12:00:24 +02:00
Johannes Altmanninger
3aab119e5b fish_config prompt save: extract loop 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
0a1ca206fa fish_config prompt save: use early return 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
028e05fff1 fish_config prompt choose: improve right prompt hack
Rather than first sourcing the prompt, and then erasing the right
prompt unless the prompt file defined the right prompt, start by
erasing the right prompt.  This is simpler (needs no conditional).
2025-10-15 12:00:24 +02:00
Johannes Altmanninger
dabd956216 fish_config prompt show: make indentation more helpful 2025-10-15 12:00:24 +02:00
Johannes Altmanninger
441f90fb55 __fish_data_list_files: fix for installed builds
This is only used in test code where bad output is ignored.
To be tested by a following commit.
2025-10-15 12:00:24 +02:00
Johannes Altmanninger
3b52d3db42 tests/fish_config prompt {choose,save} 2025-10-14 20:38:17 +02:00
Johannes Altmanninger
39943a8406 tests/fish_config: sort 2025-10-14 12:37:26 +02:00
Johannes Altmanninger
48bdf24964 __fish_data_with_file: better variable name 2025-10-14 12:37:26 +02:00
Johannes Altmanninger
fed2714e30 Rename abstraction for standalone/installed data files 2025-10-14 12:02:08 +02:00
Peter Ammon
c8262929e1 Restore statfs instead of statvfs behavior
MNT_LOCAL is NOT a flag for statvfs on macOS or possibly other BSDs
(except NetBSD which does not have statfs). Revert to statfs on other
platforms.
2025-10-13 14:15:05 -07:00
Peter Ammon
0ded3ed6f9 Rework ulimit constants
Use a macro to reduce the size of these modules.
2025-10-13 13:05:36 -07:00
Peter Ammon
2b428fae38 Fix remaining BSD build issues
Now building on FreeBSD / OpenBSD / NetBSD / DragonflyBSD
2025-10-13 11:16:48 -07:00
Johannes Altmanninger
b07adb532a chsh docs: look up fish in $PATH instead of /usr/local/bin
Now that the « chsh -s $(command -v) » approach should work both
in and outside fish, it seems like we should use that.

Non-macOS users probably shouldn't do this, but there's already a
big warning above this section.

Fixes #11931
2025-10-13 14:03:36 +02:00
Johannes Altmanninger
af72d4aebc Upgrade libc crate for _CS_PATH 2025-10-13 14:03:36 +02:00
Johannes Altmanninger
bfab595379 tests/checks/fish_config: try to work around intermittent CI failure
This is mysteriously failing intermittently on GitHub Actions CI
and OBS.  We get

  The CHECK on line 31 wants:
    {{\\x1b\\[m}}{{\\x1b\\[4m}}fish default{{\\x1b\\[m}}
  which failed to match line stdout:21:
    \x1b[38;2;7;114;161m/bright/vixens\x1b[m \x1b[38;2;34;94;121mjump\x1b[m \x1b[38;2;99;175;208m|\x1b[m \x1b[m\x1b[4mfish default\x1b[m

and it doesn't look like it's produced by the "grep -A1" below,
because the later output looks correct.

See https://github.com/fish-shell/fish-shell/pull/11923#discussion_r2417592216
2025-10-13 14:03:35 +02:00
Peter Ammon
d72adc0124 Add some vagrantfiles for building on BSDs
This only builds, doesn't run tests. Use:

    ./build_fish_on_bsd.sh dragonflybsd_6_4 freebsd_14_0 netbsd_9_3 openbsd_7_4

To build on all of them.

Note they don't all build yet.
2025-10-12 19:00:59 -07:00
Johannes Altmanninger
5f0d83d2f2 cirrus: remove "file" dependency from focal-arm64 builds
Probably that was also part of --install-recommends.
fish requires "file", but system tests don't.
2025-10-12 07:17:48 +02:00
Johannes Altmanninger
03f54171c6 cirrus: delete commented configurations 2025-10-12 07:17:48 +02:00
Johannes Altmanninger
f391b4a179 docker: add back CMake for the images used in Cirrus
build_tools/check.sh would give more coverage (the translation
checks is the main difference) but it tests embed-data builds;
for now testing, traditionally installed builds is more important
(especially since I always test check.sh locally already). In future
we will probably make embedding mandatory and get rid of this schism.
2025-10-12 07:17:48 +02:00
Johannes Altmanninger
8db674b6b5 docker: fix SSL error
Cirrus builds fail with

	error: failed to get `pcre2` as a dependency of package `fish v4.1.0-snapshot (/tmp/cirrus-ci-build)`
	...
	Caused by:
	  the SSL certificate is invalid; class=Ssl (16); code=Certificate (-17)

Likely introduced by b644fdbb04 (docker: do not install recommended
packages on Ubuntu, 2025-10-06).  Some Ubuntu Dockerfiles already
install ca-certificates explicitly but others do not. Fix the latter.
2025-10-12 07:17:48 +02:00
Johannes Altmanninger
f03113d048 __fish_cache_put: fix for BusyBox stat
On alpine, tests/checks/check-completions fails with

	stat: can't read file system information for '%u:%g': No such file or directory
2025-10-12 07:17:48 +02:00
Johannes Altmanninger
6c48e214ca tests/checks/check-completions: fix for embed-data builds 2025-10-12 07:17:48 +02:00
Johannes Altmanninger
189a2e90dd __fish_print_commands: remove code clone
Also, use it for help completions also on embed-data builds.
2025-10-12 07:11:35 +02:00
Johannes Altmanninger
9b44138917 __fish_print_commands: fix environment variable injection 2025-10-12 07:08:24 +02:00
Johannes Altmanninger
ec7d20b347 Reapply "test_driver: support Python 3.8 for now"
Re-apply commit ec27b418e after it was accidentally reverted in
5102c8b137 (Update littlecheck, 2025-10-11),
fixing a hang in e.g.

	sudo docker/docker_run_tests.sh docker/jammy.Dockerfile
2025-10-12 07:01:36 +02:00
Peter Ammon
84b52a3ed1 Resurrect some Dockerfiles
Add missing black and rustfmt
2025-10-11 12:24:20 -07:00
Peter Ammon
30b1c9570f Suppress a deprecation warning on time_t
Continue to pull cirrus builds back into the land of the living.
2025-10-11 12:24:20 -07:00
Johannes Altmanninger
b88622bc35 tests/tmux-job: fix on macOS CI
The rapid input can make the screen look like this:

    fish: Job 1, 'sleep 0.5 &' has ended
    prompt 0> echo hello world
    prompt 0> sleep 3 | cat &
    bg %1 <= no check matches this, previous check on line 24
2025-10-11 18:02:57 +02:00
Johannes Altmanninger
a4edb4020d test_driver.py: output as tests/checks/... not checks/...
Something like

	tests/test_driver.py target/debug checks/foo.fish

is invalid (needs "tests/checks/foo.fish").
Let's make failure output list the right fiel name.

At least when run from the root directory.
Don't change the behavior when run from "tests/";
in that case the path was already relative.
2025-10-11 17:56:31 +02:00
Johannes Altmanninger
e1e5dfdd62 test_driver: don't chdir in async driver
The test driver is async now; so we can't change the process-wide
working directory without causing unpredictable behavior.
For example, given these two tests:

	$ cat tests/checks/a.fish
	#RUN: %fish %s
	#REQUIRES: sleep 1
	pwd >/tmp/pwd-of-a

	$ cat tests/checks/b.fish
	#RUN: %fish %s
	pwd >/tmp/pwd-of-b

running them may give both fish processes the same working directory.

	$ tests/test_driver.py target/debug tests/checks/a.fish tests/checks/b.fish
	tests/checks/b.fish  PASSED      13 ms
	tests/checks/a.fish  PASSED    1019 ms
	2 / 2 passed (0 skipped)
	$ grep . /tmp/pwd-of-a /tmp/pwd-of-b
	/tmp/pwd-of-a:/tmp/fishtest-root-1q_tnyqa/fishtest-s9cyqkgz
	/tmp/pwd-of-b:/tmp/fishtest-root-1q_tnyqa/fishtest-s9cyqkgz
2025-10-11 17:56:31 +02:00
Johannes Altmanninger
5102c8b137 Update littlecheck
Commit c12b8ed (Clean up some lints, 2025-08-28)
2025-10-11 17:54:09 +02:00
Johannes Altmanninger
9ae9db7f70 test_driver: fix code clone 2025-10-11 17:54:09 +02:00
Johannes Altmanninger
d0aaa8d809 create_manpage_completions: fix deprecation warning
Fixes #11930
2025-10-11 17:54:09 +02:00
Johannes Altmanninger
6024539c12 CI lint: consolidate clippy definitions 2025-10-11 17:54:09 +02:00
Johannes Altmanninger
fb06ad4a44 Update sourcehut build images 2025-10-11 17:54:09 +02:00
Johannes Altmanninger
598e98794c Fixes for tmux-fish_config.fish
This fails sometimes in high-concurrency scenarios
(build_tools/check.sh), so allow sleeping a bit longer.
2025-10-11 17:54:09 +02:00
Johannes Altmanninger
b3a295959d webconfig: remove obsolete macOS workaround
As mentioned in #11926 our "fish_config" workaround for macOS
10.12.5 or later has been fixed in macOS 10.12.6 according to
https://andrewjaffe.net/blog/2017/05/python_bug_hunt/, I think we
can assume all users have upgraded to that patch version Remove
the workaround.
2025-10-11 17:54:09 +02:00
Johannes Altmanninger
50dfd962ec Document system test dependencies
Notably, the parent commit adds wget.

While at it, extract a reusable action.
2025-10-11 17:54:09 +02:00
Nahor
65332eaacc Add test for fish_config in browser modified
In particular
- test that it will return an error if the URL is invalid
- that the main page matches the index.html in git
- that "Enter" key will exit

Part of #11907
2025-10-11 17:54:09 +02:00
Nahor
a00e6f8696 Add Github action to compile for MSYS2
Closes #11907
2025-10-11 17:54:09 +02:00
Nahor
6415dfbd35 Ensure different network ports in fish_config
- Windows allows port reuse under certain conditions. In fish_config
case, this allows the signal socket to use the same port as http (e.g.
when using MINGW python). This can cause some browsers to access the
signal socket rather than the http one (e.g. when connecting using
IPv4/"127.0.0.1" instead of IPv6/"::1").
- This is also more efficient since we already know that all ports up to
and including the http one are not available

Fixes #11805

Part of #11907
2025-10-11 17:54:09 +02:00
Nahor
8c387c58de Fix build for MSYS2 (missing ulimits)
Part of #11907
2025-10-11 17:54:09 +02:00
Johannes Altmanninger
da411f6fa7 bg/fg/wait/disown/function: check for negative PID argument
While at it, extract a function.

Seems to have regressed in 4.0.0 (fc47d9fa1d (Use strongly typed
`Pid` for job control, 2024-11-11)).

Fixes #11929
2025-10-11 17:54:09 +02:00
Johannes Altmanninger
8fe402e9f7 fg: remove rogue abs() on PID argument
Present since the initial commit but I don't think anyone relies
on this.
2025-10-11 17:54:09 +02:00
Johannes Altmanninger
c41fc52077 bg: deduplicate job argument
"bg %1" of a pipline prints the same line twice because it tries
to background the same job twice.  This doesn't make sense and
other builtins like "disown" already deduplicate, so do the same.
Unfortunately we can't use the same approach as "disown" because we
can't hold on to references to job, since we're modifying the job list.
2025-10-11 17:53:30 +02:00
Johannes Altmanninger
f7d730390c Rename process id -> process ID 2025-10-11 11:47:34 +02:00
Johannes Altmanninger
8fc30d5243 po/fr.po: delete bad translation 2025-10-11 11:47:16 +02:00
Isaac Oscar Gariano
93c4d63295 Allow overwriting argv with function -a and -V
Previously, if you called a function parameter 'argv', within the body
of the function, argv would be set to *all* the arguments to the
function, and not the one indicated by the parameter name.
The same behaviour happened if you inherited a variable named 'argv'.
Both behaviours were quite surprising, so this commit makes things more
obvious, although they could alternatively simply be made errors.

Part of #11780
2025-10-11 10:51:36 +02:00
Isaac Oscar Gariano
7a07c08860 Output function argument-names in one group.
This makes it so that printing a function definition will only use one
--argument-names group, instead of one for argument name.
For example, "function foo -a x y; ..." will print with "function foo
--argument-names x y" instead of "function foo --argument-names x
--argument-names y", which is very bizarre.

Moreover, the documentation no longer says that argument-names "Has to
be the last option.". This sentence appears to have been introduced in
error by pull #10524, since the ability to have options afterwards was
deliberately added by pull #6188.

Part of #11780
2025-10-11 10:50:07 +02:00
Isaac Oscar Gariano
1cf110d083 Use idiomatic Rust error handling for function builtin.
This simply does the same thing as #10948, but for the function builtin.

Part of #11780
2025-10-11 10:46:21 +02:00
Johannes Altmanninger
fef358fc74 Move remaining builtin implementations to dedicated files
This makes them a bit easier to find I guess.
2025-10-11 09:40:37 +02:00
Daniel Rainer
b5feb79a7c style: format entire repo by default
We want all Rust and Python files formatted, and making formatting
behavior dependent on the directory `style.fish` is called from can be
counter-intuitive, especially since `check.sh`, which also calls
`style.fish` is otherwise written in a way that allows calling it from
arbitrary working directories and getting the same results.

Closes #11925
2025-10-10 10:36:52 +02:00
Daniel Rainer
4d52245617 ci: run style.fish
This allows checking formatting of fish script and Python files, in
addition to Rust files.

Closes #11923
2025-10-10 10:36:52 +02:00
Daniel Rainer
ff308b36af ci: rename workflows
The new names are consistently formulated as commands.

`main` is not very descriptive, so change it to `test`, which is more
informative and accurate.

`rust_checks` are replaced be the more general `lint` in preparation for
non-Rust-related checks.

These changes were suggested in
https://github.com/fish-shell/fish-shell/pull/11918#discussion_r2415957733

Closes #11922
2025-10-10 10:36:08 +02:00
Johannes Altmanninger
fa8cf8a1a5 abbr: fix extra Chinese translation
Closes #11919
2025-10-09 18:12:04 +02:00
Daniel Rainer
5ade4a037e style: replace black with ruff for Python formatting
Ruff's default format is very similar to black's, so there are only a
few changes made to our Python code. They are all contained in this
commit. The primary benefit of this change is that ruff's performance is
about an order of magnitude better, reducing runtime on this repo down
to under 20ms on my machine, compared to over 150ms with black, and even
more if any changes are performed by black.

Closes #11894

Closes #11918
2025-10-09 18:12:03 +02:00
Johannes Altmanninger
861002917a tests/checks/po-files-well-formed: fix inconsistent msgfmt check 2025-10-09 18:12:03 +02:00
Fabian Boehm
eddb26d490 completions/ssh: Don't read ":" from historical hosts
Fixes #11917
2025-10-09 17:14:09 +02:00
Johannes Altmanninger
b7fe3190bb Revert "builtin function: remove dead code"
This reverts commit 993b977c9b.

Fixes #11912
2025-10-08 10:51:47 +02:00
Johannes Altmanninger
b6ddb56cc7 release.sh: fix milestone API calls 2025-10-08 10:51:47 +02:00
Johannes Altmanninger
8dd59081d7 github workflows lockthreads: only run on main repo
We should disable the whole action instead of the job but I don't
know how to do that.
2025-10-08 10:51:47 +02:00
Johannes Altmanninger
3ae17ea100 release.sh: fix deployment approval logic
(cherry picked from commit e074b27abf)
2025-10-08 10:51:47 +02:00
Fabian Boehm
10c34c5353 Revert "Move the C compiler requrement in readme"
build.rs still uses cc:: for feature detection, as 50819666b1 points out.

This reverts commit 594f1df39c.
2025-10-07 22:47:14 +02:00
Johannes Altmanninger
e3ebda3647 tests/checks/fish_config: fix for non-embedded builds 2025-10-07 22:23:04 +02:00
Johannes Altmanninger
092e7fa274 release.sh: check fish-site worktree staleness 2025-10-07 22:23:04 +02:00
Johannes Altmanninger
dd47c2baa2 Sanitize cursor position report on kitty click_events
This is easy to trigger by having a background process do "echo" to
move the terminal cursor to the next line, and then clicking anywhere.

Fixes #11905
2025-10-07 21:54:26 +02:00
Johannes Altmanninger
15065255e9 fish_config: fix regression "theme show" not showing custom themes
This regressed in 6f0532460a5~2..6f0532460a5 (fish_config: fix for
non-embedded builds, 2025-09-28).

Fixes #11903
2025-10-07 21:54:26 +02:00
Johannes Altmanninger
594f1df39c Move the C compiler requrement in readme
Fixes #11908
2025-10-07 21:54:26 +02:00
Johannes Altmanninger
724416125e tests/checks/config-paths-standalone.fish: fix bad assertion
Fixes #11906
2025-10-07 17:26:48 +02:00
Johannes Altmanninger
3afafe6398 Fix build on OpenBSD/NetBSD
Co-authored-by: Michael Nickerson <darkshadow02@me.com>
Co-authored-by: Asuka Minato <i@asukaminato.eu.org>

Tested on OpenBSD; we'll see about NetBSD.

Closes #11893
Closes #11892
Closes #11904
2025-10-07 15:24:02 +02:00
Johannes Altmanninger
af7446a055 Start using cfg_if 2025-10-07 15:24:02 +02:00
Johannes Altmanninger
7be101e8c9 Add OpenBSD sourcehut config 2025-10-07 15:24:01 +02:00
Johannes Altmanninger
5f18b173dd ulimit: add back RLIMIT_NICE on linux 2025-10-07 15:24:01 +02:00
Johannes Altmanninger
3fec9c8145 Embedded builds to use $workspace_root/etc again if run from build dir
Commit f05ad46980 (config_paths: remove vestiges of installable
builds, 2025-09-06) removed a bunch of code paths for embed-data
builds, since those builds can do without most config paths.

However they still want the sysconfig path.  That commit made
embedded builds use "/etc/fish" unconditionally.  Previously they
used "$workspace_root/etc".  This is important when running tests,
which should not read /etc/fish.

tests/checks/invocation.fish tests this implicitly: if /etc/fish does
not exist, then

	fish --profile-startup /dev/stdout

will not contain "builtin source".

Let's restore historical behavior.  This might be annoying for users
who "install" with "ln -s target/debug/fish ~/bin/", but that hasn't
ever been recommended, and the historical behavior was in effect
until 4.1.0.

Fixes #11900
2025-10-07 15:24:01 +02:00
Johannes Altmanninger
bdca70bfb0 build.rs: extract function for overridable paths
Also get rid of cursed get_path().
2025-10-07 15:24:01 +02:00
Johannes Altmanninger
5e28f068ec build.rs: dedicated error for bad encoding in environment variables
We should probably not silently treat invalid Unicode the same as
"the variable is unset", even though it probably makes no difference
in practice.
2025-10-07 15:24:01 +02:00
Johannes Altmanninger
a0b22077a5 Extract constant for resolved build directory
Also use a different name than for the CMake variable, to reduce
confusion.
2025-10-07 11:59:45 +02:00
Daniel Rainer
1d36b04ea6 check.sh: export gettext extraction file variable
Some versions of `/bin/sh`, e.g. the one on FreeBSD, do not propagate
variables set on a command through shell functions. This results in
`FISH_GETTEXT_EXTRACTION_FILE` being set in the `cargo` function, but
not for the actual `cargo` process spawned from the function, which
breaks our localization scripts and tests. Exporting the variable
prevents that.

Fixes #11896

Closes #11899
2025-10-07 10:49:39 +02:00
Daniel Rainer
6829c9d678 printf-c: restore length modifiers
These were accidentally removed when semi-automatically removing length
modifiers from Rust code and shell scripts.

In C, the length modifiers are required.

Closes #11898
2025-10-07 07:52:26 +02:00
Ilya Grigoriev
e1f6ab8916 checks: make tmux-multiline-prompt less affected by less config
Fixes #11881 for me. Thanks, @krobelus, for the help with debugging
this!

The `-+X` is unrelated to the bug, strictly speaking, but makes sure the
test tests what it is intended to test.

I initially thought of also adding `LESS=` and something like
`--lesskey-content=""` to the command, but I decided against it since
`less` can also maybe be configured with `LESSOPEN` (?) and I don't know
how long the `--lesskey-content` option existed.

Closes #11891
2025-10-06 15:08:25 +02:00
Daniel Rainer
778baaecb5 sprintf: remove signed int size info
The size was used to keep track of the number of bits of the input type
the `Arg::SInt` variant was created from. This was only relevant for
arguments defined in Rust, since the `printf` command takes all
arguments as strings.

The only thing the size was used for is for printing negative numbers
with the `x` and `X` format specifiers. In these cases, the `i64` stored
in the `SInt` variant would be cast to a `u64`, but only the number of
bits present in the original argument would be kept, so `-1i8` would be
formatted as `ff` instead of `ffffffffffffffff`.

There are no users of this feature, so let's simplify the code by
removing it. While we're at it, also remove the unused `bool` returned
by `as_wrapping_sint`.

Closes #11889
2025-10-06 15:08:25 +02:00
Daniel Rainer
a189f79590 input: remove dead code
See https://github.com/fish-shell/fish-shell/pull/11874#discussion_r2404478880
> There is a comment saying `// Keep this function for debug purposes`
but I'm sure that's obsolete, since ReadlineCmd implements `Debug` now.

Closes #11887
2025-10-06 15:08:25 +02:00
Ada Magicat
6395644e8c doc: correct example of fish_should_add_to_history
Closes #11886
2025-10-06 15:08:25 +02:00
Johannes Altmanninger
a958f23f63 Fix regression on paste in non-interactive read
As reported in
https://github.com/fish-shell/fish-shell/issues/11836#issuecomment-3369973613,
running "fish -c read" and pasting something would result this error
from __fish_paste:

	commandline: Can not set commandline in non-interactive mode

Bisects to 32c36aa5f8 (builtins commandline/complete: allow handling
commandline before reader initialization, 2025-06-13).  That commit
allowed "commandline" to work only in interactive sessions, i.e. if
stdin is a TTY or if overridden with -i.

But this is not the only case where fish might read from the TTY.
The notable other case is builtin read, which also works in
noninteractive shells.
Let's allow "commandline" at least after we have initialized the TTY
for the first reader, which restores the relevant historical behavior
(which is weird, e.g. « fish -c 'read; commandline foo' »).
2025-10-06 15:08:25 +02:00
Johannes Altmanninger
ec8756d7a3 tests/checks/read: add test for non-interactive use of commandline 2025-10-06 15:04:19 +02:00
Xiretza
b7fabb11ac Make command run by __fish_echo output to TTY for color detection
Without this, e.g. Alt-L shows the directory entries one per line and
without colors.

Closes #11888
2025-10-06 13:39:30 +02:00
Johannes Altmanninger
74ba4e9a98 docker_builds: run only on fish-shell/fish-shell repo
Else this runs when people push to their master's forks, see
https://github.com/fish-shell/fish-shell/pull/11884#discussion_r2405618358
2025-10-06 13:29:08 +02:00
Johannes Altmanninger
b1e8fdfaa2 Revert "CI: use build_tools/check.sh in Cirrus CI"
I think we do want to stop using CMake on Cirrus but this should
first be tested in combination with all the other changes that made
it to master concurrently (test by pushing a temporary branch to the
fish-shell repo), to avoid confusion as to what exactly broke.

This reverts commit d167ab9376.

See #11884
2025-10-06 13:28:49 +02:00
Johannes Altmanninger
9eb439c01d Revert "Allow black to be missing in style.fish"
The root cause was that FISH_CHECK_LINT was not set. By
default, check.sh should fail if any tool is not installed, see
59b43986e9 (build_tools/style.fish: fail if formatters are not
available, 2025-07-24); like it does for rustfmt and clippy.

This reverts commit fbfd29d6d2.

See #11884
2025-10-06 13:27:47 +02:00
Peter Ammon
fbfd29d6d2 Allow black to be missing in style.fish
Stop failing BSD builds because black is missing.
2025-10-05 20:49:49 -07:00
Peter Ammon
f158a3ae3e Revert "Attempt to fix Cirrus builds harder"
This reverts commit d683769e1f.
2025-10-05 20:38:22 -07:00
Peter Ammon
7d59b4f4e2 Add an unnecessary_cast suppression
Continue to help fix BSD builds.
2025-10-05 20:12:55 -07:00
Peter Ammon
e99eca47c3 Add .claude to gitignore 2025-10-05 19:58:28 -07:00
Peter Ammon
d683769e1f Attempt to fix Cirrus builds harder
Install black
2025-10-05 19:58:02 -07:00
Peter Ammon
9ea328e43a Fix the BSD builds
These relied on constants that don't actually exist.
2025-10-05 19:30:33 -07:00
David Adam
f6d93f2fdb GitHub Actions: add workflow to build Docker images for CI 2025-10-06 09:50:56 +08:00
David Adam
b644fdbb04 docker: do not install recommended packages on Ubuntu
This should speed things up a bit, but various additional packages need
to be installed.
2025-10-06 09:50:56 +08:00
David Adam
7647d68b68 docker: fix Rust package name for jammy 2025-10-06 09:50:56 +08:00
David Adam
d167ab9376 CI: use build_tools/check.sh in Cirrus CI
08b03a733a removed CMake from the Docker images used for the
Cirrus builds.

It might be better to use fish_run_tests.sh in the Docker image, but
that requires some context which I'm not sure is set up properly in
Cirrus.
2025-10-06 09:50:55 +08:00
David Adam
e68bd2f980 build_tools/check.sh: add support for FISH_TEST_MAX_CONCURRENCY 2025-10-06 09:50:55 +08:00
Jesse Harwin
b5c17d4743 completions/bind: bug fixes, cleanup, and complete multiple functions
Revamped and renamed the __fish_bind_test2 function. Now has a
more explicit name, `__fish_bind_has_keys`  and allows for multiple
functions after the key-combo, doesn't offer function names after an
argument with a parameter (e.g. -M MODE).

Logic on the function is now more concise.

Closes #11864
2025-10-05 15:16:41 +02:00
Jesse Harwin
66ca7ac6d0 completions/bind: removed the unused __fish_bind_test1 function 2025-10-05 15:16:41 +02:00
Johannes Altmanninger
e97a616ffa completions/bind: don't suggest key names if --function-names is given
This combination makes no sense and should be an error.  (Also the
short options and --key-names were missing, so this was quite
inconsistent.)

See #11864
2025-10-05 15:16:41 +02:00
Ilya Grigoriev
061517cd14 completion/set: fix bug preventing showing history or fish_killring
Previously, `set -S fish_kill<TAB>` did not list `fish_killring`. This
was because `$1` wasn't sufficiently escaped, and so instead of
referring to a regex capture group, it was always empty.

Closes #11880
2025-10-05 15:16:41 +02:00
Johannes Altmanninger
6accc475c9 Don't use kitty keyboard protocol support to decide timeout
As reported in
https://github.com/fish-shell/fish-shell/discussions/11868, some
terminals advertise support for the kitty keyboard protocol despite
it not necessarily being enabled.

We use this flag in 30ff3710a0 (Increase timeout when reading
escape sequences inside paste/kitty kbd, 2025-07-24), to support
the AutoHotKey scenario on terminals that support the kitty keyboard
protocols.

Let's move towards the more comprehensive fix mentioned in abd23d2a1b
(Increase escape sequence timeout while waiting for query response,
2025-09-30), i.e. only apply a low timeout when necessary to actually
distinguish legacy escape.

Let's pick 30ms for now (which has been used successfully for similar
things historically, see 30ff3710a0); a higher timeout let alone
a warning on incomplete sequence seems risky for a patch relase,
and it's also not 100% clear if this is actually a degraded state
because in theory the user might legitimately type "escape [ 1"
(while kitty keyboard protocol is turned off, e.g. before the shell
regains control).

This obsoletes and hence reverts commit 623c14aed0 (Kitty keyboard
protocol is non-functional on old versions of Zellij, 2025-10-04).
2025-10-05 15:16:41 +02:00
Johannes Altmanninger
c2e2fd6432 fish_add_path: remove extra argument to printf 2025-10-05 15:16:41 +02:00
Daniel Rainer
83af5c91bd printf: remove all uses of length modifiers
Length modifiers are useless. This simplifies the code a bit, results in
more consistency, and allows removing a few PO messages which only
differed in the use of length modifiers.

Closes #11878
2025-10-05 15:16:41 +02:00
Peter Ammon
e9f5982147 Fix a clipply 2025-10-04 19:25:10 -07:00
Peter Ammon
50819666b1 Remove our own C bits
fish-shell itself no longer depends on a C compiler; however we still
use cc for feature detection. Removing that will have to wait for another day.
2025-10-04 18:56:11 -07:00
Peter Ammon
6ad13e35c0 Bravely define PATH_BSHELL
PATH_BSHELL is always "/bin/sh" except on Android where it's "/system/bin/sh".

This isn't exposed by Rust, so just define it ourselves.
2025-10-04 17:27:16 -07:00
Peter Ammon
39e2f1138b Bravely stop setting stdout to unbuffered
Issue #3748 made stdout (the C FILE*, NOT the file descriptor) unbuffered,
due to concerns about mixing output to the stdout FILE* with output output.

We no longer write to the C FILE* and Rust libc doesn't expose stdout, which may
be a macro. This code no longer looks useful. Bravely remove it.
2025-10-04 17:27:15 -07:00
Peter Ammon
cd37c71e29 Adopt Rust libc RLIMIT_* fields
Moving more stuff out of C.
2025-10-04 14:09:47 -07:00
Peter Ammon
c1f3d93b3b Adopt Rust libc::MNT_LOCAL
Note the ST_LOCAL usage on NetBSD is also covered by this.
2025-10-04 14:09:46 -07:00
Peter Ammon
0aa05032c4 Adopt rust _PC_CASE_SENSITIVE
fish no longer needs to expose this - the libc crate does the job.
2025-10-04 14:01:13 -07:00
Peter Ammon
174130fe2f Adopt Rust libc _CS_PATH
This is now supported directly by the libc crate - no need for fish
to expose this via C.
2025-10-04 14:01:11 -07:00
Peter Ammon
d06f7f01d2 Remove MB_CUR_MAX from our libc ffi
We no longer need this.
2025-10-04 13:39:22 -07:00
Peter Ammon
a04ddd9b17 Adopt get_is_multibyte_locale in the pager 2025-10-04 13:39:22 -07:00
Peter Ammon
12929fed74 Adopt get_is_multibyte_locale in decode_input_byte
Move away from MB_CUR_MAX
2025-10-04 13:39:22 -07:00
Peter Ammon
87bf580f68 Adopt get_is_multibyte_locale in wcs2string_callback
Move away from MB_CUR_MAX
2025-10-04 13:39:22 -07:00
Peter Ammon
66bab5e767 Early work aiming to remove MB_CUR_MAX from fish libc FFI
Start detecting multibyte locales in Rust.
2025-10-04 13:39:21 -07:00
Peter Ammon
4b12fb2887 Migrate invalidate_numeric_locale into fish_setlocale
Centralizes where locale information is recomputed.
2025-10-04 13:39:21 -07:00
Johannes Altmanninger
623c14aed0 Kitty keyboard protocol is non-functional on old versions of Zellij
try_readb() uses a high timeout when the kitty keyboard protocol is
enabled, because in that case it should basically never be necessary
to interpret \e as escape key, see 30ff3710a0 (Increase timeout when
reading escape sequences inside paste/kitty kbd, 2025-07-24).

Zellij before commit 0075548a (fix(terminal): support kitty keyboard
protocol setting with "=" (#3942), 2025-01-17) fails to enable kitty
keyboard protocol, so it sends the raw escape bytes, causing us to
wait 300ms.

Closes #11868
2025-10-04 07:17:34 +02:00
Johannes Altmanninger
7d83dc4758 Refresh TTY timestamps after firing focus events
Using a multi-line prompt with focus events on:

	tmux new-session fish -C '
		tmux set -g focus-events on
		set -g fish_key_bindings fish_vi_key_bindings
		function fish_prompt
		    echo (prompt_pwd)
		    echo -n "> "
		end
		tmux split
	'

switching to the fish pane and typing any key sometimes leads to our
two-line-prompt being redawn one line below it's actual place.

Reportedly, it bisects to d27f5a5 which changed when we print things.
I did not verify root cause, but
1. symptoms are very similar to other
   problems with TTY timestamps, see eaa837effa (Refresh TTY
   timestamps again in most cases, 2025-07-24).
2. this seems fixed if we refresh timestamps after
   running the focus events, which print some cursor shaping commands
   to stdout. So bravely do that.

Closes #11870
2025-10-03 22:35:31 +02:00
Johannes Altmanninger
493d0bca95 Update changelog for patch release 2025-10-03 22:01:39 +02:00
qianlongzt
983501ff8c zh_CN: fix vi case
Part of #11854
2025-10-03 20:51:57 +02:00
The0x539
20da9a2b51 ast: use macro_rules_attribute for the Acceptor trait
Closes #11867
2025-10-03 20:45:01 +02:00
The0x539
7aec6c55f9 ast: use macro_rules_attribute for Leaf trait
Part of #11867
2025-10-03 20:45:01 +02:00
The0x539
532f30e031 ast: use macro_rules_attribute for Node trait
Part of #11867
2025-10-03 20:45:01 +02:00
Daniel Rainer
1d7ab57e3a xgettext: remove --strict flag from msguniq
As with `msgmerge`, this introduces unwanted empty comment lines above
`#, c-format`
lines. We don't need this strict formatting, so we get rid of the flag
and the associated empty comment lines.

Closes #11863
2025-10-03 20:22:59 +02:00
Étienne Deparis
8adc598e90 web_config: Support long options separated with = from their value
Closes #11861
2025-10-03 20:18:38 +02:00
Étienne Deparis
c884c08257 web_config: Use None as default for underline style
Underline is no more a boolean and should be one of the accepted style,
or None. By keeping False as default value, web_config was generating
wrong --underline=False settings

Part of #11861
2025-10-03 20:18:38 +02:00
Daniel Rainer
66dc734c11 printf: remove useless length modifiers
Closes #11858
2025-10-03 20:14:20 +02:00
Daniel Rainer
77fee9acb9 printf: rename direc -> directive
The abbreviation is ambiguous, which makes the code unnecessarily hard
to read. (possible misleading expansions: direct, direction, director,
...)

Part of #11858
2025-10-03 20:14:20 +02:00
Daniel Rainer
6b66c2bc1d printf: use options for idiomatic code
The `have_foo: bool` + `foo: i64` combination is more idiomatically
represented as `foo: Option<i64>`. This change is applied for
`field_width` and `precision`.

In addition, the sketchy explicit cast from `i64` to `c_int`, and the
subsequent implicit cast from `c_int` to `i32` are avoided by using
`i64` consistently.

Part of #11858
2025-10-03 20:14:20 +02:00
Daniel Rainer
81b9f50dc2 printf: reformat doc comments
Part of #11858
2025-10-03 20:14:20 +02:00
Johannes Altmanninger
fcd246064b Stop requesting modifyOtherKeys on old Midnight Commander again
This upstream issue was fixed in 0ea77d2ec (Ticket #4597: fix CSI
parser, 2024-10-09); for old mc's we had worked around this but the
workaround was accidentally removed. Add it back for all the versions
that don't have that fix.

Fixes f0e007c439 (Relocate tty metadata and protocols and clean
it up, 2025-06-19) Turns out this was why the "Capability" enum was
added in 2d234bb676 (Only request keyboard protocols once we know
if kitty kbd is supported, 2025-01-26).

Fixes #11869
2025-10-03 20:14:20 +02:00
Johannes Altmanninger
86a0a348ee Harmonize temporary Midnight Commander workarounds a bit 2025-10-03 18:18:05 +02:00
Johannes Altmanninger
ed36e852d2 release.sh: add next patch milestone
This is still the common case.
2025-10-03 18:08:28 +02:00
Johannes Altmanninger
da5d93c1e2 release.sh: close milestone when done
Don't fail early if this doesn't exist, because it's not needed for
testing this on fish-shell forks that live on GitHub.
2025-10-03 18:08:28 +02:00
Johannes Altmanninger
7b59ae0d82 Unbreak hack to strip " (deleted)" suffix from executable path
Commit 49b88868df (Fix stripping of " (deleted)" from non-UTF8 paths
to fish, 2024-10-12) was wrong because Path::ends_with() considers
entire path components. Fix that.

Refs:
- https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$k2IQazfmztFUXrairmIQvx_seS1ZJ7HlFWhmNy479Dg
- https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$4pugfHejL9J9L89zuFU6Bfg41UMjA0y79orc3EaBego
2025-10-03 18:08:28 +02:00
Fabian Boehm
97acc12d62 Fix scp completions
Introduced when __fish_mktemp_relative was.

Fixes #11860
2025-10-02 18:20:41 +02:00
675 changed files with 118396 additions and 31768 deletions

View File

@@ -1,7 +1,6 @@
image: alpine/edge
packages:
- cargo
- clang17-libclang
- cmake
- ninja
- pcre2-dev
@@ -24,4 +23,4 @@ tasks:
ninja
- test: |
cd fish-shell/build
ninja test
ninja fish_run_tests

View File

@@ -20,4 +20,4 @@ tasks:
ninja
- test: |
cd fish/build
ninja test
ninja fish_run_tests

View File

@@ -5,10 +5,10 @@ packages:
- gettext
- gmake
- llvm
- terminfo-db
- ninja
- pcre2
- py311-pexpect
- py311-sphinx
- python
- rust
- tmux
@@ -27,4 +27,4 @@ tasks:
ninja
- test: |
cd fish-shell/build
ninja test
ninja fish_run_tests

30
.builds/openbsd.yml Normal file
View File

@@ -0,0 +1,30 @@
image: openbsd/latest
packages:
- cmake
- gcc
- gettext
- gmake
- llvm
- ninja
- pcre2
- py3-pexpect
- py3-sphinx
- python
- rust
- tmux
sources:
- https://github.com/fish-shell/fish-shell
tasks:
- build: |
cd fish-shell
mkdir build
cd build
cmake -GNinja .. \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_DATADIR=share \
-DCMAKE_INSTALL_DOCDIR=share/doc/fish \
-DCMAKE_INSTALL_SYSCONFDIR=/etc
ninja
- test: |
cd fish-shell/build
ninja fish_run_tests

View File

@@ -8,18 +8,10 @@ linux_task:
container: &step
image: ghcr.io/krobelus/fish-ci/alpine:latest
memory: 4GB
- name: jammy
- name: ubuntu-oldest-supported
container:
<<: *step
image: ghcr.io/krobelus/fish-ci/jammy:latest
# - name: jammy-asan
# container:
# <<: *step
# image: ghcr.io/krobelus/fish-ci/jammy-asan:latest
# - name: focal-32bit
# container:
# <<: *step
# image: ghcr.io/krobelus/fish-ci/focal-32bit:latest
image: ghcr.io/krobelus/fish-ci/ubuntu-oldest-supported:latest
tests_script:
# cirrus at times gives us 32 procs and 2 GB of RAM
# Unrestriced parallelism results in OOM
@@ -31,32 +23,11 @@ linux_task:
- ninja fish_run_tests
only_if: $CIRRUS_REPO_OWNER == 'fish-shell'
linux_arm_task:
matrix:
- name: focal-arm64
arm_container:
image: ghcr.io/fish-shell/fish-ci/focal-arm64
- name: jammy-armv7-32bit
arm_container:
image: ghcr.io/fish-shell/fish-ci/jammy-armv7-32bit
tests_script:
# cirrus at times gives us 32 procs and 2 GB of RAM
# Unrestriced parallelism results in OOM
- lscpu || true
- (cat /proc/meminfo | grep MemTotal) || true
- mkdir build && cd build
- FISH_TEST_MAX_CONCURRENCY=6 cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug ..
- ninja -j 6 fish
- file ./fish
- ninja fish_run_tests
# CI task disabled during RIIR transition
only_if: false && $CIRRUS_REPO_OWNER == 'fish-shell'
freebsd_task:
matrix:
- name: FreeBSD 14
- name: FreeBSD Stable
freebsd_instance:
image: freebsd-14-3-release-amd64-ufs
image: freebsd-15-0-release-amd64-ufs # updatecli.d/cirrus-freebsd.yml
tests_script:
- pkg install -y cmake-core devel/pcre2 devel/ninja gettext git-lite lang/rust misc/py-pexpect
# libclang.so is a required build dependency for rust-c++ ffi bridge

View File

@@ -14,7 +14,6 @@ indent_style = tab
[*.{md,rst}]
max_line_length = unset
trim_trailing_whitespace = false
[*.sh]
indent_size = 4

2
.gitattributes vendored
View File

@@ -14,8 +14,6 @@
.gitattributes export-ignore
.gitignore export-ignore
/build_tools/make_tarball.sh export-ignore
/debian export-ignore
/debian/* export-ignore
/.github export-ignore
/.github/* export-ignore
/.builds export-ignore

2
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,2 @@
github:
- krobelus

View File

@@ -0,0 +1,41 @@
name: Install dependencies for system tests
inputs:
include_sphinx:
description: Whether to install Sphinx
required: true
default: false
include_pcre:
description: Whether to install the PCRE library
required: false
default: true
permissions:
contents: read
runs:
using: "composite"
steps:
- shell: bash
env:
include_pcre: ${{ inputs.include_pcre }}
run: |
set -x
: "optional dependencies"
sudo apt install \
gettext \
$(if $include_pcre; then echo libpcre2-dev; fi) \
;
: "system test dependencies"
sudo apt install \
diffutils $(: "for diff") \
git \
gettext \
less \
$(if ${{ inputs.include_pcre }}; then echo libpcre2-dev; fi) \
python3-pexpect \
tmux \
wget \
;
- uses: ./.github/actions/install-sphinx
if: ${{ inputs.include_sphinx == 'true' }}

View File

@@ -1,14 +0,0 @@
name: Install sphinx-markdown-builder
permissions:
contents: read
runs:
using: "composite"
steps:
- shell: bash
run: |
set -x
commit=b259de1dc97573a71470a1d71c3d83535934136b
pip install git+https://github.com/krobelus/sphinx-markdown-builder@"$commit"
python -c 'import sphinx_markdown_builder'

View File

@@ -0,0 +1,23 @@
name: Install sphinx
permissions:
contents: read
runs:
using: "composite"
steps:
- shell: bash
run: |
set -x
sudo pip install uv --break-system-packages
command -v uv
command -v uvx
# Check that pyproject.toml and the lock file are in sync.
# TODO Use "uv" to install Python as well.
: 'Note that --no-managed-python below would be implied but be explicit'
uv='env UV_PYTHON=python uv --no-managed-python'
$uv lock --check --exclude-newer="$(awk -F'"' <uv.lock '/^exclude-newer[[:space:]]*=/ {print $2}')"
# Install globally.
sudo $uv pip install --group=dev --system --break-system-packages
# Smoke test.
python -c 'import sphinx; import sphinx_markdown_builder'

View File

@@ -0,0 +1,41 @@
name: Rust Toolchain
inputs:
toolchain_channel:
description: Either "stable" or "msrv"
required: true
targets:
description: Comma-separated list of target triples to install for this toolchain
required: false
components:
description: Comma-separated list of components to be additionally installed
required: false
permissions:
contents: read
runs:
using: "composite"
steps:
- name: Set toolchain
env:
toolchain_channel: ${{ inputs.toolchain_channel }}
shell: bash
run: |
set -x
toolchain=$(
case "$toolchain_channel" in
(stable) echo 1.92 ;; # updatecli.d/rust.yml
(msrv) echo 1.85 ;; # updatecli.d/rust.yml
(*)
printf >&2 "error: unsupported toolchain channel %s" "$toolchain_channel"
exit 1
;;
esac
)
printf 'TOOLCHAIN=%s\n' "$toolchain" >>"$GITHUB_ENV"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.TOOLCHAIN }}
targets: ${{ inputs.targets }}
components: ${{ inputs.components }}

View File

@@ -14,7 +14,8 @@ permissions:
runs:
using: "composite"
steps:
- uses: dtolnay/rust-toolchain@1.70
- uses: ./.github/actions/rust-toolchain
with:
toolchain_channel: "msrv"
targets: ${{ inputs.targets }}
components: ${{ inputs.components}}
components: ${{ inputs.components }}

View File

@@ -14,7 +14,8 @@ permissions:
runs:
using: "composite"
steps:
- uses: dtolnay/rust-toolchain@1.90
- uses: ./.github/actions/rust-toolchain
with:
toolchain_channel: "stable"
targets: ${{ inputs.targets }}
components: ${{ inputs.components }}

View File

@@ -0,0 +1,64 @@
name: Build Docker test images
on:
push:
branches:
- master
paths:
- 'docker/**'
workflow_dispatch:
concurrency:
group: docker-builds
env:
REGISTRY: ghcr.io
NAMESPACE: fish-ci
jobs:
docker-build:
if: github.repository_owner == 'fish-shell'
permissions:
contents: read
packages: write
attestations: write
id-token: write
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: alpine
- os: ubuntu-latest
target: ubuntu-oldest-supported
runs-on: ${{ matrix.os }}
steps:
-
name: Checkout
uses: actions/checkout@v5
-
name: Login to Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.NAMESPACE }}/${{ matrix.target }}
flavor: |
latest=true
-
name: Build and push
uses: docker/build-push-action@v6
with:
context: docker/context
push: true
file: docker/${{ matrix.target }}.Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

24
.github/workflows/lint-dependencies.yml vendored Normal file
View File

@@ -0,0 +1,24 @@
name: Lint Dependencies
on:
push:
paths:
- '.github/workflows/lint-dependencies.yml'
- 'Cargo.lock'
- '**/Cargo.toml'
- 'deny.toml'
pull_request:
paths:
- '.github/workflows/lint-dependencies.yml'
- 'Cargo.lock'
- '**/Cargo.toml'
- 'deny.toml'
jobs:
cargo-deny:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v2
with:
command: check licenses
arguments: --all-features --locked --exclude-dev
rust-version: 1.92 # updatecli.d/rust.yml

View File

@@ -1,4 +1,4 @@
name: Rust checks
name: Lint
on: [push, pull_request]
@@ -6,25 +6,39 @@ permissions:
contents: read
jobs:
rustfmt:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/rust-toolchain@stable
with:
components: rustfmt
- name: cargo fmt
run: cargo fmt --check
- name: install dependencies
run: pip install ruff
- name: build fish
run: cargo build
- name: check format
run: PATH="target/debug:$PATH" build_tools/style.fish --all --check
- name: check rustfmt
run: find build.rs crates src -type f -name '*.rs' | xargs rustfmt --check
clippy-stable:
clippy:
runs-on: ubuntu-latest
strategy:
matrix:
features: ["", "--no-default-features"]
include:
- rust_version: "stable"
features: ""
- rust_version: "stable"
features: "--no-default-features"
- rust_version: "msrv"
features: ""
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/rust-toolchain@stable
- uses: ./.github/actions/rust-toolchain
with:
toolchain_channel: ${{ matrix.rust_version }}
components: clippy
- name: Install deps
run: |
@@ -32,19 +46,6 @@ jobs:
- name: cargo clippy
run: cargo clippy --workspace --all-targets ${{ matrix.features }} -- --deny=warnings
clippy-msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/rust-toolchain@oldest-supported
with:
components: clippy
- name: Install deps
run: |
sudo apt install gettext
- name: cargo clippy
run: cargo clippy --workspace --all-targets -- --deny=warnings
rustdoc:
runs-on: ubuntu-latest
steps:

View File

@@ -12,6 +12,7 @@ permissions:
jobs:
lock:
if: github.repository_owner == 'fish-shell'
permissions:
issues: write # for dessant/lock-threads to lock issues
pull-requests: write # for dessant/lock-threads to lock PRs

View File

@@ -41,8 +41,8 @@ jobs:
# Workaround for https://github.com/actions/checkout/issues/882
ref: ${{ inputs.version }}
- name: Install dependencies
run: sudo apt install cmake gettext ninja-build python3-pip python3-sphinx
- uses: ./.github/actions/install-sphinx-markdown-builder
run: sudo apt install cmake gettext ninja-build python3-pip
- uses: ./.github/actions/install-sphinx
- name: Create tarball
run: |
set -x
@@ -52,7 +52,10 @@ jobs:
# Need history since the last release (i.e. tag) for stats.
git fetch --tags
git fetch --unshallow
sh -x ./build_tools/release-notes.sh >"$relnotes"
gpg_public_key_url=https://github.com/${{ github.actor }}.gpg
curl -sS "$gpg_public_key_url" | grep 'PGP PUBLIC KEY BLOCK' -A5
FISH_GPG_PUBLIC_KEY_URL=$gpg_public_key_url \
sh -x ./build_tools/release-notes.sh >"$relnotes"
# Delete title
sed -n 1p "$relnotes" | grep -q "^## fish .*"
sed -n 2p "$relnotes" | grep -q '^$'
@@ -68,7 +71,7 @@ jobs:
packages-for-linux:
needs: [is-release-tag]
name: Build single-file fish for Linux (experimental)
name: Build single-file fish for Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -80,7 +83,8 @@ jobs:
with:
targets: x86_64-unknown-linux-musl,aarch64-unknown-linux-musl
- name: Install dependencies
run: sudo apt install crossbuild-essential-arm64 gettext musl-tools python3-sphinx
run: sudo apt install crossbuild-essential-arm64 gettext musl-tools
- uses: ./.github/actions/install-sphinx
- name: Build statically-linked executables
run: |
set -x
@@ -143,15 +147,12 @@ jobs:
# Workaround for https://github.com/actions/checkout/issues/882
ref: ${{ inputs.version }}
- name: Install Rust
uses: ./.github/actions/rust-toolchain@oldest-supported
with:
targets: x86_64-apple-darwin
- name: Install Rust Stable
uses: ./.github/actions/rust-toolchain@stable
with:
targets: aarch64-apple-darwin
targets: aarch64-apple-darwin,x86_64-apple-darwin
- name: Install dependencies
run: brew install gettext
- uses: ./.github/actions/install-sphinx
- name: Build and codesign
run: |
die() { echo >&2 "$*"; exit 1; }
@@ -171,7 +172,7 @@ jobs:
echo "$MACOS_NOTARIZE_JSON" >/tmp/notarize.json
./build_tools/make_macos_pkg.sh -s -f /tmp/app.p12 \
-i /tmp/installer.p12 -p "$MAC_CODESIGN_PASSWORD" \
-n -j /tmp/notarize.json
-n -j /tmp/notarize.json -- -c "-DWITH_DOCS=ON"
version=$(git describe)
[ -f "${FISH_ARTEFACT_PATH}/fish-$version.app.zip" ]
[ -f "${FISH_ARTEFACT_PATH}/fish-$version.pkg" ]

View File

@@ -1,4 +1,4 @@
name: make fish_run_tests
name: Test
on: [push, pull_request]
@@ -11,18 +11,17 @@ permissions:
jobs:
ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/rust-toolchain@oldest-supported
- name: Install deps
uses: ./.github/actions/install-dependencies
with:
include_sphinx: true
- name: Generate a locale that uses a comma as decimal separator.
run: |
sudo apt install gettext libpcre2-dev python3-pexpect python3-sphinx tmux
# Generate a locale that uses a comma as decimal separator.
sudo locale-gen fr_FR.UTF-8
- uses: ./.github/actions/install-sphinx-markdown-builder
- name: cmake
run: |
mkdir build && cd build
@@ -43,18 +42,20 @@ jobs:
git --no-pager diff --exit-code || { echo 'There are uncommitted changes after regenerating the gettext PO files. Make sure to update them via `build_tools/update_translations.fish` after changing source files.'; exit 1; }
ubuntu-32bit-static-pcre2:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/rust-toolchain@oldest-supported
with:
targets: "i586-unknown-linux-gnu" # rust-toolchain wants this comma-separated
targets: "i586-unknown-linux-gnu"
- name: Install deps
uses: ./.github/actions/install-dependencies
with:
include_pcre: false
include_sphinx: false
- name: Install g++-multilib
run: |
sudo apt update
sudo apt install gettext python3-pexpect g++-multilib tmux
sudo apt install g++-multilib
- name: cmake
env:
CFLAGS: "-m32"
@@ -69,7 +70,6 @@ jobs:
make -C build VERBOSE=1 fish_run_tests
ubuntu-asan:
runs-on: ubuntu-latest
env:
# Rust has two different memory sanitizers of interest; they can't be used at the same time:
@@ -79,7 +79,6 @@ jobs:
#
RUSTFLAGS: "-Zsanitizer=address"
# RUSTFLAGS: "-Zsanitizer=memory -Zsanitizer-memory-track-origins"
steps:
- uses: actions/checkout@v4
# All -Z options require running nightly
@@ -89,8 +88,11 @@ jobs:
# this is comma-separated
components: rust-src
- name: Install deps
uses: ./.github/actions/install-dependencies
with:
include_sphinx: false
- name: Install llvm
run: |
sudo apt install gettext libpcre2-dev python3-pexpect tmux
sudo apt install llvm # for llvm-symbolizer
- name: cmake
env:
@@ -119,38 +121,8 @@ jobs:
export LSAN_OPTIONS="$LSAN_OPTIONS:suppressions=$PWD/build_tools/lsan_suppressions.txt"
make -C build VERBOSE=1 fish_run_tests
# Our clang++ tsan builds are not recognizing safe rust patterns (such as the fact that Drop
# cannot be called while a thread is using the object in question). Rust has its own way of
# running TSAN, but for the duration of the port from C++ to Rust, we'll keep this disabled.
# ubuntu-threadsan:
#
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v4
# - uses: ./.github/actions/rust-toolchain@oldest-supported
# - name: Install deps
# run: |
# sudo apt install gettext libpcre2-dev python3-pexpect tmux
# - name: cmake
# env:
# FISH_CI_SAN: 1
# CC: clang
# run: |
# mkdir build && cd build
# cmake ..
# - name: make
# run: |
# make
# - name: make fish_run_tests
# run: |
# make -C build fish_run_tests
macos:
runs-on: macos-latest
env:
# macOS runners keep having issues loading Cargo.toml dependencies from git (GitHub) instead
# of crates.io, so give this a try. It's also sometimes significantly faster on all platforms.
@@ -164,13 +136,41 @@ jobs:
# this is CI so we don't actually care.
sudo pip3 install --break-system-packages pexpect
brew install gettext tmux
- uses: ./.github/actions/install-sphinx
- name: cmake
run: |
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
FISH_TEST_MAX_CONCURRENCY=1 \
cmake -DCMAKE_BUILD_TYPE=Debug ..
- name: make
run: |
make -C build VERBOSE=1
- name: make fish_run_tests
run: |
make -C build VERBOSE=1 fish_run_tests
windows:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v4
- uses: msys2/setup-msys2@v2
with:
update: true
msystem: MSYS
- name: Install deps
# Not using setup-msys2 `install` option to make it easier to copy/paste
run: |
pacman --noconfirm -S --needed git rust
- name: cargo build
run: |
cargo build
- name: smoketest
# We can't run `build_tools/check.sh` yet, there are just too many failures
# so this is just a quick check to make sure that fish can swim
run: |
set -x
[ "$(target/debug/fish.exe -c 'echo (math 1 + 1)')" = 2 ]
cargo test

4
.gitignore vendored
View File

@@ -7,7 +7,6 @@
*.DS_Store
*.a
*.app
*.d
*.dll
*.dylib
*.exe
@@ -105,3 +104,6 @@ target/
# JetBrains editors.
.idea/
# AI slop
.claude/

1
.rustfmt.toml Normal file
View File

@@ -0,0 +1 @@
edition = "2024"

View File

@@ -1,8 +1,170 @@
fish ?.?.? (released ???)
=========================
fish 4.3.1 (released December 28, 2025)
=======================================
fish 4.1.1 (released ???)
=========================
This release fixes the following problem identified in 4.3.0:
- Possible crash after expanding an abbreviation (:issue:`12223`).
fish 4.3.0 (released December 28, 2025)
=======================================
Deprecations and removed features
---------------------------------
- fish no longer sets :ref:`universal variables <variables-universal>` by default, making the configuration easier to understand.
Specifically, the ``fish_color_*``, ``fish_pager_color_*`` and ``fish_key_bindings`` variables are now set in the global scope by default.
After upgrading to 4.3.0, fish will (once and never again) migrate these universals to globals set at startup in the
``~/.config/fish/conf.d/fish_frozen_theme.fish`` and
``~/.config/fish/conf.d/fish_frozen_key_bindings.fish`` files.
We suggest that you delete those files and :ref:`set your theme <syntax-highlighting>` in ``~/.config/fish/config.fish``.
- You can still configure fish to propagate theme changes instantly; see :ref:`here <syntax-highlighting-instant-update>` for an example.
- You can still opt into storing color variables in the universal scope
via ``fish_config theme save`` though unlike ``fish_config theme choose``,
it does not support dynamic theme switching based on the terminal's color theme (see below).
- In addition to setting the variables which are explicitly defined in the given theme,
``fish_config theme choose`` now clears only color variables that were set by earlier invocations of a ``fish_config theme choose`` command
(which is how fish's default theme is set).
Scripting improvements
----------------------
- New :ref:`status language <status-language>` command allows showing and modifying language settings for fish messages without having to modify environment variables.
- When using a noninteractive fish instance to compute completions, ``commandline --cursor`` works as expected instead of throwing an error (:issue:`11993`).
- :envvar:`fish_trace` can now be set to ``all`` to also trace execution of key bindings, event handlers as well as prompt and title functions.
Interactive improvements
------------------------
- When typing immediately after starting fish, the first prompt is now rendered correctly.
- Completion accuracy was improved for file paths containing ``=`` or ``:`` (:issue:`5363`).
- Prefix-matching completions are now shown even if they don't match the case typed by the user (:issue:`7944`).
- On Cygwin/MSYS, command name completion will favor the non-exe name (``foo``) unless the user started typing the extension.
- When using the exe name (``foo.exe``), fish will use to the description and completions for ``foo`` if there are none for ``foo.exe``.
- Autosuggestions now also show soft-wrapped portions (:issue:`12045`).
New or improved bindings
------------------------
- :kbd:`ctrl-w` (``backward-kill-path-component``) also deletes escaped spaces (:issue:`2016`).
- New special input functions ``backward-path-component``, ``forward-path-component`` and ``kill-path-component`` (:issue:`12127`).
Improved terminal support
-------------------------
- Themes can now be made color-theme-aware by including both ``[light]`` and ``[dark]`` sections in the :ref:`theme file <fish-config-theme-files>`.
Some default themes have been made color-theme-aware, meaning they dynamically adjust as your terminal's background color switches between light and dark colors (:issue:`11580`).
- The working directory is now reported on every fresh prompt (via OSC 7), fixing scenarios where a child process (like ``ssh``) left behind a stale working directory (:issue:`12191`).
- OSC 133 prompt markers now also mark the prompt end, which improves shell integration with terminals like iTerm2 (:issue:`11837`).
- Operating-system-specific key bindings are now decided based on the :ref:`terminal's host OS <status-terminal-os>`.
- Focus reporting is enabled unconditionally, not just inside tmux.
To use it, define functions that handle the ``fish_focus_in`` or ``fish_focus_out`` :ref:`events <event>`.
- New :ref:`feature flag <featureflags>` ``omit-term-workarounds`` can be turned on to prevent fish from trying to work around some incompatible terminals.
For distributors and developers
-------------------------------
- Tarballs no longer contain prebuilt documentation,
so building and installing documentation requires Sphinx.
To avoid users accidentally losing docs, the ``BUILD_DOCS`` and ``INSTALL_DOCS`` configuration options have been replaced with a new ``WITH_DOCS`` option.
- ``fish_key_reader`` and ``fish_indent`` are now installed as hardlinks to ``fish``, to save some space.
Regression fixes:
-----------------
- (from 4.1.0) Crash on incorrectly-set color variables (:issue:`12078`).
- (from 4.1.0) Crash when autosuggesting Unicode characters with nontrivial lowercase mapping.
- (from 4.2.0) Incorrect emoji width computation on macOS.
- (from 4.2.0) Mouse clicks and :kbd:`ctrl-l` edge cases in multiline command lines (:issue:`12121`).
- (from 4.2.0) Completions for Git remote names on some non-glibc systems.
- (from 4.2.0) Expansion of ``~$USER``.
fish 4.2.1 (released November 13, 2025)
=======================================
This release fixes the following problems identified in 4.2.0:
- When building from a tarball without Sphinx (that is, with ``-DBUILD_DOCS=OFF`` or when ``sphinx-build`` is not found),
builtin man pages and help files were missing, which has been fixed (:issue:`12052`).
- ``fish_config``'s theme selector (the "colors" tab) was broken, which has been fixed (:issue:`12053`).
fish 4.2.0 (released November 10, 2025)
=======================================
Notable improvements and fixes
------------------------------
- History-based autosuggestions now include multi-line commands.
- A :ref:`transient prompt <transient-prompt>` containing more lines than the final prompt will now be cleared properly (:issue:`11875`).
- Taiwanese Chinese translations have been added.
- French translations have been supplemented (:issue:`11842`).
Deprecations and removed features
---------------------------------
- fish now assumes UTF-8 for character encoding even if the system does not have a UTF-8 locale.
Input bytes which are not valid UTF-8 are still round-tripped correctly.
For example, file paths using legacy encodings can still be used,
but may be rendered differently on the command line.
- On systems where no multi-byte locale is available,
fish will no longer fall back to using ASCII replacements for :ref:`Unicode characters <term-compat-unicode-codepoints>` such as "…".
Interactive improvements
------------------------
- The title of the terminal tab can now be set separately from the window title by defining the :doc:`fish_tab_title <cmds/fish_tab_title>` function (:issue:`2692`).
- fish now hides the portion of a multiline prompt that is scrolled out of view due to a huge command line. This prevents duplicate lines after repainting with partially visible prompt (:issue:`11911`).
- :doc:`fish_config prompt <cmds/fish_config>`'s ``choose`` and ``save`` subcommands have been taught to reset :doc:`fish_mode_prompt <cmds/fish_mode_prompt>` in addition to the other prompt functions (:issue:`11937`).
- fish no longer force-disables mouse capture (DECSET/DECRST 1000),
so you can use those commands
to let mouse clicks move the cursor or select completions items (:issue:`4918`).
- The :kbd:`alt-p` binding no longer adds a redundant space to the command line.
- When run as a login shell on macOS, fish now sets :envvar:`MANPATH` correctly when that variable was already present in the environment (:issue:`10684`).
- A Windows-specific case of the :doc:`web-based config <cmds/fish_config>` failing to launch has been fixed (:issue:`11805`).
- A MSYS2-specific workaround for Konsole and WezTerm has been added,
to prevent them from using the wrong working directory when opening new tabs (:issue:`11981`).
For distributors and developers
-------------------------------
- Release tags and source code tarballs are GPG-signed again (:issue:`11996`).
- Documentation in release tarballs is now built with the latest version of Sphinx,
which means that pre-built man pages include :ref:`OSC 8 hyperlinks <term-compat-osc-8>`.
- The Sphinx dependency is now specified in ``pyproject.toml``,
which allows you to use `uv <https://github.com/astral-sh/uv>`__ to provide Sphinx for building documentation (e.g. ``uv run cargo install --path .``).
- The minimum supported Rust version (MSRV) has been updated to 1.85.
- The standalone build mode has been made the default.
This means that the files in ``$CMAKE_INSTALL_PREFIX/share/fish`` will not be used anymore, except for HTML docs.
As a result, future upgrades will no longer break running shells
if one of fish's internal helper functions has been changed in the updated version.
For now, the data files are still installed redundantly,
to prevent upgrades from breaking already-running shells (:issue:`11921`).
To reverse this change (which should not be necessary),
patch out the ``embed-data`` feature from ``cmake/Rust.cmake``.
This option will be removed in future.
- OpenBSD 7.8 revealed an issue with fish's approach for displaying builtin man pages, which has been fixed.
Regression fixes:
-----------------
- (from 4.1.0) Fix the :doc:`web-based config <cmds/fish_config>` for Python 3.9 and older (:issue:`12039`).
- (from 4.1.0) Correct wrong terminal modes set by ``fish -c 'read; cat`` (:issue:`12024`).
- (from 4.1.0) On VTE-based terminals, stop redrawing the prompt on resize again, to avoid glitches.
- (from 4.1.0) On MSYS2, fix saving/loading of universal variables (:issue:`11948`).
- (from 4.1.0) Fix error using ``man`` for the commands ``!`` ``.`` ``:`` ``[`` ``{`` (:issue:`11955`).
- (from 4.1.0) Fix build issues on illumos systems (:issue:`11982`).
- (from 4.1.0) Fix crash on invalid :doc:`function <cmds/function>` command (:issue:`11912`).
- (from 4.0.0) Fix build on SPARC and MIPS Linux by disabling ``SIGSTKFLT``.
- (from 4.0.0) Fix crash when passing negative PIDs to builtin :doc:`wait <cmds/wait>` (:issue:`11929`).
- (from 4.0.0) On Linux, fix :doc:`status fish-path <cmds/status>` output when fish has been reinstalled since it was started.
fish 4.1.2 (released October 7, 2025)
=====================================
This release fixes the following regressions identified in 4.1.0:
- Fixed spurious error output when completing remote file paths for ``scp`` (:issue:`11860`).
- Fixed the :kbd:`alt-l` binding not formatting ``ls`` output correctly (one entry per line, no colors) (:issue:`11888`).
- Fixed an issue where focus events (currently only enabled in ``tmux``) would cause multiline prompts to be redrawn in the wrong line (:issue:`11870`).
- Stopped printing output that would cause a glitch on old versions of Midnight Commander (:issue:`11869`).
- Added a fix for some configurations of Zellij where :kbd:`escape` key processing was delayed (:issue:`11868`).
- Fixed a case where the :doc:`web-based configuration tool <cmds/fish_config>` would generate invalid configuration (:issue:`11861`).
- Fixed a case where pasting into ``fish -c read`` would fail with a noisy error (:issue:`11836`).
- Fixed a case where upgrading fish would break old versions of fish that were still running.
In general, fish still needs to be restarted after it is upgraded,
except for `standalone builds <https://github.com/fish-shell/fish-shell/?tab=readme-ov-file#building-fish-with-embedded-data-experimental>`__.
fish 4.1.1 (released September 30, 2025)
========================================
This release fixes the following regressions identified in 4.1.0:
@@ -14,7 +176,7 @@ This release fixes the following regressions identified in 4.1.0:
This will not affect fish's child processes unless ``LC_MESSAGES`` was already exported.
- Some :doc:`fish_config <cmds/fish_config>` subcommands for showing prompts and themes had been broken in standalone Linux builds (those using the ``embed-data`` cargo feature), which has been fixed (:issue:`11832`).
- On Windows Terminal, we observed an issue where fish would fail to read the terminal's response to our new startup queries, causing noticeable lags and a misleading error message. A workaround has been added (:issue:`11841`).
- On Windows Terminal, we observed an issue where fish would fail to read the terminal's response to our new startup queries, causing noticeable lags and a misleading error message. A workaround has been added (:issue:`11841`).
- A WezTerm `issue breaking shifted key input <https://github.com/wezterm/wezterm/issues/6087>`__ has resurfaced on some versions of WezTerm; our workaround has been extended to cover all versions for now (:issue:`11204`).
- Fixed a crash in :doc:`the web-based configuration tool <cmds/fish_config>` when using the new underline styles (:issue:`11840`).
@@ -844,7 +1006,7 @@ Notable improvements and fixes
which expands ``!!`` to the last history item, anywhere on the command line, mimicking other shells' history expansion.
See :ref:`the documentation <cmd-abbr>` for more.
See :doc:`the documentation <cmds/abbr>` for more.
- ``path`` gained a new ``mtime`` subcommand to print the modification time stamp for files. For example, this can be used to handle cache file ages (:issue:`9057`)::
> touch foo
@@ -1269,7 +1431,7 @@ Scripting improvements
two
'blue '
- ``$fish_user_paths`` is now automatically deduplicated to fix a common user error of appending to it in config.fish when it is universal (:issue:`8117`). :ref:`fish_add_path <cmd-fish_add_path>` remains the recommended way to add to $PATH.
- ``$fish_user_paths`` is now automatically deduplicated to fix a common user error of appending to it in config.fish when it is universal (:issue:`8117`). :doc:`fish_add_path <cmds/fish_add_path>` remains the recommended way to add to $PATH.
- ``return`` can now be used outside functions. In scripts, it does the same thing as ``exit``. In interactive mode,it sets ``$status`` without exiting (:issue:`8148`).
- An oversight prevented all syntax checks from running on commands given to ``fish -c`` (:issue:`8171`). This includes checks such as ``exec`` not being allowed in a pipeline, and ``$$`` not being a valid variable. Generally, another error was generated anyway.
- ``fish_indent`` now correctly reformats tokens that end with a backslash followed by a newline (:issue:`8197`).

View File

@@ -28,6 +28,23 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
# This defines the FBVF variable.
include(Version)
# Set up the docs.
include(cmake/Docs.cmake)
# Tell Cargo where our build directory is so it can find Cargo.toml.
set(VARS_FOR_CARGO
"FISH_CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}"
"PREFIX=${CMAKE_INSTALL_PREFIX}"
"DOCDIR=${CMAKE_INSTALL_FULL_DOCDIR}"
"DATADIR=${CMAKE_INSTALL_FULL_DATADIR}"
"SYSCONFDIR=${CMAKE_INSTALL_FULL_SYSCONFDIR}"
"BINDIR=${CMAKE_INSTALL_FULL_BINDIR}"
"CARGO_TARGET_DIR=${FISH_RUST_BUILD_DIR}"
"CARGO_BUILD_RUSTC=${Rust_COMPILER}"
"${FISH_PCRE2_BUILDFLAG}"
"FISH_SPHINX=${SPHINX_EXECUTABLE}"
)
# Let fish pick up when we're running out of the build directory without installing
get_filename_component(REAL_CMAKE_BINARY_DIR "${CMAKE_BINARY_DIR}" REALPATH)
get_filename_component(REAL_CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}" REALPATH)
@@ -39,40 +56,40 @@ if(NOT "${CMAKE_BUILD_TYPE}" IN_LIST build_types)
message(WARNING "Unsupported build type ${CMAKE_BUILD_TYPE}. If this doesn't build, try one of Release, RelWithDebInfo or Debug")
endif()
# Define a function to build and link dependencies.
function(CREATE_TARGET target)
add_custom_target(
fish ALL
COMMAND
"${CMAKE_COMMAND}" -E
env ${VARS_FOR_CARGO}
${Rust_CARGO}
build --bin fish
$<$<CONFIG:Release>:--release>
$<$<CONFIG:RelWithDebInfo>:--profile=release-with-debug>
--target ${Rust_CARGO_TARGET}
--no-default-features
--features=${FISH_CARGO_FEATURES}
${CARGO_FLAGS}
&&
"${CMAKE_COMMAND}" -E
copy "${rust_target_dir}/${rust_profile}/fish" "${CMAKE_CURRENT_BINARY_DIR}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
USES_TERMINAL
)
function(CREATE_LINK target)
add_custom_target(
${target} ALL
COMMAND
"${CMAKE_COMMAND}" -E
env ${VARS_FOR_CARGO}
${Rust_CARGO}
build --bin ${target}
$<$<CONFIG:Release>:--release>
$<$<CONFIG:RelWithDebInfo>:--profile=release-with-debug>
--target ${Rust_CARGO_TARGET}
--no-default-features
--features=${FISH_CARGO_FEATURES}
${CARGO_FLAGS}
&&
"${CMAKE_COMMAND}" -E
copy "${rust_target_dir}/${rust_profile}/${target}" "${CMAKE_CURRENT_BINARY_DIR}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
USES_TERMINAL
DEPENDS fish
COMMAND ln -f fish ${target}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
endfunction(CREATE_TARGET)
# Define fish.
create_target(fish)
endfunction(CREATE_LINK)
# Define fish_indent.
create_target(fish_indent)
create_link(fish_indent)
# Define fish_key_reader.
create_target(fish_key_reader)
# Set up the docs.
include(cmake/Docs.cmake)
create_link(fish_key_reader)
# Set up tests.
include(cmake/Tests.cmake)

View File

@@ -21,10 +21,10 @@ Archives are available at https://lists.sr.ht/~krobelus/fish-shell/.
GitHub
======
Fish is available on Github, at https://github.com/fish-shell/fish-shell.
Fish is available on GitHub, at https://github.com/fish-shell/fish-shell.
First, you'll need an account there, and you'll need a git clone of fish.
Fork it on Github and then run::
Fork it on GitHub and then run::
git clone https://github.com/<USERNAME>/fish-shell.git
@@ -52,6 +52,23 @@ In short:
- Be conservative in what you need (keep to the agreed minimum supported Rust version, limit new dependencies)
- Use automated tools to help you (``build_tools/check.sh``)
Commit History
==============
We use a linear, `recipe-style <https://www.bitsnbites.eu/git-history-work-log-vs-recipe/>`__ history.
Every commit should pass our checks.
We do not want "fixup" commits in our history.
If you notice an issue with a commit in a pull request, or get feedback suggesting changes,
you should rewrite the commit history and fix the relevant commits directly,
instead of adding new "fixup" commits.
When a pull request is ready, we rebase it on top of the current master branch,
so don't be shy about rewriting the history of commits which are not on master yet.
Rebasing (not merging) your pull request on the latest version of master is also welcome, especially if it resolves conflicts.
If you're using Git, consider using `jj <https://www.jj-vcs.dev/>`__ to make this easier.
If a commit should close an issue, add a ``Fixes #<issue-number>`` line at the end of the commit description.
Contributing completions
========================
@@ -71,7 +88,7 @@ Completion scripts should
1. Use as few dependencies as possible - try to use fish's builtins like ``string`` instead of ``grep`` and ``awk``,
use ``python`` to read json instead of ``jq`` (because it's already a soft dependency for fish's tools)
2. If it uses a common unix tool, use posix-compatible invocations - ideally it would work on GNU/Linux, macOS, the BSDs and other systems
2. If it uses a common unix tool, use POSIX-compatible invocations - ideally it would work on GNU/Linux, macOS, the BSDs and other systems
3. Option and argument descriptions should be kept short.
The shorter the description, the more likely it is that fish can use more columns.
4. Function names should start with ``__fish``, and functions should be kept in the completion file unless they're used elsewhere.
@@ -89,44 +106,36 @@ Contributing documentation
The documentation is stored in ``doc_src/``, and written in ReStructured Text and built with Sphinx.
To build it locally, run from the main fish-shell directory::
To build it locally, run either::
sphinx-build -j 8 -b html -n doc_src/ /tmp/fish-doc/
sphinx-build -j auto -b html doc_src/ /tmp/fish-doc/
which will build the docs as html in /tmp/fish-doc. You can open it in a browser and see that it looks okay.
which will output HTML docs to /tmp/fish-doc.
You can open it in a browser and see that it looks okay.
Alternatively, you can use::
cmake --build build -t sphinx-docs
which outputs to build/user_doc/html/.
The builtins and various functions shipped with fish are documented in doc_src/cmds/.
Code Style
==========
To ensure your changes conform to the style rules run
::
build_tools/style.fish
before committing your change. That will run our autoformatters:
For formatting, we use:
- ``rustfmt`` for Rust
- ``fish_indent`` (shipped with fish) for fish script
- ``black`` for python
- ``ruff format`` for Python
If youve already committed your changes thats okay since it will then
check the files in the most recent commit. This can be useful after
youve merged another persons change and want to check that its style
is acceptable. However, in that case it will run ``clang-format`` to
ensure the entire file, not just the lines modified by the commit,
conform to the style.
If you want to check the style of the entire code base run
To reformat files, there is a script
::
build_tools/style.fish --all
That command will refuse to restyle any files if you have uncommitted
changes.
build_tools/style.fish somefile.rs some.fish
Fish Script Style Guide
-----------------------
@@ -178,10 +187,10 @@ made to run fish_indent via e.g.
(add-hook 'fish-mode-hook (lambda ()
(add-hook 'before-save-hook 'fish_indent-before-save)))
Rust Style Guide
----------------
Minimum Supported Rust Version (MSRV) Policy
--------------------------------------------
Use ``cargo fmt`` and ``cargo clippy``. Clippy warnings can be turned off if there's a good reason to.
We support at least the version of ``rustc`` available in Debian Stable.
Testing
=======
@@ -190,84 +199,53 @@ The source code for fish includes a large collection of tests. If you
are making any changes to fish, running these tests is a good way to make
sure the behaviour remains consistent and regressions are not
introduced. Even if you dont run the tests on your machine, they will
still be run via Github Actions.
still be run via GitHub Actions.
You are strongly encouraged to add tests when changing the functionality
of fish, especially if you are fixing a bug to help ensure there are no
regressions in the future (i.e., we dont reintroduce the bug).
The tests can be found in three places:
Unit tests live next to the implementation in Rust source files, in inline submodules (``mod tests {}``).
- src/tests for unit tests.
- tests/checks for script tests, run by `littlecheck <https://github.com/ridiculousfish/littlecheck>`__
- tests/pexpects for interactive tests using `pexpect <https://pexpect.readthedocs.io/en/stable/>`__
System tests live in ``tests/``:
When in doubt, the bulk of the tests should be added as a littlecheck test in tests/checks, as they are the easiest to modify and run, and much faster and more dependable than pexpect tests. The syntax is fairly self-explanatory. It's a fish script with the expected output in ``# CHECK:`` or ``# CHECKERR:`` (for stderr) comments.
If your littlecheck test has a specific dependency, use ``# REQUIRE: ...`` with a posix sh script.
- ``tests/checks`` are run by `littlecheck <https://github.com/ridiculousfish/littlecheck>`__
and test noninteractive (script) behavior,
except for ``tests/checks/tmux-*`` which test interactive scenarios.
- ``tests/pexpects`` tests interactive scenarios using `pexpect <https://pexpect.readthedocs.io/en/stable/>`__
The pexpects are written in python and can simulate input and output to/from a terminal, so they are needed for anything that needs actual interactivity. The runner is in tests/pexpect_helper.py, in case you need to modify something there.
When in doubt, the bulk of the tests should be added as a littlecheck test in tests/checks, as they are the easiest to modify and run, and much faster and more dependable than pexpect tests.
The syntax is fairly self-explanatory.
It's a fish script with the expected output in ``# CHECK:`` or ``# CHECKERR:`` (for stderr) comments.
If your littlecheck test has a specific dependency, use ``# REQUIRE: ...`` with a POSIX sh script.
These tests can be run via the tests/test_driver.py python script, which will set up the environment.
The pexpect tests are written in Python and can simulate input and output to/from a terminal, so they are needed for anything that needs actual interactivity.
The runner is in tests/pexpect_helper.py, in case you need to modify something there.
These tests can be run via the tests/test_driver.py Python script, which will set up the environment.
It sets up a temporary $HOME and also uses it as the current directory, so you do not need to create a temporary directory in them.
If you need a command to do something weird to test something, maybe add it to the ``fish_test_helper`` binary (in tests/fish_test_helper.c), or see if it can already do it.
If you need a command to do something weird to test something, maybe add it to the ``fish_test_helper`` binary (in ``tests/fish_test_helper.c``).
Local testing
-------------
The tests can be run on your local computer on all operating systems.
The tests can be run on your local system::
::
cmake path/to/fish-shell
make fish_run_tests
Or you can run them on a fish, without involving cmake::
cargo build
cargo test # for the unit tests
tests/test_driver.py target/debug # for the script and interactive tests
cargo build
# Run unit tests
cargo test
# Run system tests
tests/test_driver.py target/debug
# Run a specific system test.
tests/test_driver.py target/debug tests/checks/abbr.fish
Here, the first argument to test_driver.py refers to a directory with ``fish``, ``fish_indent`` and ``fish_key_reader`` in it.
In this example we're in the root of the git repo and have run ``cargo build`` without ``--release``, so it's a debug build.
In this example we're in the root of the workspace and have run ``cargo build`` without ``--release``, so it's a debug build.
Git hooks
---------
To run all tests and linters, use::
Since developers sometimes forget to run the tests, it can be helpful to
use git hooks (see githooks(5)) to automate it.
One possibility is a pre-push hook script like this one:
.. code:: sh
#!/bin/sh
#### A pre-push hook for the fish-shell project
# This will run the tests when a push to master is detected, and will stop that if the tests fail
# Save this as .git/hooks/pre-push and make it executable
protected_branch='master'
# Git gives us lines like "refs/heads/frombranch SOMESHA1 refs/heads/tobranch SOMESHA1"
# We're only interested in the branches
isprotected=false
while read from _ to _; do
if [ "$to" = "refs/heads/$protected_branch" ]; then
isprotected=true
fi
done
if "$isprotected"; then
echo "Running checks before push to master"
build_tools/check.sh
fi
This will check if the push is to the master branch and, if it is, only
allow the push if running ``build_tools/check.sh`` succeeds. In some circumstances
it may be advisable to circumvent this check with
``git push --no-verify``, but usually that isnt necessary.
To install the hook, place the code in a new file
``.git/hooks/pre-push`` and make it executable.
build_tools/check.sh
Contributing Translations
=========================
@@ -279,9 +257,8 @@ It also means that some features are not supported, such as message context and
We also expect all files to be UTF-8-encoded.
In practice, this should not matter much for contributing translations.
Translation sources are
stored in the ``po`` directory, named ``ll_CC.po``, where ``ll`` is the
two (or possibly three) letter ISO 639-1 language code of the target language
Translation sources are stored in the ``localization/po`` directory and named ``ll_CC.po``,
where ``ll`` is the two (or possibly three) letter ISO 639-1 language code of the target language
(e.g. ``pt`` for Portuguese). ``CC`` is an ISO 3166 country/territory code,
(e.g. ``BR`` for Brazil).
An example for a valid name is ``pt_BR.po``, indicating Brazilian Portuguese.
@@ -295,7 +272,7 @@ More specifically, you will need ``msguniq`` and ``msgmerge`` for creating trans
language.
To create a new translation, run::
build_tools/update_translations.fish po/ll_CC.po
build_tools/update_translations.fish localization/po/ll_CC.po
This will create a new PO file containing all messages available for translation.
If the file already exists, it will be updated.
@@ -341,9 +318,9 @@ Editing PO files
Many tools are available for editing translation files, including
command-line and graphical user interface programs. For simple use, you can use your text editor.
Open up the PO file, for example ``po/sv.po``, and you'll see something like::
Open up the PO file, for example ``localization/po/sv.po``, and you'll see something like::
msgid "%ls: No suitable job\n"
msgid "%s: No suitable job\n"
msgstr ""
The ``msgid`` here is the "name" of the string to translate, typically the English string to translate.
@@ -351,10 +328,10 @@ The second line (``msgstr``) is where your translation goes.
For example::
msgid "%ls: No suitable job\n"
msgstr "%ls: Inget passande jobb\n"
msgid "%s: No suitable job\n"
msgstr "%s: Inget passande jobb\n"
Any ``%s`` / ``%ls`` or ``%d`` are placeholders that fish will use for formatting at runtime. It is important that they match - the translated string should have the same placeholders in the same order.
Any ``%s`` or ``%d`` are placeholders that fish will use for formatting at runtime. It is important that they match - the translated string should have the same placeholders in the same order.
Also any escaped characters, like that ``\n`` newline at the end, should be kept so the translation has the same behavior.
@@ -369,7 +346,7 @@ Modifications to strings in source files
If a string changes in the sources, the old translations will no longer work.
They will be preserved in the PO files, but commented-out (starting with ``#~``).
If you add/remove/change a translatable strings in a source file,
run ``build_tools/update_translations.fish`` to propagate this to all translation files (``po/*.po``).
run ``build_tools/update_translations.fish`` to propagate this to all translation files (``localization/po/*.po``).
This is only relevant for developers modifying the source files of fish or fish scripts.
Setting Code Up For Translations
@@ -381,7 +358,7 @@ macros:
::
streams.out.append(wgettext_fmt!("%ls: There are no jobs\n", argv[0]));
streams.out.append(wgettext_fmt!("%s: There are no jobs\n", argv[0]));
All messages in fish script must be enclosed in single or double quote
characters for our message extraction script to find them.
@@ -404,6 +381,12 @@ You can use either single or double quotes to enclose the
message to be translated. You can also optionally include spaces after
the opening parentheses or before the closing parentheses.
Updating Dependencies
=====================
To update dependencies, run ``build_tools/update-dependencies.sh``.
This currently requires `updatecli <https://github.com/updatecli/updatecli>`__ and a few other tools.
Versioning
==========

597
Cargo.lock generated
View File

@@ -1,6 +1,15 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4
[[package]]
name = "aho-corasick"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
[[package]]
name = "allocator-api2"
@@ -10,15 +19,15 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
[[package]]
name = "autocfg"
version = "1.4.0"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
[[package]]
name = "bitflags"
version = "2.6.0"
version = "2.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
[[package]]
name = "block-buffer"
@@ -30,11 +39,22 @@ dependencies = [
]
[[package]]
name = "cc"
version = "1.2.7"
name = "bstr"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a012a0df96dd6d06ba9a1b29d6402d1a5d77c6befd2566afdc26e10603dc93d7"
checksum = "234113d19d0d7d613b40e86fb654acf958910802bcceab913a4f9e7cda03b1a4"
dependencies = [
"memchr",
"serde",
]
[[package]]
name = "cc"
version = "1.2.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac9fe6cdbb24b6ade63616c0a0688e45bb56732262c158df3c0c4bea4ca47cb7"
dependencies = [
"find-msvc-tools",
"jobserver",
"libc",
"shlex",
@@ -42,9 +62,9 @@ dependencies = [
[[package]]
name = "cfg-if"
version = "1.0.0"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
[[package]]
name = "cfg_aliases"
@@ -54,9 +74,9 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
[[package]]
name = "cpufeatures"
version = "0.2.16"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3"
checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
dependencies = [
"libc",
]
@@ -82,16 +102,37 @@ dependencies = [
]
[[package]]
name = "equivalent"
version = "1.0.1"
name = "dirs"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"
dependencies = [
"dirs-sys",
]
[[package]]
name = "dirs-sys"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
dependencies = [
"libc",
"option-ext",
"redox_users",
"windows-sys",
]
[[package]]
name = "equivalent"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "errno"
version = "0.3.11"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
"windows-sys",
@@ -103,35 +144,48 @@ version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
[[package]]
name = "find-msvc-tools"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127"
[[package]]
name = "fish"
version = "4.1.0-snapshot"
version = "4.3.1"
dependencies = [
"bitflags",
"cc",
"cfg-if",
"errno",
"fish-build-helper",
"fish-build-man-pages",
"fish-common",
"fish-fallback",
"fish-gettext",
"fish-gettext-extraction",
"fish-gettext-maps",
"fish-gettext-mo-file-parser",
"fish-printf",
"fish-tempfile",
"fish-wchar",
"fish-widecharwidth",
"libc",
"lru",
"macro_rules_attribute",
"nix",
"num-traits",
"once_cell",
"pcre2",
"phf 0.12.1",
"phf_codegen 0.12.1",
"portable-atomic",
"rand",
"rand 0.9.2",
"rsconf",
"rust-embed",
"serial_test",
"terminfo",
"unix_path",
"widestring",
"xterm-color",
]
[[package]]
@@ -149,11 +203,45 @@ dependencies = [
"rsconf",
]
[[package]]
name = "fish-common"
version = "0.0.0"
dependencies = [
"libc",
"nix",
"once_cell",
]
[[package]]
name = "fish-fallback"
version = "0.0.0"
dependencies = [
"fish-build-helper",
"fish-common",
"fish-wchar",
"fish-widecharwidth",
"libc",
"once_cell",
"rsconf",
"widestring",
]
[[package]]
name = "fish-gettext"
version = "0.0.0"
dependencies = [
"fish-gettext-maps",
"once_cell",
"phf 0.12.1",
]
[[package]]
name = "fish-gettext-extraction"
version = "0.0.0"
dependencies = [
"fish-tempfile",
"proc-macro2",
"rsconf",
]
[[package]]
@@ -181,6 +269,26 @@ dependencies = [
"widestring",
]
[[package]]
name = "fish-tempfile"
version = "0.0.0"
dependencies = [
"nix",
"rand 0.9.2",
]
[[package]]
name = "fish-wchar"
version = "0.0.0"
dependencies = [
"fish-common",
"widestring",
]
[[package]]
name = "fish-widecharwidth"
version = "0.0.0"
[[package]]
name = "fnv"
version = "1.0.7"
@@ -189,25 +297,61 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "foldhash"
version = "0.1.4"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]]
name = "generic-array"
version = "0.14.7"
version = "0.14.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2"
dependencies = [
"typenum",
"version_check",
]
[[package]]
name = "hashbrown"
version = "0.15.2"
name = "getrandom"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
dependencies = [
"cfg-if",
"libc",
"wasi",
]
[[package]]
name = "getrandom"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
dependencies = [
"cfg-if",
"libc",
"r-efi",
"wasip2",
]
[[package]]
name = "globset"
version = "0.4.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54a1028dfc5f5df5da8a56a73e6c153c9a9708ec57232470703592a3f18e49f5"
dependencies = [
"aho-corasick",
"bstr",
"log",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "hashbrown"
version = "0.15.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
dependencies = [
"allocator-api2",
"equivalent",
@@ -216,34 +360,44 @@ dependencies = [
[[package]]
name = "jobserver"
version = "0.1.32"
version = "0.1.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0"
checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33"
dependencies = [
"getrandom 0.3.4",
"libc",
]
[[package]]
name = "libc"
version = "0.2.172"
version = "0.2.177"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976"
[[package]]
name = "libredox"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb"
dependencies = [
"bitflags",
"libc",
]
[[package]]
name = "lock_api"
version = "0.4.12"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
dependencies = [
"autocfg",
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.22"
version = "0.4.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
[[package]]
name = "lru"
@@ -255,10 +409,26 @@ dependencies = [
]
[[package]]
name = "memchr"
version = "2.7.4"
name = "macro_rules_attribute"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
checksum = "65049d7923698040cd0b1ddcced9b0eb14dd22c5f86ae59c3740eab64a676520"
dependencies = [
"macro_rules_attribute-proc_macro",
"paste",
]
[[package]]
name = "macro_rules_attribute-proc_macro"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "670fdfda89751bc4a84ac13eaa63e205cf0fd22b4c9a5fbfa085b63c1f1d3a30"
[[package]]
name = "memchr"
version = "2.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
[[package]]
name = "minimal-lexical"
@@ -299,15 +469,21 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.20.2"
version = "1.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
[[package]]
name = "option-ext"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
[[package]]
name = "parking_lot"
version = "0.12.3"
version = "0.12.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a"
dependencies = [
"lock_api",
"parking_lot_core",
@@ -315,17 +491,23 @@ dependencies = [
[[package]]
name = "parking_lot_core"
version = "0.9.10"
version = "0.9.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-targets",
"windows-link",
]
[[package]]
name = "paste"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]]
name = "pcre2"
version = "0.2.9"
@@ -391,7 +573,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d"
dependencies = [
"phf_shared 0.11.3",
"rand",
"rand 0.8.5",
]
[[package]]
@@ -424,41 +606,76 @@ dependencies = [
[[package]]
name = "pkg-config"
version = "0.3.31"
version = "0.3.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
[[package]]
name = "portable-atomic"
version = "1.10.0"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6"
checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483"
[[package]]
name = "ppv-lite86"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
dependencies = [
"zerocopy",
]
[[package]]
name = "proc-macro2"
version = "1.0.95"
version = "1.0.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.40"
version = "1.0.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1"
dependencies = [
"proc-macro2",
]
[[package]]
name = "r-efi"
version = "5.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
[[package]]
name = "rand"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"rand_core",
"rand_core 0.6.4",
]
[[package]]
name = "rand"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
dependencies = [
"rand_chacha",
"rand_core 0.9.3",
]
[[package]]
name = "rand_chacha"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
dependencies = [
"ppv-lite86",
"rand_core 0.9.3",
]
[[package]]
@@ -468,14 +685,51 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
[[package]]
name = "redox_syscall"
version = "0.5.8"
name = "rand_core"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834"
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
dependencies = [
"getrandom 0.3.4",
]
[[package]]
name = "redox_syscall"
version = "0.5.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
dependencies = [
"bitflags",
]
[[package]]
name = "redox_users"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac"
dependencies = [
"getrandom 0.2.16",
"libredox",
"thiserror",
]
[[package]]
name = "regex-automata"
version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
[[package]]
name = "rsconf"
version = "0.2.2"
@@ -487,9 +741,9 @@ dependencies = [
[[package]]
name = "rust-embed"
version = "8.7.2"
version = "8.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "025908b8682a26ba8d12f6f2d66b987584a4a87bc024abc5bbc12553a8cd178a"
checksum = "947d7f3fad52b283d261c4c99a084937e2fe492248cb9a68a8435a861b8798ca"
dependencies = [
"rust-embed-impl",
"rust-embed-utils",
@@ -498,23 +752,25 @@ dependencies = [
[[package]]
name = "rust-embed-impl"
version = "8.7.2"
version = "8.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6065f1a4392b71819ec1ea1df1120673418bf386f50de1d6f54204d836d4349c"
checksum = "5fa2c8c9e8711e10f9c4fd2d64317ef13feaab820a4c51541f1a8c8e2e851ab2"
dependencies = [
"proc-macro2",
"quote",
"rust-embed-utils",
"shellexpand",
"syn",
"walkdir",
]
[[package]]
name = "rust-embed-utils"
version = "8.7.2"
version = "8.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6cc0c81648b20b70c491ff8cce00c1c3b223bb8ed2b5d41f0e54c6c4c0a3594"
checksum = "60b161f275cb337fe0a44d924a5f4df0ed69c2c39519858f931ce61c779d3475"
dependencies = [
"globset",
"sha2",
"walkdir",
]
@@ -530,9 +786,9 @@ dependencies = [
[[package]]
name = "scc"
version = "2.3.0"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28e1c91382686d21b5ac7959341fcb9780fa7c03773646995a87c950fa7be640"
checksum = "46e6f046b7fef48e2660c57ed794263155d713de679057f2d0c169bfc6e756cc"
dependencies = [
"sdd",
]
@@ -545,9 +801,38 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "sdd"
version = "3.0.5"
version = "3.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "478f121bb72bbf63c52c93011ea1791dca40140dfe13f8336c4c5ac952c33aa9"
checksum = "490dcfcbfef26be6800d11870ff2df8774fa6e86d047e3e8c8a76b25655e41ca"
[[package]]
name = "serde"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
dependencies = [
"serde_core",
]
[[package]]
name = "serde_core"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serial_test"
@@ -574,15 +859,24 @@ dependencies = [
[[package]]
name = "sha2"
version = "0.10.8"
version = "0.10.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
]
[[package]]
name = "shellexpand"
version = "3.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b1fdf65dd6331831494dd616b30351c38e96e45921a27745cf98490458b90bb"
dependencies = [
"dirs",
]
[[package]]
name = "shlex"
version = "1.3.0"
@@ -597,15 +891,15 @@ checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d"
[[package]]
name = "smallvec"
version = "1.13.2"
version = "1.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
[[package]]
name = "syn"
version = "2.0.95"
version = "2.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46f71c0377baf4ef1cc3e3402ded576dccc315800fbc62dfc7fe04b009773b4a"
checksum = "2a26dbd934e5451d21ef060c018dae56fc073894c5a7896f882928a76e6d081b"
dependencies = [
"proc-macro2",
"quote",
@@ -625,16 +919,36 @@ dependencies = [
]
[[package]]
name = "typenum"
version = "1.17.0"
name = "thiserror"
version = "2.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "2.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "typenum"
version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb"
[[package]]
name = "unicode-ident"
version = "1.0.14"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
checksum = "462eeb75aeb73aea900253ce739c8e18a67423fadf006037cd3ff27e82748a06"
[[package]]
name = "unicode-segmentation"
@@ -644,9 +958,9 @@ checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
[[package]]
name = "unicode-width"
version = "0.2.0"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"
[[package]]
name = "unix_path"
@@ -680,89 +994,78 @@ dependencies = [
]
[[package]]
name = "widestring"
version = "1.2.0"
name = "wasi"
version = "0.11.1+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd7cf3379ca1aac9eea11fba24fd7e315d621f8dfe35c8d7d2be8b793726e07d"
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
[[package]]
name = "wasip2"
version = "1.0.1+wasi-0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7"
dependencies = [
"wit-bindgen",
]
[[package]]
name = "widestring"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72069c3113ab32ab29e5584db3c6ec55d416895e60715417b5b883a357c3e471"
[[package]]
name = "winapi-util"
version = "0.1.9"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
"windows-sys",
]
[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-sys"
version = "0.59.0"
version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
dependencies = [
"windows-targets",
"windows-link",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
name = "wit-bindgen"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
[[package]]
name = "xterm-color"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4de5f056fb9dc8b7908754867544e26145767187aaac5a98495e88ad7cb8a80f"
[[package]]
name = "zerocopy"
version = "0.8.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
"zerocopy-derive",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
name = "zerocopy-derive"
version = "0.8.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831"
dependencies = [
"proc-macro2",
"quote",
"syn",
]

View File

@@ -1,24 +1,33 @@
[workspace]
resolver = "2"
members = ["crates/*"]
[workspace.package]
# To build revisions that use Corrosion (those before 2024-01), use CMake 3.19, Rustc 1.78 and Rustup 1.27.
rust-version = "1.70"
edition = "2021"
rust-version = "1.85"
edition = "2024"
repository = "https://github.com/fish-shell/fish-shell"
# see doc_src/license.rst for details
# don't forget to update COPYING and debian/copyright too
license = "GPL-2.0-only AND LGPL-2.0-or-later AND MIT AND PSF-2.0"
[workspace.dependencies]
bitflags = "2.5.0"
cc = "1.0.94"
cfg-if = "1.0.3"
errno = "0.3.0"
fish-build-helper = { path = "crates/build-helper" }
fish-build-man-pages = { path = "crates/build-man-pages" }
fish-common = { path = "crates/common" }
fish-fallback = { path = "crates/fallback" }
fish-gettext = { path = "crates/gettext" }
fish-gettext-extraction = { path = "crates/gettext-extraction" }
fish-gettext-maps = { path = "crates/gettext-maps" }
fish-gettext-mo-file-parser = { path = "crates/gettext-mo-file-parser" }
fish-printf = { path = "crates/printf", features = ["widestring"] }
libc = "0.2.155"
fish-tempfile = { path = "crates/tempfile" }
fish-wchar = { path = "crates/wchar" }
fish-widecharwidth = { path = "crates/widecharwidth" }
libc = "0.2.177"
# lru pulls in hashbrown by default, which uses a faster (though less DoS resistant) hashing algo.
# disabling default features uses the stdlib instead, but it doubles the time to rewrite the history
# files as of 22 April 2024.
@@ -28,6 +37,7 @@ nix = { version = "0.30.1", default-features = false, features = [
"inotify",
"resource",
"fs",
"term",
] }
num-traits = "0.2.19"
once_cell = "1.19.0"
@@ -40,12 +50,16 @@ portable-atomic = { version = "1", default-features = false, features = [
"fallback",
] }
proc-macro2 = "1.0"
# Don't use the "getrandom" feature as it requires "getentropy" which was not
# available on macOS < 10.12. We can enable "getrandom" when we raise the
# minimum supported version to 10.12.
rand = { version = "0.8.5", default-features = false, features = ["small_rng"] }
rand = { version = "0.9.2", default-features = false, features = [
"small_rng",
"thread_rng",
] }
rsconf = "0.2.2"
rust-embed = { version = "8.7.2", features = ["deterministic-timestamps"] }
rust-embed = { version = "8.9.0", features = [
"deterministic-timestamps",
"include-exclude",
"interpolate-folder-path",
] }
serial_test = { version = "3", default-features = false }
# We need 0.9.0 specifically for some crash fixes.
terminfo = "0.9.0"
@@ -53,6 +67,7 @@ widestring = "1.2.0"
unicode-segmentation = "1.12.0"
unicode-width = "0.2.0"
unix_path = "1.0.1"
xterm-color = "1.0.1"
[profile.release]
overflow-checks = true
@@ -64,42 +79,56 @@ debug = true
[package]
name = "fish"
version = "4.1.0-snapshot"
version = "4.3.1"
edition.workspace = true
rust-version.workspace = true
default-run = "fish"
# see doc_src/license.rst for details
# don't forget to update COPYING and debian/copyright too
license = "GPL-2.0-only AND LGPL-2.0-or-later AND MIT AND PSF-2.0"
license.workspace = true
homepage = "https://fishshell.com"
readme = "README.rst"
[dependencies]
bitflags.workspace = true
cfg-if.workspace = true
errno.workspace = true
fish-build-helper.workspace = true
fish-build-man-pages = { workspace = true, optional = true }
fish-common.workspace = true
fish-fallback.workspace = true
fish-gettext = { workspace = true, optional = true }
fish-gettext-extraction = { workspace = true, optional = true }
fish-gettext-maps = { workspace = true, optional = true }
fish-printf.workspace = true
fish-tempfile.workspace = true
fish-wchar.workspace = true
fish-widecharwidth.workspace = true
libc.workspace = true
lru.workspace = true
macro_rules_attribute = "0.2.2"
nix.workspace = true
num-traits.workspace = true
once_cell.workspace = true
pcre2.workspace = true
phf = { workspace = true, optional = true }
rand.workspace = true
terminfo.workspace = true
xterm-color.workspace = true
widestring.workspace = true
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]
portable-atomic.workspace = true
[target.'cfg(windows)'.dependencies]
rust-embed = { workspace = true, optional = true, features = ["deterministic-timestamps", "debug-embed"] }
rust-embed = { workspace = true, features = [
"deterministic-timestamps",
"debug-embed",
"include-exclude",
"interpolate-folder-path",
] }
[target.'cfg(not(windows))'.dependencies]
rust-embed = { workspace = true, optional = true, features = ["deterministic-timestamps"] }
rust-embed = { workspace = true, features = [
"deterministic-timestamps",
"include-exclude",
"interpolate-folder-path",
] }
[dev-dependencies]
serial_test.workspace = true
@@ -131,12 +160,12 @@ name = "fish_key_reader"
path = "src/bin/fish_key_reader.rs"
[features]
default = ["embed-data", "localize-messages"]
default = ["embed-manpages", "localize-messages"]
benchmark = []
embed-data = ["dep:rust-embed", "dep:fish-build-man-pages"]
embed-manpages = ["dep:fish-build-man-pages"]
# Enable gettext localization at runtime. Requires the `msgfmt` tool to generate catalog data at
# build time.
localize-messages = ["dep:phf", "dep:fish-gettext-maps"]
localize-messages = ["dep:fish-gettext"]
# This feature is used to enable extracting messages from the source code for localization.
# It only needs to be enabled if updating these messages (and the corresponding PO files) is
# desired. This happens when running tests via `build_tools/check.sh` and when calling
@@ -152,9 +181,14 @@ rust.non_camel_case_types = "allow"
rust.non_upper_case_globals = "allow"
rust.unknown_lints = "allow"
rust.unstable_name_collisions = "allow"
rustdoc.private_intra_doc_links = "allow"
clippy.len_without_is_empty = "allow" # we're not a library crate
clippy.let_and_return = "allow"
clippy.manual_range_contains = "allow"
clippy.needless_return = "allow"
clippy.map_unwrap_or = "warn"
clippy.needless_lifetimes = "allow"
clippy.new_without_default = "allow"
clippy.option_map_unit_fn = "allow"
# We do not want to use the e?print(ln)?! macros.
# These lints flag their use.

View File

@@ -37,7 +37,7 @@ fish can be installed:
- using the `installer from fishshell.com <https://fishshell.com/>`__
- as a `standalone app from fishshell.com <https://fishshell.com/>`__
Note: The minimum supported macOS version is 10.10 "Yosemite".
Note: The minimum supported macOS version is 10.12.
Packages for Linux
~~~~~~~~~~~~~~~~~~
@@ -90,7 +90,7 @@ Running fish requires:
- some common \*nix system utilities (currently ``mktemp``), in
addition to the basic POSIX utilities (``cat``, ``cut``, ``dirname``,
``file``, ``ls``, ``mkdir``, ``mkfifo``, ``rm``, ``sh``, ``sort``, ``tee``, ``tr``,
``ls``, ``mkdir``, ``mkfifo``, ``rm``, ``sh``, ``sort``, ``tee``, ``tr``,
``uname`` and ``sed`` at least, but the full coreutils plus ``find`` and
``awk`` is preferred)
@@ -100,6 +100,7 @@ The following optional features also have specific requirements:
messages require ``man`` for display
- automated completion generation from manual pages requires Python 3.5+
- the ``fish_config`` web configuration tool requires Python 3.5+ and a web browser
- the :ref:`alt-o <shared-binds-alt-o>` binding requires the ``file`` program.
- system clipboard integration (with the default Ctrl-V and Ctrl-X
bindings) require either the ``xsel``, ``xclip``,
``wl-copy``/``wl-paste`` or ``pbcopy``/``pbpaste`` utilities
@@ -111,14 +112,12 @@ The following optional features also have specific requirements:
Building
--------
.. _dependencies-1:
Dependencies
~~~~~~~~~~~~
Compiling fish requires:
- Rust (version 1.70 or later)
- Rust (version 1.85 or later)
- CMake (version 3.15 or later)
- a C compiler (for system feature detection and the test helper binary)
- PCRE2 (headers and libraries) - optional, this will be downloaded if missing
@@ -128,7 +127,7 @@ Compiling fish requires:
Sphinx is also optionally required to build the documentation from a
cloned git repository.
Additionally, running the full test suite requires Python 3.5+, tmux, and the pexpect package.
Additionally, running the full test suite requires diff, git, Python 3.5+, pexpect, less, tmux and wget.
Building from source with CMake
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -140,7 +139,7 @@ links above, and up-to-date `development builds of fish are available for many p
To install into ``/usr/local``, run:
.. code:: bash
.. code:: shell
mkdir build; cd build
cmake ..
@@ -158,41 +157,47 @@ In addition to the normal CMake build options (like ``CMAKE_INSTALL_PREFIX``), f
- Rust_COMPILER=path - the path to rustc. If not set, cmake will check $PATH and ~/.cargo/bin
- Rust_CARGO=path - the path to cargo. If not set, cmake will check $PATH and ~/.cargo/bin
- Rust_CARGO_TARGET=target - the target to pass to cargo. Set this for cross-compilation.
- BUILD_DOCS=ON|OFF - whether to build the documentation. This is automatically set to OFF when Sphinx isn't installed.
- INSTALL_DOCS=ON|OFF - whether to install the docs. This is automatically set to on when BUILD_DOCS is or prebuilt documentation is available (like when building in-tree from a tarball).
- WITH_DOCS=ON|OFF - whether to build the documentation. By default, this is ON when Sphinx is installed.
- FISH_USE_SYSTEM_PCRE2=ON|OFF - whether to use an installed pcre2. This is normally autodetected.
- MAC_CODESIGN_ID=String|OFF - the codesign ID to use on Mac, or "OFF" to disable codesigning.
- WITH_GETTEXT=ON|OFF - whether to include translations.
- extra_functionsdir, extra_completionsdir and extra_confdir - to compile in an additional directory to be searched for functions, completions and configuration snippets
Building fish with embedded data (experimental)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Building fish with Cargo
~~~~~~~~~~~~~~~~~~~~~~~~
You can also build fish with the data files embedded.
You can also build fish with Cargo.
This example uses `uv <https://github.com/astral-sh/uv>`__ to install Sphinx (which is used for man-pages and ``--help`` options).
You can also install Sphinx another way and drop the ``uv run --no-managed-python`` prefix.
This will include all the datafiles like the included functions or web configuration tool in the main ``fish`` binary.
.. code:: shell
Fish will then read these right from its own binary, and print them out when needed. Some files, like the webconfig tool and the manpage completion generator, will be extracted to a temporary directory on-demand. You can list the files with ``status list-files`` and print one with ``status get-file path/to/file`` (e.g. ``status get-file functions/fish_prompt.fish`` to get the default prompt).
git clone https://github.com/fish-shell/fish-shell
cd fish-shell
To install fish with embedded files, just use ``cargo``, like::
# Optional: check out a specific version rather than building the latest
# development version.
git checkout "$(git for-each-ref refs/tags/ | awk '$2 == "tag" { print $3 }' | tail -1)"
cargo install --path /path/to/fish # if you have a git clone
cargo install --git https://github.com/fish-shell/fish-shell --tag "$(curl -s https://api.github.com/repos/fish-shell/fish-shell/releases/latest | jq -r .tag_name)" # to build the latest release
cargo install --git https://github.com/fish-shell/fish-shell # to build the latest development snapshot
uv run --no-managed-python \
cargo install --path .
This will place the standalone binaries in ``~/.cargo/bin/``, but you can place them wherever you want.
This will place standalone binaries in ``~/.cargo/bin/``, but you can move them wherever you want.
This build won't have the HTML docs (``help`` will open the online version).
It will try to build the man pages with sphinx-build. If that is not available and you would like to include man pages, you need to install it and retrigger the build script, e.g. by setting FISH_BUILD_DOCS=1::
FISH_BUILD_DOCS=1 cargo install --path .
Setting it to "0" disables the inclusion of man pages.
To disable translations, disable the ``localize-messages`` feature by passing ``--no-default-features --features=embed-data`` to cargo.
To disable translations, disable the ``localize-messages`` feature by passing ``--no-default-features --features=embed-manpages`` to cargo.
You can also link this build statically (but not against glibc) and move it to other computers.
Here are the remaining advantages of a full installation, as currently done by CMake:
- Man pages like ``fish(1)`` installed in standard locations, easily accessible from outside fish.
- Separate files for builtins (e.g. ``$PREFIX/share/fish/man/man1/abbr.1``).
- A local copy of the HTML documentation, typically accessed via the ``help`` fish function.
In Cargo builds, ``help`` will redirect to `<https://fishshell.com/docs/current/>`__
- Ability to use our CMake options extra_functionsdir, extra_completionsdir and extra_confdir,
(also recorded in ``$PREFIX/share/pkgconfig/fish.pc``)
which are used by some package managers to house third-party completions.
Regardless of build system, fish uses ``$XDG_DATA_DIRS/{vendor_completion.d,vendor_conf.d,vendor_functions.d}``.
Contributing Changes to the Code
--------------------------------

219
build.rs
View File

@@ -1,6 +1,7 @@
#![allow(clippy::uninlined_format_args)]
use fish_build_helper::{fish_build_dir, workspace_root};
use fish_build_helper::{
env_var, fish_build_dir, target_os, target_os_is_apple, target_os_is_bsd, target_os_is_cygwin,
workspace_root,
};
use rsconf::Target;
use std::env;
use std::path::{Path, PathBuf};
@@ -16,7 +17,7 @@ fn main() {
// language server.
rsconf::set_env_value(
"FISH_BUILD_DIR",
"FISH_RESOLVED_BUILD_DIR",
// If set by CMake, this might include symlinks. Since we want to compare this to the
// dir fish is executed in we need to canonicalize it.
canonicalize(fish_build_dir()).to_str().unwrap(),
@@ -30,28 +31,19 @@ fn main() {
);
// Some build info
rsconf::set_env_value("BUILD_TARGET_TRIPLE", &env::var("TARGET").unwrap());
rsconf::set_env_value("BUILD_HOST_TRIPLE", &env::var("HOST").unwrap());
rsconf::set_env_value("BUILD_PROFILE", &env::var("PROFILE").unwrap());
rsconf::set_env_value("BUILD_TARGET_TRIPLE", &env_var("TARGET").unwrap());
rsconf::set_env_value("BUILD_HOST_TRIPLE", &env_var("HOST").unwrap());
rsconf::set_env_value("BUILD_PROFILE", &env_var("PROFILE").unwrap());
let version = &get_version(&env::current_dir().unwrap());
// Per https://doc.rust-lang.org/cargo/reference/build-scripts.html#inputs-to-the-build-script,
// the source directory is the current working directory of the build script
rsconf::set_env_value("FISH_BUILD_VERSION", version);
std::env::set_var("FISH_BUILD_VERSION", version);
// safety: single-threaded code.
unsafe { std::env::set_var("FISH_BUILD_VERSION", version) };
// These are necessary if built with embedded functions,
// but only in release builds (because rust-embed in debug builds reads from the filesystem).
#[cfg(feature = "embed-data")]
#[cfg(any(windows, not(debug_assertions)))]
rsconf::rebuild_if_path_changed("share");
#[cfg(feature = "gettext-extract")]
rsconf::rebuild_if_env_changed("FISH_GETTEXT_EXTRACTION_FILE");
rsconf::rebuild_if_path_changed("src/libc.c");
cc::Build::new().file("src/libc.c").compile("flibc.a");
fish_build_helper::rebuild_if_embedded_path_changed("share");
let build = cc::Build::new();
let mut target = Target::new_from(build).unwrap();
@@ -60,7 +52,9 @@ fn main() {
detect_cfgs(&mut target);
#[cfg(all(target_env = "gnu", target_feature = "crt-static"))]
compile_error!("Statically linking against glibc has unavoidable crashes and is unsupported. Use dynamic linking or link statically against musl.");
compile_error!(
"Statically linking against glibc has unavoidable crashes and is unsupported. Use dynamic linking or link statically against musl."
);
}
/// Check target system support for certain functionality dynamically when the build is invoked,
@@ -75,35 +69,41 @@ fn main() {
/// `Cargo.toml`) behind a feature we just enabled.
///
/// [0]: https://github.com/rust-lang/cargo/issues/5499
#[rustfmt::skip]
fn detect_cfgs(target: &mut Target) {
for (name, handler) in [
// Ignore the first entry, it just sets up the type inference. Model new entries after the
// second line.
// Ignore the first entry, it just sets up the type inference.
("", &(|_: &Target| false) as &dyn Fn(&Target) -> bool),
("apple", &detect_apple),
("bsd", &detect_bsd),
("cygwin", &detect_cygwin),
("small_main_stack", &has_small_stack),
// See if libc supports the thread-safe localeconv_l(3) alternative to localeconv(3).
("localeconv_l", &|target| {
target.has_symbol("localeconv_l")
}),
("FISH_USE_POSIX_SPAWN", &|target| {
target.has_header("spawn.h")
}),
("HAVE_PIPE2", &|target| {
target.has_symbol("pipe2")
}),
("HAVE_EVENTFD", &|target| {
("apple", &(|_| target_os_is_apple())),
("bsd", &(|_| target_os_is_bsd())),
("cygwin", &(|_| target_os_is_cygwin())),
("have_eventfd", &|target| {
// FIXME: NetBSD 10 has eventfd, but the libc crate does not expose it.
if cfg!(target_os = "netbsd") {
false
} else {
target.has_header("sys/eventfd.h")
if target_os() == "netbsd" {
false
} else {
target.has_header("sys/eventfd.h")
}
}),
("HAVE_WAITSTATUS_SIGNAL_RET", &|target| {
("have_localeconv_l", &|target| {
target.has_symbol("localeconv_l")
}),
("have_pipe2", &|target| target.has_symbol("pipe2")),
("have_posix_spawn", &|target| {
if matches!(target_os().as_str(), "openbsd" | "android") {
// OpenBSD's posix_spawn returns status 127 instead of erroring with ENOEXEC when faced with a
// shebang-less script. Disable posix_spawn on OpenBSD.
//
// Android is broken for unclear reasons
false
} else {
target.has_header("spawn.h")
}
}),
("small_main_stack", &has_small_stack),
("using_cmake", &|_| {
option_env!("FISH_CMAKE_BINARY_DIR").is_some()
}),
("waitstatus_signal_ret", &|target| {
target.r#if("WEXITSTATUS(0x007f) == 0x7f", &["sys/wait.h"])
}),
] {
@@ -111,40 +111,6 @@ fn detect_cfgs(target: &mut Target) {
}
}
fn detect_apple(_: &Target) -> bool {
cfg!(any(target_os = "ios", target_os = "macos"))
}
fn detect_cygwin(_: &Target) -> bool {
// Cygwin target is usually cross-compiled.
std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "cygwin"
}
/// Detect if we're being compiled for a BSD-derived OS, allowing targeting code conditionally with
/// `#[cfg(bsd)]`.
///
/// Rust offers fine-grained conditional compilation per-os for the popular operating systems, but
/// doesn't necessarily include less-popular forks nor does it group them into families more
/// specific than "windows" vs "unix" so we can conditionally compile code for BSD systems.
fn detect_bsd(_: &Target) -> bool {
// Instead of using `uname`, we can inspect the TARGET env variable set by Cargo. This lets us
// support cross-compilation scenarios.
let mut target = std::env::var("TARGET").unwrap();
if !target.chars().all(|c| c.is_ascii_lowercase()) {
target = target.to_ascii_lowercase();
}
#[allow(clippy::let_and_return)] // for old clippy
let is_bsd = target.ends_with("bsd") || target.ends_with("dragonfly");
#[cfg(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
))]
assert!(is_bsd, "Target incorrectly detected as not BSD!");
is_bsd
}
/// Rust sets the stack size of newly created threads to a sane value, but is at at the mercy of the
/// OS when it comes to the size of the main stack. Some platforms we support default to a tiny
/// 0.5 MiB main stack, which is insufficient for fish's MAX_EVAL_DEPTH/MAX_STACK_DEPTH values.
@@ -163,19 +129,16 @@ fn has_small_stack(_: &Target) -> bool {
{
use core::ffi;
extern "C" {
fn pthread_get_stacksize_np(thread: *const ffi::c_void) -> usize;
fn pthread_self() -> *const ffi::c_void;
unsafe extern "C" {
unsafe fn pthread_get_stacksize_np(thread: *const ffi::c_void) -> usize;
unsafe fn pthread_self() -> *const ffi::c_void;
}
// build.rs is executed on the main thread, so we are getting the main thread's stack size.
// Modern macOS versions default to an 8 MiB main stack but legacy OS X have a 0.5 MiB one.
let stack_size = unsafe { pthread_get_stacksize_np(pthread_self()) };
const TWO_MIB: usize = 2 * 1024 * 1024 - 1;
match stack_size {
0..=TWO_MIB => true,
_ => false,
}
stack_size <= TWO_MIB
}
}
@@ -183,59 +146,63 @@ fn setup_paths() {
#[cfg(windows)]
use unix_path::{Path, PathBuf};
fn get_path(name: &str, default: &str, onvar: &Path) -> PathBuf {
let mut var = PathBuf::from(env::var(name).unwrap_or(default.to_string()));
if var.is_relative() {
var = onvar.join(var);
fn overridable_path(
env_var_name: &str,
f: impl FnOnce(Option<String>) -> Option<PathBuf>,
) -> Option<PathBuf> {
rsconf::rebuild_if_env_changed(env_var_name);
let maybe_path = f(env_var(env_var_name));
if let Some(path) = maybe_path.as_ref() {
rsconf::set_env_value(env_var_name, path.to_str().unwrap());
}
var
maybe_path
}
let prefix = PathBuf::from(env::var("PREFIX").unwrap_or("/usr/local".to_string()));
rsconf::rebuild_if_env_changed("PREFIX");
rsconf::set_env_value("PREFIX", prefix.to_str().unwrap());
let datadir = get_path("DATADIR", "share/", &prefix);
let sysconfdir = get_path(
"SYSCONFDIR",
// Embedded builds use "/etc," not "./share/etc".
if cfg!(feature = "embed-data") {
"/etc/"
fn join_if_relative(parent_if_relative: &Path, path: String) -> PathBuf {
let path = PathBuf::from(path);
if path.is_relative() {
parent_if_relative.join(path)
} else {
"etc/"
},
&datadir,
);
rsconf::set_env_value("SYSCONFDIR", sysconfdir.to_str().unwrap());
rsconf::rebuild_if_env_changed("SYSCONFDIR");
#[cfg(not(feature = "embed-data"))]
{
rsconf::set_env_value("DATADIR", datadir.to_str().unwrap());
rsconf::rebuild_if_env_changed("DATADIR");
let bindir = get_path("BINDIR", "bin/", &prefix);
rsconf::set_env_value("BINDIR", bindir.to_str().unwrap());
rsconf::rebuild_if_env_changed("BINDIR");
let localedir = get_path("LOCALEDIR", "locale/", &datadir);
let localedir = localedir.to_str().unwrap();
assert!(!localedir.is_empty(), "empty LOCALEDIR is not supported");
rsconf::set_env_value("LOCALEDIR", localedir);
rsconf::rebuild_if_env_changed("LOCALEDIR");
let docdir = get_path("DOCDIR", "doc/fish", &datadir);
rsconf::set_env_value("DOCDIR", docdir.to_str().unwrap());
rsconf::rebuild_if_env_changed("DOCDIR");
path
}
}
let prefix = overridable_path("PREFIX", |env_prefix| {
Some(PathBuf::from(
env_prefix.unwrap_or("/usr/local".to_string()),
))
})
.unwrap();
overridable_path("SYSCONFDIR", |env_sysconfdir| {
Some(join_if_relative(
&prefix,
env_sysconfdir.unwrap_or("/etc/".to_string()),
))
});
let datadir = overridable_path("DATADIR", |env_datadir| {
env_datadir.map(|p| join_if_relative(&prefix, p))
});
overridable_path("BINDIR", |env_bindir| {
env_bindir.map(|p| join_if_relative(&prefix, p))
});
overridable_path("DOCDIR", |env_docdir| {
env_docdir.map(|p| {
join_if_relative(
&datadir
.expect("Setting DOCDIR without setting DATADIR is not currently supported"),
p,
)
})
});
}
fn get_version(src_dir: &Path) -> String {
use std::fs::read_to_string;
use std::process::Command;
if let Ok(var) = std::env::var("FISH_BUILD_VERSION") {
if let Some(var) = env_var("FISH_BUILD_VERSION") {
return var;
}

View File

@@ -8,6 +8,22 @@ if [ "$FISH_CHECK_LINT" = false ]; then
lint=false
fi
check_dependency_versions=false
if [ "${FISH_CHECK_DEPENDENCY_VERSIONS:-false}" != false ]; then
check_dependency_versions=true
fi
if $check_dependency_versions; then
command -v curl
command -v jq
command -v rustup
command -v uv
sort --version-sort </dev/null
# To match existing behavior, only check Rust/dockerfiles for now.
# TODO: remove this from this script.
updatecli diff --config=updatecli.d/docker.yml --config=updatecli.d/rust.yml
fi
cargo_args=$FISH_CHECK_CARGO_ARGS
target_triple=$FISH_CHECK_TARGET_TRIPLE
if [ -n "$target_triple" ]; then
@@ -22,8 +38,8 @@ cargo() {
}
cleanup () {
if [ -n "$template_file" ] && [ -e "$template_file" ]; then
rm "$template_file"
if [ -n "$gettext_template_dir" ] && [ -e "$gettext_template_dir" ]; then
rm -r "$gettext_template_dir"
fi
}
@@ -43,9 +59,20 @@ fi
# Currently, all builds are debug builds.
build_dir="$target_dir/debug"
template_file=$(mktemp)
FISH_GETTEXT_EXTRACTION_FILE=$template_file cargo build --workspace --all-targets --features=gettext-extract
if [ -n "$FISH_TEST_MAX_CONCURRENCY" ]; then
export RUST_TEST_THREADS="$FISH_TEST_MAX_CONCURRENCY"
export CARGO_BUILD_JOBS="$FISH_TEST_MAX_CONCURRENCY"
fi
gettext_template_dir=$(mktemp -d)
(
export FISH_GETTEXT_EXTRACTION_DIR="$gettext_template_dir"
cargo build --workspace --all-targets --features=gettext-extract
)
if $lint; then
if command -v cargo-deny >/dev/null; then
cargo deny --all-features --locked --exclude-dev check licenses
fi
PATH="$build_dir:$PATH" "$workspace_root/build_tools/style.fish" --all --check
for features in "" --no-default-features; do
cargo clippy --workspace --all-targets $features
@@ -54,9 +81,9 @@ fi
cargo test --no-default-features --workspace --all-targets
cargo test --doc --workspace
if $lint; then
cargo doc --workspace
cargo doc --workspace --no-deps
fi
FISH_GETTEXT_EXTRACTION_FILE=$template_file "$workspace_root/tests/test_driver.py" "$build_dir"
FISH_GETTEXT_EXTRACTION_DIR=$gettext_template_dir "$workspace_root/tests/test_driver.py" "$build_dir"
exit
}

View File

@@ -1,23 +0,0 @@
#!/usr/bin/env fish
# Build a list of all sections in the html sphinx docs, separately by page,
# so it can be added to share/functions/help.fish
# Use like
# fish extract_help_sections.fish user_doc/html/{fish_for_bash_users.html,faq.html,interactive.html,language.html,tutorial.html}
# TODO: Currently `help` uses variable names we can't generate, so it needs to be touched up manually.
# Also this could easily be broken by changes in sphinx, ideally we'd have a way to let it print the section titles.
#
for file in $argv
set -l varname (string replace -r '.*/(.*).html' '$1' -- $file | string escape --style=var)pages
# Technically we can use any id in the document as an anchor, but listing them all is probably too much.
# Sphinx stores section titles (in a slug-ized form) in the id,
# and stores explicit section links in a `span` tag like
# `<span id="identifiers"></span>`
# We extract both separately.
set -l sections (string replace -rf '.*class="headerlink" href="#([^"]*)".*' '$1' <$file)
# Sections titled "id5" and such are internal cruft and shouldn't be offered.
set -a sections (string replace -rf '.*span id="([^"]*)".*' '$1' <$file | string match -rv 'id\d+')
set sections (printf '%s\n' $sections | sort -u)
echo set -l $varname $sections
end

View File

@@ -21,13 +21,13 @@ begin
set -g workspace_root (path resolve (status dirname)/..)
set -l rust_extraction_file
set -l rust_extraction_dir
if set -l --query _flag_use_existing_template
set rust_extraction_file $_flag_use_existing_template
set rust_extraction_dir $_flag_use_existing_template
else
set rust_extraction_file (mktemp)
set rust_extraction_dir (mktemp -d)
# We need to build to ensure that the proc macro for extracting strings runs.
FISH_GETTEXT_EXTRACTION_FILE=$rust_extraction_file cargo check --no-default-features --features=gettext-extract
FISH_GETTEXT_EXTRACTION_DIR=$rust_extraction_dir cargo check --features=gettext-extract
or exit 1
end
@@ -41,11 +41,11 @@ begin
mark_section tier1-from-rust
# Get rid of duplicates and sort.
msguniq --no-wrap --strict --sort-output $rust_extraction_file
find $rust_extraction_dir -type f -exec cat {} + | msguniq --no-wrap --sort-output
or exit 1
if not set -l --query _flag_use_existing_template
rm $rust_extraction_file
rm -r $rust_extraction_dir
end
function extract_fish_script_messages_impl

View File

@@ -24,16 +24,12 @@ SIGN=
NOTARIZE=
ARM64_DEPLOY_TARGET='MACOSX_DEPLOYMENT_TARGET=11.0'
X86_64_DEPLOY_TARGET='MACOSX_DEPLOYMENT_TARGET=10.9'
X86_64_DEPLOY_TARGET='MACOSX_DEPLOYMENT_TARGET=10.12'
cmake_args=
# As of this writing, the most recent Rust release supports macOS back to 10.12.
# The first supported version of macOS on arm64 is 10.15, so any Rust is fine for arm64.
# We wish to support back to 10.9 on x86-64; the last version of Rust to support that is
# version 1.73.0.
RUST_VERSION_X86_64=1.70.0
while getopts "sf:i:p:e:nj:" opt; do
while getopts "c:sf:i:p:e:nj:" opt; do
case $opt in
c) cmake_args+=("$OPTARG");;
s) SIGN=1;;
f) P12_APP_FILE=$(realpath "$OPTARG");;
i) P12_INSTALL_FILE=$(realpath "$OPTARG");;
@@ -65,34 +61,30 @@ OUTPUT_PATH=${FISH_ARTEFACT_PATH:-~/fish_built}
mkdir -p "$PKGDIR/build_x86_64" "$PKGDIR/build_arm64" "$PKGDIR/root" "$PKGDIR/intermediates" "$PKGDIR/dst"
do_cmake() {
cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,-ld_classic" \
-DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' \
-DFISH_USE_SYSTEM_PCRE2=OFF \
"${cmake_args[@]}" \
"$@" \
"$SRC_DIR"
}
# Build and install for arm64.
# Pass FISH_USE_SYSTEM_PCRE2=OFF because a system PCRE2 on macOS will not be signed by fish,
# and will probably not be built universal, so the package will fail to validate/run on other systems.
# Note CMAKE_OSX_ARCHITECTURES is still relevant for the Mac app.
{ cd "$PKGDIR/build_arm64" \
&& cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,-ld_classic" \
-DRust_CARGO_TARGET=aarch64-apple-darwin \
-DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' \
-DFISH_USE_SYSTEM_PCRE2=OFF \
"$SRC_DIR" \
&& do_cmake -DRust_CARGO_TARGET=aarch64-apple-darwin \
&& env $ARM64_DEPLOY_TARGET make VERBOSE=1 -j 12 \
&& env DESTDIR="$PKGDIR/root/" $ARM64_DEPLOY_TARGET make install;
}
# Build for x86-64 but do not install; instead we will make some fat binaries inside the root.
# Set RUST_VERSION_X86_64 to the last version of Rust that supports macOS 10.9.
{ cd "$PKGDIR/build_x86_64" \
&& cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,-ld_classic" \
-DRust_TOOLCHAIN="$RUST_VERSION_X86_64" \
-DRust_CARGO_TARGET=x86_64-apple-darwin \
-DRust_COMPILER="$(rustup +$RUST_VERSION_X86_64 which rustc)" \
-DRust_CARGO="$(rustup +$RUST_VERSION_X86_64 which cargo)" \
-DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' \
-DFISH_USE_SYSTEM_PCRE2=OFF "$SRC_DIR" \
&& do_cmake -DRust_CARGO_TARGET=x86_64-apple-darwin \
&& env $X86_64_DEPLOY_TARGET make VERBOSE=1 -j 12; }
# Fatten them up.

View File

@@ -1,79 +1,23 @@
#!/bin/sh
# Script to generate a tarball
# We use git to output a tree. But we also want to build the user documentation
# and put that in the tarball, so that nobody needs to have sphinx installed
# to build it.
# Outputs to $FISH_ARTEFACT_PATH or ~/fish_built by default
# Exit on error
set -e
# We will generate a tarball with a prefix "fish-VERSION"
# git can do that automatically for us via git-archive
# but to get the documentation in, we need to make a symlink called "fish-VERSION"
# and tar from that, so that the documentation gets the right prefix
# Use Ninja if available, as it automatically parallelises
BUILD_TOOL="make"
BUILD_GENERATOR="Unix Makefiles"
if command -v ninja >/dev/null; then
BUILD_TOOL="ninja"
BUILD_GENERATOR="Ninja"
fi
# We need GNU tar as that supports the --mtime and --transform options
TAR=notfound
for try in tar gtar gnutar; do
if $try -Pcf /dev/null --mtime now /dev/null >/dev/null 2>&1; then
TAR=$try
break
fi
done
if [ "$TAR" = "notfound" ]; then
echo 'No suitable tar (supporting --mtime) found as tar/gtar/gnutar in PATH'
exit 1
fi
# Get the current directory, which we'll use for symlinks
wd="$PWD"
# Get the version
VERSION=$(build_tools/git_version_gen.sh --stdout 2>/dev/null)
# The name of the prefix, which is the directory that you get when you untar
prefix="fish-$VERSION"
prefix=fish-$VERSION
path=${FISH_ARTEFACT_PATH:-~/fish_built}/$prefix.tar.xz
# The path where we will output the tar file
# Defaults to ~/fish_built
path=${FISH_ARTEFACT_PATH:-~/fish_built}/$prefix.tar
# Clean up stuff we've written before
rm -f "$path" "$path".xz
# git starts the archive
git archive --format=tar --prefix="$prefix"/ HEAD > "$path"
# tarball out the documentation, generate a version file
PREFIX_TMPDIR=$(mktemp -d)
cd "$PREFIX_TMPDIR"
echo "$VERSION" > version
cmake -G "$BUILD_GENERATOR" -DCMAKE_BUILD_TYPE=Debug "$wd"
$BUILD_TOOL doc
TAR_APPEND="$TAR --append --file=$path --mtime=now --owner=0 --group=0 \
--mode=g+w,a+rX --transform s/^/$prefix\//"
$TAR_APPEND --no-recursion user_doc
$TAR_APPEND user_doc/html user_doc/man
$TAR_APPEND version
cd -
rm -r "$PREFIX_TMPDIR"
# xz it
xz "$path"
git archive \
--prefix="$prefix/" \
--add-virtual-file="$prefix/version:$VERSION" \
HEAD |
xz >"$path"
# Output what we did, and the sha256 hash
echo "Tarball written to $path".xz
openssl dgst -sha256 "$path".xz
echo "Tarball written to $path"
openssl dgst -sha256 "$path"

View File

@@ -11,37 +11,38 @@ mkdir -p "$relnotes_tmp/fake-workspace" "$relnotes_tmp/out"
cp -r doc_src CONTRIBUTING.rst README.rst "$relnotes_tmp/fake-workspace"
)
version=$(sed 's,^fish \(\S*\) .*,\1,; 1q' "$workspace_root/CHANGELOG.rst")
previous_version=$(
cd "$workspace_root"
awk <CHANGELOG.rst '
( /^fish \S*\.\S*\.\S* \(released .*\)$/ &&
NR > 1 &&
# Skip tags that have not been created yet..
system("git rev-parse --verify >/dev/null --quiet refs/tags/"$2) == 0 \
) {
print $2; ok = 1; exit
}
END { exit !ok }
'
)
minor_version=${version%.*}
previous_minor_version=${previous_version%.*}
add_stats=false
# Skip on shallow clone (CI) for now.
if test -z "$CI" || [ "$(git -C "$workspace_root" tag | wc -l)" -gt 1 ]; then {
previous_version=$(
cd "$workspace_root"
git for-each-ref --format='%(objecttype) %(refname:strip=2)' refs/tags |
awk '/tag/ {print $2}' | sort --version-sort |
grep -vxF "$(git describe)" | tail -1
)
minor_version=${version%.*}
previous_minor_version=${previous_version%.*}
if [ "$minor_version" != "$previous_minor_version" ]; then
add_stats=true
fi
} fi
{
sed -n 1,2p <"$workspace_root/CHANGELOG.rst"
ListCommitters() {
comm "$@" "$relnotes_tmp/committers-then" "$relnotes_tmp/committers-now"
}
(
cd "$workspace_root"
git log "$previous_version" --format="%aN" | sort -u >"$relnotes_tmp/committers-then"
git log "$previous_version".. --format="%aN" | sort -u >"$relnotes_tmp/committers-now"
ListCommitters -13 >"$relnotes_tmp/committers-new"
ListCommitters -12 >"$relnotes_tmp/committers-returning"
)
if [ "$minor_version" != "$previous_minor_version" ]; then
if $add_stats; then {
ExtractCommitters() {
git log "$1" --format="%aN"
trailers='Co-authored-by|Signed-off-by'
git log "$1" --format="%b" | sed -En "/^($trailers):\s*/{s///;s/\s*<.*//;p}"
}
ListCommitters() {
comm "$@" "$relnotes_tmp/committers-then" "$relnotes_tmp/committers-now"
}
(
cd "$workspace_root"
ExtractCommitters "$previous_version" | sort -u >"$relnotes_tmp/committers-then"
ExtractCommitters "$previous_version".. | sort -u >"$relnotes_tmp/committers-now"
ListCommitters -13 >"$relnotes_tmp/committers-new"
ListCommitters -12 >"$relnotes_tmp/committers-returning"
num_commits=$(git log --no-merges --format=%H "$previous_version".. | wc -l)
num_authors=$(wc -l <"$relnotes_tmp/committers-now")
num_new_authors=$(wc -l <"$relnotes_tmp/committers-new")
@@ -51,7 +52,7 @@ previous_minor_version=${previous_version%.*}
echo
echo
)
fi
} fi
printf '%s\n' "$(awk <"$workspace_root/CHANGELOG.rst" '
NR <= 2 || /^\.\. ignore / { next }
@@ -60,9 +61,9 @@ previous_minor_version=${previous_version%.*}
' | sed '$d')" |
sed -e '$s/^----*$//' # Remove spurious transitions at the end of the document.
if [ "$minor_version" != "$previous_minor_version" ]; then {
if $add_stats; then {
JoinEscaped() {
sed 's/\S/\\&/g' |
LC_CTYPE=C.UTF-8 sed 's/\S/\\&/g' |
awk '
NR != 1 { printf ",\n" }
{ printf "%s", $0 }
@@ -83,9 +84,14 @@ previous_minor_version=${previous_version%.*}
echo
echo "---"
echo
echo "*Download links: To download the source code for fish, we suggest the file named \"fish-$version.tar.xz\". The file downloaded from \"Source code (tar.gz)\" will not build correctly.*"
echo 'Download links:'
echo 'To download the source code for fish, we suggest the file named ``fish-'"$version"'.tar.xz``.'
echo 'The file downloaded from ``Source code (tar.gz)`` will not build correctly.'
echo 'A GPG signature using `this key <'"${FISH_GPG_PUBLIC_KEY_URL:-???}"'>`__ is available as ``fish-'"$version"'.tar.xz.asc``.'
echo
echo "*The files called fish-$version-linux-\*.tar.xz are experimental packages containing a single standalone ``fish`` binary for any Linux with the given CPU architecture.*"
echo 'The files called ``fish-'"$version"'-linux-*.tar.xz`` contain'
echo '`standalone fish binaries <https://github.com/fish-shell/fish-shell/?tab=readme-ov-file#building-fish-with-cargo>`__'
echo 'for any Linux with the given CPU architecture.'
} >"$relnotes_tmp/fake-workspace"/CHANGELOG.rst
sphinx-build >&2 -j auto \
@@ -93,7 +99,7 @@ sphinx-build >&2 -j auto \
-d "$relnotes_tmp/doctree" "$relnotes_tmp/fake-workspace/doc_src" "$relnotes_tmp/out" \
-D markdown_http_base="https://fishshell.com/docs/$minor_version" \
-D markdown_uri_doc_suffix=".html" \
-D markdown_github_flavored=1 \
-D markdown_flavor=github \
"$@"
# Skip changelog header

View File

@@ -18,11 +18,18 @@ fi
[ -n "$version" ]
for tool in \
cmake \
bundle \
diff \
gh \
gpg \
jq \
ninja \
ruby \
tar \
timeout \
uv \
xz \
; do
if ! command -v "$tool" >/dev/null; then
echo >&2 "$0: missing command: $1"
@@ -30,8 +37,14 @@ for tool in \
fi
done
committer=$(git var GIT_AUTHOR_IDENT)
committer=${committer% *} # strip timezone
committer=${committer% *} # strip timestamp
gpg --local-user="$committer" --sign </dev/null >/dev/null
repo_root="$(dirname "$0")/.."
fish_site=$repo_root/../fish-site
fish_site_repo=git@github.com:$repository_owner/fish-site
for path in . "$fish_site"
do
@@ -42,6 +55,13 @@ do
fi
done
(
cd "$fish_site"
[ "$(git rev-parse HEAD)" = \
"$(git ls-remote "$fish_site_repo" refs/heads/master |
awk '{print $1}')" ]
)
if git tag | grep -qxF "$version"; then
echo >&2 "$0: tag $version already exists"
exit 1
@@ -66,6 +86,22 @@ sed -i \
CommitVersion() {
sed -i "s/^version = \".*\"/version = \"$1\"/g" Cargo.toml
cargo fetch --offline
if [ "$1" = "$version" ]; then
# debchange is a Debian script to manage the Debian changelog, but
# it's too annoying to install everywhere. Just do it by hand.
cat - contrib/debian/changelog > contrib/debian/changelog.new <<EOF
fish (${version}-1) stable; urgency=medium
* Release of new version $version.
See https://github.com/fish-shell/fish-shell/releases/tag/$version for details.
-- $committer $(date -R)
EOF
mv contrib/debian/changelog.new contrib/debian/changelog
git add contrib/debian/changelog
fi
git add CHANGELOG.rst Cargo.toml Cargo.lock
git commit -m "$2
@@ -74,8 +110,8 @@ Created by ./build_tools/release.sh $version"
CommitVersion "$version" "Release $version"
# N.B. this is not GPG-signed.
git tag --annotate --message="Release $version" $version
git -c "user.signingKey=$committer" \
tag --sign --message="Release $version" $version
git push $remote $version
@@ -100,13 +136,21 @@ done
# Update fishshell.com
tag_oid=$(git rev-parse "$version")
tmpdir=$(mktemp -d)
fish_tar_xz=fish-$version.tar.xz
(
local_tarball=$tmpdir/local-tarball
mkdir "$local_tarball"
FISH_ARTEFACT_PATH=$local_tarball ./build_tools/make_tarball.sh
cd "$local_tarball"
tar xf "$fish_tar_xz"
)
# TODO This works on draft releases only if "gh" is configured to
# have write access to the fish-shell repository. Unless we are fine
# publishing the release at this point, we should at least fail if
# "gh" doesn't have write access.
while ! \
gh release download "$version" --dir="$tmpdir" \
--pattern="fish-$version.tar.xz"
--pattern="$fish_tar_xz"
do
TIMEOUT=30 gh run watch "$run_id" ||:
sleep 5
@@ -114,10 +158,26 @@ done
actual_tag_oid=$(git ls-remote "$remote" |
awk '$2 == "refs/tags/'"$version"'" { print $1 }')
[ "$tag_oid" = "$actual_tag_oid" ]
( cd "$tmpdir" && tar xf fish-$version.tar.xz )
(
cd "$tmpdir"
tar xf "$fish_tar_xz"
diff -ur "fish-$version" "local-tarball/fish-$version"
gpg --local-user="$committer" --sign --detach --armor \
"$fish_tar_xz"
gh release upload "$version" "$fish_tar_xz.asc"
)
(
cd "$tmpdir/local-tarball/fish-$version"
uv --no-managed-python venv
. .venv/bin/activate
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug .
ninja doc
)
CopyDocs() {
rm -rf "$fish_site/site/docs/$1"
cp -r "$tmpdir/fish-$version/user_doc/html" "$fish_site/site/docs/$1"
cp -r "$tmpdir/local-tarball/fish-$version/user_doc/html" "$fish_site/site/docs/$1"
git -C $fish_site add "site/docs/$1"
}
minor_version=${version%.*}
@@ -147,15 +207,21 @@ rm -rf "$tmpdir"
" | sed 's,^\s*| \?,,')"
)
# Approve macos-codesign
# TODO what if current user can't approve?
gh_pending_deployments() {
gh_api_repo() {
path=$1
shift
command gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/$repository_owner/fish-shell/actions/runs/$run_id/pending_deployments" \
"/repos/$repository_owner/fish-shell/$path" \
"$@"
}
# Approve macos-codesign
# TODO what if current user can't approve?
gh_pending_deployments() {
gh_api_repo "actions/runs/$run_id/pending_deployments" "$@"
}
while {
environment_id=$(gh_pending_deployments | jq .[].environment.id)
[ -z "$environment_id" ]
@@ -170,7 +236,7 @@ echo '
"comment": "Approved via ./build_tools/release.sh"
}
' |
gh_pending_deployments -XPOST --input=-
gh_pending_deployments --method POST --input=-
# Await completion.
gh run watch "$run_id"
@@ -198,12 +264,14 @@ done
" | sed 's,^\s*| \?,,')"
# This takes care to support remote names that are different from
# fish-shell remote name. Also, support detached HEAD state.
git push git@github.com:$repository_owner/fish-site HEAD:master
git push "$fish_site_repo" HEAD:master
git fetch "$fish_site_repo" \
"$(git rev-parse HEAD):refs/remotes/origin/master"
)
if [ -n "$integration_branch" ]; then {
git push $remote "$version^{commit}":refs/heads/$integration_branch
else
} else {
changelog=$(cat - CHANGELOG.rst <<EOF
fish ?.?.? (released ???)
=========================
@@ -215,6 +283,29 @@ EOF
git push $remote HEAD:master
} fi
milestone_version="$(
if echo "$version" | grep -q '\.0$'; then
echo "$minor_version"
else
echo "$version"
fi
)"
milestone_number() {
gh_api_repo milestones?state=open |
jq --arg name "fish $1" '
.[] | select(.title == $name) | .number
'
}
gh_api_repo milestones/"$(milestone_number "$milestone_version")" \
--method PATCH --raw-field state=closed
next_minor_version=$(echo "$minor_version" |
awk -F. '{ printf "%s.%s", $1, $2+1 }')
if [ -z "$(milestone_number "$next_minor_version")" ]; then
gh_api_repo milestones --method POST \
--raw-field title="fish $next_minor_version"
fi
exit
}

View File

@@ -44,7 +44,7 @@ if test $all = yes
end
end
set fish_files $workspace_root/{benchmarks,build_tools,etc,share}/**.fish
set python_files {doc_src,share,tests}/**.py
set python_files $workspace_root
else
# Format the files specified as arguments.
set -l files $argv
@@ -58,6 +58,11 @@ set -l green (set_color green)
set -l yellow (set_color yellow)
set -l normal (set_color normal)
function die -V red -V normal
echo $red$argv[1]$normal
exit 1
end
if set -q fish_files[1]
if not type -q fish_indent
echo
@@ -66,58 +71,52 @@ if set -q fish_files[1]
end
echo === Running "$green"fish_indent"$normal"
if set -l -q _flag_check
if not fish_indent --check -- $fish_files
echo $red"Fish files are not formatted correctly."$normal
exit 1
end
fish_indent --check -- $fish_files
or die "Fish files are not formatted correctly."
else
fish_indent -w -- $fish_files
end
end
if set -q python_files[1]
if not type -q black
if not type -q ruff
echo
echo $yellow'Please install `black` to style python'$normal
echo $yellow'Please install `ruff` to style python'$normal
exit 127
end
echo === Running "$green"black"$normal"
echo === Running "$green"ruff format"$normal"
if set -l -q _flag_check
if not black --check $python_files
echo $red"Python files are not formatted correctly."$normal
exit 1
end
ruff format --check $python_files
or die "Python files are not formatted correctly."
else
black $python_files
ruff format $python_files
end
end
if not cargo fmt --version >/dev/null
echo
echo $yellow'Please install "rustfmt" to style Rust, e.g. via:'
echo "rustup component add rustfmt"$normal
exit 127
end
echo === Running "$green"rustfmt"$normal"
if set -l -q _flag_check
if set -l -q _flag_all
if not cargo fmt --check
echo $red"Rust files are not formatted correctly."$normal
exit 1
end
else
if set -q rust_files[1]
if not rustfmt --check --files-with-diff $rust_files
echo $red"Rust files are not formatted correctly."
exit 1
end
end
if test $all = yes; or set -q rust_files[1]
if not cargo fmt --version >/dev/null
echo
echo $yellow'Please install "rustfmt" to style Rust, e.g. via:'
echo "rustup component add rustfmt"$normal
exit 127
end
else
if set -l -q _flag_all
cargo fmt
set -l edition_spec string match -r '^edition\s*=.*'
test "$($edition_spec <Cargo.toml)" = "$($edition_spec <.rustfmt.toml)"
or die "Cargo.toml and .rustfmt.toml use different editions"
echo === Running "$green"rustfmt"$normal"
if set -l -q _flag_check
if test $all = yes
cargo fmt --all --check
else
rustfmt --check --files-with-diff $rust_files
end
or die "Rust files are not formatted correctly."
else
if set -q rust_files[1]
if test $all = yes
cargo fmt --all
else
rustfmt $rust_files
end
end

View File

@@ -0,0 +1,22 @@
# /// script
# requires-python = ">=3.5"
# dependencies = [
# "launchpadlib",
# ]
# ///
from launchpadlib.launchpad import Launchpad
if __name__ == "__main__":
launchpad = Launchpad.login_anonymously(
"fish shell build script", "production", "~/.cache", version="devel"
)
ubu = launchpad.projects("ubuntu")
print(
"\n".join(
x["name"]
for x in ubu.series.entries
if x["supported"] == True
and x["name"] not in ("trusty", "xenial", "bionic", "focal")
)
)

View File

@@ -0,0 +1,33 @@
#!/bin/sh
set -ex
command -v curl
command -v gcloud
command -v jq
command -v rustup
command -v updatecli
command -v uv
sort --version-sort </dev/null
uv lock --check
updatecli "${@:-apply}"
uv lock # Python version constraints may have changed.
uv lock --upgrade --exclude-newer="$(date --date='7 days ago' --iso-8601)"
from_gh() {
repo=$1
path=$2
out_dir=$3
contents=$(curl -fsS https://raw.githubusercontent.com/"${repo}"/refs/heads/master/"${path}")
printf '%s\n' >"$out_dir/$(basename "$path")" "$contents"
}
from_gh ridiculousfish/widecharwidth widechar_width.rs crates/widecharwidth/src/
from_gh ridiculousfish/littlecheck littlecheck/littlecheck.py tests/
# Update Cargo.lock
cargo update
# Update Cargo.toml and Cargo.lock
cargo +nightly -Zunstable-options update --breaking

View File

@@ -9,32 +9,32 @@
# For developers:
# - Run with no args to update all PO files after making changes to Rust/fish sources.
# For translators:
# - Specify the language you want to work on as an argument, which must be a file in the po/
# directory. You can specify a language which does not have translations yet by specifying the
# name of a file which does not yet exist. Make sure to follow the naming convention.
# - Specify the language you want to work on as an argument, which must be a file in the
# localization/po/ directory. You can specify a language which does not have translations
# yet by specifying the name of a file which does not yet exist.
# Make sure to follow the naming convention.
# For testing:
# - Specify `--dry-run` to see if any updates to the PO files would by applied by this script.
# If this flag is specified, the script will exit with an error if there are outstanding
# changes, and will display the diff. Do not specify other flags if `--dry-run` is specified.
#
# Specify `--use-existing-template=FILE` to prevent running cargo for extracting an up-to-date
# Specify `--use-existing-template=DIR` to prevent running cargo for extracting an up-to-date
# version of the localized strings. This flag is intended for testing setups which make it
# inconvenient to run cargo here, but run it in an earlier step to ensure up-to-date values.
# This argument is passed on to the `fish_xgettext.fish` script and has no other uses.
# `FILE` must be the path to a gettext template file generated from our compilation process.
# `DIR` must be the path to a gettext template file generated from our compilation process.
# It can be obtained by running:
# set -l FILE (mktemp)
# FISH_GETTEXT_EXTRACTION_FILE=$FILE cargo check --features=gettext-extract
# set -l DIR (mktemp -d)
# FISH_GETTEXT_EXTRACTION_DIR=$DIR cargo check --features=gettext-extract
# The sort utility is locale-sensitive.
# Ensure that sorting output is consistent by setting LC_ALL here.
set -gx LC_ALL C.UTF-8
set -l build_tools (status dirname)
set -l po_dir $build_tools/../po
set -l po_dir $build_tools/../localization/po
set -l extract
set -l po
argparse dry-run use-existing-template= -- $argv
or exit $status
@@ -90,8 +90,9 @@ if set -l --query extract
end
if set -l --query _flag_dry_run
# On a dry run, we do not modify po/ but write to a temporary directory instead and check if
# there is a difference between po/ and the tmpdir after re-generating the PO files.
# On a dry run, we do not modify localization/po/ but write to a temporary directory instead
# and check if there is a difference between localization/po/ and the tmpdir after re-generating
# the PO files.
set -g tmpdir (mktemp -d)
# Ensure tmpdir has the same initial state as the po dir.
@@ -134,22 +135,20 @@ for po_file in $po_files
if set --query tmpdir[1]
set po_file $tmpdir/(basename $po_file)
end
if set -l --query po
if test -e $po_file
merge_po_files $template_file $po_file
else
begin
print_header
cat $template_file
end >$po_file
end
if test -e $po_file
merge_po_files $template_file $po_file
else
begin
print_header
cat $template_file
end >$po_file
end
end
if set -g --query tmpdir[1]
diff -ur $po_dir $tmpdir
or begin
echo ERROR: translations in ./po/ are stale. Try running build_tools/update_translations.fish
echo ERROR: translations in localization/po/ are stale. Try running build_tools/update_translations.fish
cleanup_exit
end
end

View File

@@ -0,0 +1,16 @@
#!/bin/bash
set -euo pipefail
channel=$1 # e.g. stable, testing
package=$2 # e.g. rustc, sphinx
codename=$(
curl -fsS https://ftp.debian.org/debian/dists/"${channel}"/Release |
grep '^Codename:' | cut -d' ' -f2)
curl -fsS https://sources.debian.org/api/src/"${package}"/ |
jq -r --arg codename "${codename}" '
.versions[] | select(.suites[] == $codename) | .version' |
sed 's/^\([0-9]\+\.[0-9]\+\).*/\1/' |
sort --version-sort |
tail -1

View File

@@ -27,7 +27,6 @@ add_custom_target(sphinx-docs
DEPENDS ${SPHINX_SRC_DIR}/fish_indent_lexer.py fish_indent
COMMENT "Building HTML documentation with Sphinx")
# sphinx-manpages needs the fish_indent binary for the version number
add_custom_target(sphinx-manpages
env FISH_BUILD_VERSION_FILE=${CMAKE_CURRENT_BINARY_DIR}/${FBVF}
${SPHINX_EXECUTABLE}
@@ -36,51 +35,36 @@ add_custom_target(sphinx-manpages
-c "${SPHINX_SRC_DIR}"
-d "${SPHINX_ROOT_DIR}/.doctrees-man"
"${SPHINX_SRC_DIR}"
# TODO: This only works if we only have section 1 manpages.
"${SPHINX_MANPAGE_DIR}/man1"
DEPENDS CHECK-FISH-BUILD-VERSION-FILE
COMMENT "Building man pages with Sphinx")
if(SPHINX_EXECUTABLE)
option(BUILD_DOCS "build documentation (requires Sphinx)" ON)
else(SPHINX_EXECUTABLE)
option(BUILD_DOCS "build documentation (requires Sphinx)" OFF)
endif(SPHINX_EXECUTABLE)
if(NOT DEFINED WITH_DOCS) # Don't check for legacy options if the new one is defined, to help bisecting.
if(DEFINED BUILD_DOCS)
message(FATAL_ERROR "the BUILD_DOCS option is no longer supported, use -DWITH_DOCS=ON|OFF")
endif()
if(DEFINED INSTALL_DOCS)
message(FATAL_ERROR "the INSTALL_DOCS option is no longer supported, use -DWITH_DOCS=ON|OFF")
endif()
endif()
if(BUILD_DOCS AND NOT SPHINX_EXECUTABLE)
if(SPHINX_EXECUTABLE)
option(WITH_DOCS "build documentation (requires Sphinx)" ON)
else()
option(WITH_DOCS "build documentation (requires Sphinx)" OFF)
endif()
if(WITH_DOCS AND NOT SPHINX_EXECUTABLE)
message(FATAL_ERROR "build documentation selected, but sphinx-build could not be found")
endif()
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/user_doc/html
AND IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/user_doc/man)
set(HAVE_PREBUILT_DOCS TRUE)
else()
set(HAVE_PREBUILT_DOCS FALSE)
endif()
add_feature_info(Documentation WITH_DOCS "user manual and documentation")
if(BUILD_DOCS OR HAVE_PREBUILT_DOCS)
set(INSTALL_DOCS ON)
else()
set(INSTALL_DOCS OFF)
endif()
add_feature_info(Documentation INSTALL_DOCS "user manual and documentation")
if(BUILD_DOCS)
if(WITH_DOCS)
configure_file("${SPHINX_SRC_DIR}/conf.py" "${SPHINX_BUILD_DIR}/conf.py" @ONLY)
add_custom_target(doc ALL
DEPENDS sphinx-docs sphinx-manpages)
# Group docs targets into a DocsTargets folder
set_property(TARGET doc sphinx-docs sphinx-manpages
PROPERTY FOLDER cmake/DocTargets)
elseif(HAVE_PREBUILT_DOCS)
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
# Out of tree build - link the prebuilt documentation to the build tree
add_custom_target(link_doc ALL)
add_custom_command(TARGET link_doc
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/user_doc ${CMAKE_CURRENT_BINARY_DIR}/user_doc
POST_BUILD)
endif()
endif(BUILD_DOCS)
endif()

View File

@@ -1,7 +1,5 @@
set(CMAKE_INSTALL_MESSAGE NEVER)
set(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fish ${CMAKE_CURRENT_BINARY_DIR}/fish_indent ${CMAKE_CURRENT_BINARY_DIR}/fish_key_reader)
set(prefix ${CMAKE_INSTALL_PREFIX})
set(bindir ${CMAKE_INSTALL_BINDIR})
set(sysconfdir ${CMAKE_INSTALL_SYSCONFDIR})
@@ -75,22 +73,30 @@ function(FISH_TRY_CREATE_DIRS)
endforeach()
endfunction(FISH_TRY_CREATE_DIRS)
install(PROGRAMS ${PROGRAMS}
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fish
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION ${bindir})
if(NOT IS_ABSOLUTE ${bindir})
set(abs_bindir "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${bindir}")
else()
set(abs_bindir "\$ENV{DESTDIR}${bindir}")
endif()
install(CODE "file(CREATE_LINK ${abs_bindir}/fish ${abs_bindir}/fish_indent)")
install(CODE "file(CREATE_LINK ${abs_bindir}/fish ${abs_bindir}/fish_key_reader)")
fish_create_dirs(${sysconfdir}/fish/conf.d ${sysconfdir}/fish/completions
${sysconfdir}/fish/functions)
install(FILES etc/config.fish DESTINATION ${sysconfdir}/fish/)
fish_create_dirs(${rel_datadir}/fish ${rel_datadir}/fish/completions
${rel_datadir}/fish/functions ${rel_datadir}/fish/groff
${rel_datadir}/fish/functions
${rel_datadir}/fish/man/man1 ${rel_datadir}/fish/tools
${rel_datadir}/fish/tools/web_config
${rel_datadir}/fish/tools/web_config/js
${rel_datadir}/fish/tools/web_config/sample_prompts
${rel_datadir}/fish/tools/web_config/themes
${rel_datadir}/fish/prompts
${rel_datadir}/fish/themes
)
configure_file(share/__fish_build_paths.fish.in share/__fish_build_paths.fish)
@@ -125,9 +131,6 @@ install(DIRECTORY share/functions/
DESTINATION ${rel_datadir}/fish/functions
FILES_MATCHING PATTERN "*.fish")
install(DIRECTORY share/groff
DESTINATION ${rel_datadir}/fish)
# CONDEMNED_PAGE is managed by the conditional above
# Building the man pages is optional: if sphinx isn't installed, they're not built
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/
@@ -136,7 +139,7 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/
PATTERN "*.1"
PATTERN ${CONDEMNED_PAGE} EXCLUDE)
install(PROGRAMS share/tools/create_manpage_completions.py share/tools/deroff.py
install(PROGRAMS share/tools/create_manpage_completions.py
DESTINATION ${rel_datadir}/fish/tools/)
install(DIRECTORY share/tools/web_config

View File

@@ -19,7 +19,6 @@ else()
endif()
set(rust_profile $<IF:$<CONFIG:Debug>,debug,$<IF:$<CONFIG:RelWithDebInfo>,release-with-debug,release>>)
set(rust_debugflags "$<$<CONFIG:Debug>:-g>$<$<CONFIG:RelWithDebInfo>:-g>")
option(WITH_GETTEXT "Build with gettext localization support. Requires `msgfmt` to work." ON)
# Enable gettext feature unless explicitly disabled.
@@ -28,19 +27,3 @@ if(NOT DEFINED WITH_GETTEXT OR "${WITH_GETTEXT}")
endif()
list(JOIN FISH_CARGO_FEATURES_LIST , FISH_CARGO_FEATURES)
# Tell Cargo where our build directory is so it can find Cargo.toml.
set(VARS_FOR_CARGO
"FISH_BUILD_DIR=${CMAKE_BINARY_DIR}"
"PREFIX=${CMAKE_INSTALL_PREFIX}"
# Cheesy so we can tell cmake was used to build
"CMAKE=1"
"DOCDIR=${CMAKE_INSTALL_FULL_DOCDIR}"
"DATADIR=${CMAKE_INSTALL_FULL_DATADIR}"
"SYSCONFDIR=${CMAKE_INSTALL_FULL_SYSCONFDIR}"
"BINDIR=${CMAKE_INSTALL_FULL_BINDIR}"
"CARGO_TARGET_DIR=${FISH_RUST_BUILD_DIR}"
"CARGO_BUILD_RUSTC=${Rust_COMPILER}"
"${FISH_PCRE2_BUILDFLAG}"
"RUSTFLAGS=$ENV{RUSTFLAGS} ${rust_debugflags}"
)

View File

@@ -57,7 +57,15 @@ endif()
add_custom_target(fish_run_tests
# TODO: This should be replaced with a unified solution, possibly build_tools/check.sh.
COMMAND ${CMAKE_SOURCE_DIR}/tests/test_driver.py ${max_concurrency_flag} ${CMAKE_CURRENT_BINARY_DIR}
COMMAND env ${VARS_FOR_CARGO} cargo test --no-default-features ${CARGO_FLAGS} --workspace --target-dir ${rust_target_dir} ${cargo_test_flags}
COMMAND env ${VARS_FOR_CARGO}
${Rust_CARGO}
test
--no-default-features
--features=${FISH_CARGO_FEATURES}
${CARGO_FLAGS}
--workspace
--target-dir ${rust_target_dir}
${cargo_test_flags}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
DEPENDS fish fish_indent fish_key_reader fish_test_helper
USES_TERMINAL

472
contrib/debian/changelog Normal file
View File

@@ -0,0 +1,472 @@
fish (4.3.1-1) stable; urgency=medium
* Release of new version 4.3.1.
See https://github.com/fish-shell/fish-shell/releases/tag/4.3.1 for details.
-- Johannes Altmanninger <aclopte@gmail.com> Sun, 28 Dec 2025 16:54:44 +0100
fish (4.3.0-1) stable; urgency=medium
* Release of new version 4.3.0.
See https://github.com/fish-shell/fish-shell/releases/tag/4.3.0 for details.
-- Johannes Altmanninger <aclopte@gmail.com> Sun, 28 Dec 2025 10:20:47 +0100
fish (4.2.1-1) testing; urgency=medium
* Release of new version 4.2.1.
See https://github.com/fish-shell/fish-shell/releases/tag/4.2.1 for details.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Thu, 13 Nov 2025 20:42:43 +0800
fish (4.2.0-1) testing; urgency=medium
* Release of new version 4.2.0.
See https://github.com/fish-shell/fish-shell/releases/tag/4.2.0 for details.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Mon, 10 Nov 2025 19:29:03 +0800
fish (4.1.2-1) testing; urgency=medium
* Release of new version 4.1.2.
See https://github.com/fish-shell/fish-shell/releases/tag/4.1.2 for details.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Wed, 08 Oct 2025 13:46:45 +0800
fish (4.1.1-1) testing; urgency=medium
* Release of new version 4.1.1.
See https://github.com/fish-shell/fish-shell/releases/tag/4.1.1 for details.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Fri, 03 Oct 2025 16:43:43 +0800
fish (4.0.8-1) testing; urgency=medium
* Release of new version 4.0.8.
See https://github.com/fish-shell/fish-shell/releases/tag/4.0.8 for details.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Thu, 18 Sep 2025 22:17:43 +0800
fish (4.0.6-1) testing; urgency=medium
* Release of new version 4.0.6.
See https://github.com/fish-shell/fish-shell/releases/tag/4.0.6 for details.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Wed, 17 Sep 2025 12:27:09 +0800
fish (4.0.2-2) testing; urgency=medium
* Fix tests on Debian.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Sun, 20 Apr 2025 23:08:14 +0800
fish (4.0.2-1) testing; urgency=medium
* Release of new version 4.0.2.
See https://github.com/fish-shell/fish-shell/releases/tag/4.0.2 for details.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Sun, 20 Apr 2025 21:24:18 +0800
fish (4.0.1-1) testing; urgency=medium
* Release of new version 4.0.1.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Thu, 13 Mar 2025 11:30:21 +0800
fish (4.0.0-2) testing; urgency=medium
* Fix tests on Debian.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Thu, 27 Feb 2025 21:50:33 +0800
fish (4.0.0-1) testing; urgency=medium
* Release of new version 4.0.0.
See https://github.com/fish-shell/fish-shell/releases/tag/4.0.0 for details.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Thu, 27 Feb 2025 19:22:30 +0800
fish (4.0.1-1) testing; urgency=medium
* Release of new beta version 4.0b1.
See https://github.com/fish-shell/fish-shell/releases/tag/4.0b1 for details.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Tue, 17 Dec 2024 23:42:25 +0800
fish (3.7.1-1) testing; urgency=medium
* Release of new version 3.7.1.
See https://github.com/fish-shell/fish-shell/releases/tag/3.7.1 for details.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Tue, 19 Mar 2024 13:26:22 +0800
fish (3.7.0-1) testing; urgency=medium
* Release of new version 3.7.0.
See https://github.com/fish-shell/fish-shell/releases/tag/3.7.0 for details.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Mon, 01 Jan 2024 23:32:55 +0800
fish (3.6.4-1) testing; urgency=medium
* Release of new version 3.6.4.
See https://github.com/fish-shell/fish-shell/releases/tag/3.6.4 for details.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Tue, 05 Dec 2023 22:34:09 +0800
fish (3.6.3-1) testing; urgency=medium
* Release of new version 3.6.3.
See https://github.com/fish-shell/fish-shell/releases/tag/3.6.3 for details.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Tue, 05 Dec 2023 00:11:12 +0800
fish (3.6.2-1) testing; urgency=medium
* Release of new version 3.6.2.
* Includes a fix for CVE-2023-49284.
See https://github.com/fish-shell/fish-shell/releases/tag/3.6.2 for details.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Mon, 04 Dec 2023 23:16:42 +0800
fish (3.6.1-1) testing; urgency=medium
* Release of new version 3.6.1.
See https://github.com/fish-shell/fish-shell/releases/tag/3.6.1 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Sat, 25 Mar 2023 17:22:12 +0800
fish (3.6.0-1) testing; urgency=medium
* Release of new version 3.6.0.
See https://github.com/fish-shell/fish-shell/releases/tag/3.6.0 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Sat, 07 Jan 2023 22:41:32 +0800
fish (3.5.1-1) testing; urgency=medium
* Release of new version 3.5.1.
See https://github.com/fish-shell/fish-shell/releases/tag/3.5.1 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Wed, 20 Jul 2022 21:54:09 +0800
fish (3.5.0-1) testing; urgency=medium
* Release of new version 3.5.0.
See https://github.com/fish-shell/fish-shell/releases/tag/3.5.0 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Thu, 16 Jun 2022 19:45:33 +0800
fish (3.4.0-1) testing; urgency=medium
* Release of new version 3.4.0.
See https://github.com/fish-shell/fish-shell/releases/tag/3.4.0 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Sat, 12 Mar 2022 23:24:22 +0800
fish (3.3.1-1) testing; urgency=medium
* Release of new version 3.3.1.
See https://github.com/fish-shell/fish-shell/releases/tag/3.3.1 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Tue, 06 Jul 2021 23:22:36 +0800
fish (3.3.0-1) testing; urgency=medium
* Release of new version 3.3.0.
See https://github.com/fish-shell/fish-shell/releases/tag/3.3.0 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Mon, 28 Jun 2021 23:06:36 +0800
fish (3.2.2-1) testing; urgency=medium
* Release of new version 3.2.2.
See https://github.com/fish-shell/fish-shell/releases/tag/3.2.2 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Wed, 07 Apr 2021 21:10:54 +0800
fish (3.2.1-1) testing; urgency=medium
* Release of new version 3.2.1.
See https://github.com/fish-shell/fish-shell/releases/tag/3.2.1 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Thu, 18 Mar 2021 12:08:13 +0800
fish (3.2.0-1) testing; urgency=medium
* Release of new version 3.2.0.
See https://github.com/fish-shell/fish-shell/releases/tag/3.2.0 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Mon, 01 Mar 2021 21:22:39 +0800
fish (3.1.2-1) testing; urgency=medium
* Release of new version 3.1.2.
See https://github.com/fish-shell/fish-shell/releases/tag/3.1.2 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Wed, 29 Apr 2020 11:22:35 +0800
fish (3.1.1-1) testing; urgency=medium
* Release of new version 3.1.1.
See https://github.com/fish-shell/fish-shell/releases/tag/3.1.1 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Mon, 27 Apr 2020 22:45:35 +0800
fish (3.1.0-1) testing; urgency=medium
* Release of new version 3.1.0.
See https://github.com/fish-shell/fish-shell/releases/tag/3.1.0 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Wed, 12 Feb 2020 22:34:53 +0800
fish (3.1.1-1) testing; urgency=medium
* Release of new beta version 3.1b1.
See https://github.com/fish-shell/fish-shell/releases/tag/3.1b1 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Sun, 26 Jan 2020 21:42:46 +0800
fish (3.0.2-1) testing; urgency=medium
* Release of new version 3.0.2.
See https://github.com/fish-shell/fish-shell/releases/tag/3.0.2 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Tue, 19 Feb 2019 21:45:05 +0800
fish (3.0.1-1) testing; urgency=medium
* Release of new version 3.0.1.
See https://github.com/fish-shell/fish-shell/releases/tag/3.0.1 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Mon, 11 Feb 2019 20:23:55 +0800
fish (3.0.0-1) testing; urgency=medium
* Release of new version 3.0.0.
See https://github.com/fish-shell/fish-shell/releases/tag/3.0.0 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Fri, 28 Dec 2018 21:10:28 +0800
fish (3.0.1-1) testing; urgency=medium
* Release of new beta version 3.0b1.
See https://github.com/fish-shell/fish-shell/releases/tag/3.0b1 for
significant changes, which includes backward incompatibility.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Tue, 11 Dec 2018 22:59:15 +0800
fish (2.7.1-1) testing; urgency=medium
* Release of new bug fix version 2.7.1. On all Linux platforms, this is
release will behave identically to 2.7.0.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Sat, 23 Dec 2017 00:43:12 +0800
fish (2.7.0-1) testing; urgency=medium
* Release of new version 2.7.0.
See https://github.com/fish-shell/fish-shell/releases/tag/2.7.0 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Thu, 23 Nov 2017 18:38:21 +0800
fish (2.7.1-1) testing; urgency=medium
* Release of new beta version 2.7b1.
See https://github.com/fish-shell/fish-shell/releases/tag/2.7b1 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Tue, 31 Oct 2017 20:32:29 +0800
fish (2.6.0-1) testing; urgency=medium
* Relase of new version 2.6.0.
See https://github.com/fish-shell/fish-shell/releases/tag/2.6.0 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Sat, 03 Jun 2017 20:51:50 +0800
fish (2.6b1-1) testing; urgency=medium
* Release of new beta version 2.6b1.
See https://github.com/fish-shell/fish-shell/releases/tag/2.6b1 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Sun, 14 May 2017 10:47:39 +0800
fish (2.5.0-1) testing; urgency=medium
* Release of new version 2.5.0.
See https://github.com/fish-shell/fish-shell/releases/tag/2.5.0 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Fri, 03 Feb 2017 09:52:57 +0800
fish (2.5b1-1) testing; urgency=medium
* Release of new beta version 2.5b1.
See https://github.com/fish-shell/fish-shell/releases/tag/2.5b1 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Sat, 14 Jan 2017 08:49:34 +0800
fish (2.4.0-2) testing; urgency=medium
* Change recommendation of xdg-utils to suggestion (closes
https://github.com/fish-shell/fish-shell/issues/3534).
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Wed, 09 Nov 2016 22:56:16 +0800
fish (2.4.0-1) testing; urgency=medium
* Release of new version 2.4.0.
See https://github.com/fish-shell/fish-shell/releases/tag/2.4.0 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Tue, 08 Nov 2016 11:29:57 +0800
fish (2.4b1-1) testing; urgency=medium
* Release of new beta version 2.4b1.
See https://github.com/fish-shell/fish-shell/releases/tag/2.4b1 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Tue, 18 Oct 2016 22:25:26 +0800
fish (2.3.1-1) testing; urgency=medium
* Release of new version 2.3.1.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Sun, 03 Jul 2016 21:21:51 +0800
fish (2.3.0-1) testing; urgency=medium
* Release of new version 2.3.0.
See http://fishshell.com/release_notes.html for significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Sat, 21 May 2016 06:59:54 +0800
fish (2.3b2-1) testing; urgency=medium
* Release of new beta version 2.3b2.
See https://github.com/fish-shell/fish-shell/releases/tag/2.3b2 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Thu, 05 May 2016 06:22:37 +0800
fish (2.3.1-1) testing; urgency=medium
* Release of new beta version 2.3b1.
See http://github.com/fish-shell/fish-shell/releases/tag/2.3b1 for
significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Tue, 19 Apr 2016 21:07:17 +0800
fish (2.2.0-2) testing; urgency=medium
* Binary rebuild only to resynchronise repository state.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Mon, 15 Feb 2016 22:45:05 +0800
fish (2.2.0-1) testing; urgency=medium
* Release of new version 2.2.0.
See http://fishshell.com/release_notes.html for significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Sun, 12 Jul 2015 18:52:29 +0800
fish (2.2b1-1) testing; urgency=low
* Release of new beta version 2.2b1.
See http://fishshell.com/staging/release_notes.html for significant
changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Thu, 07 May 2015 14:48:21 +0800
fish (2.1.1-1) unstable; urgency=high
* Release of new version 2.1.1.
See http://fishshell.com/release_notes.html for significant changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Sun, 07 Sep 2014 17:06:31 +0800
fish (2.1.0-1) unstable; urgency=low
* Release of new version 2.1.0.
See http://fishshell.com/staging/release_notes.html for significant
changes.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Sat, 19 Oct 2013 14:35:23 +0800
fish (2.0.0-0) unstable; urgency=low
* Initial release of fish 2.0.0.
-- David Adam <zanchey@ucc.gu.uwa.edu.au> Thu, 19 Jul 2012 23:17:58 +0800

View File

@@ -3,32 +3,31 @@ Section: shells
Priority: optional
Maintainer: ridiculous_fish <corydoras@ridiculousfish.com>
Uploaders: David Adam <zanchey@ucc.gu.uwa.edu.au>
Build-Depends: debhelper (>= 12),
cargo (>= 0.66) | cargo-mozilla (>= 0.66),
cmake (>= 3.15.0) | cmake-mozilla (>= 3.15.0),
Build-Depends: debhelper-compat (= 13),
# -web is for Debian's updated version, -X.Y is for Ubuntu's backported versions
cargo (>= 1.85) | cargo-web (>= 1.85) | cargo-1.85,
cmake (>= 3.15.0),
gettext,
libpcre2-dev,
rustc (>= 1.70),
rustc (>= 1.85) | rustc-web (>= 1.85) | rustc-1.85,
sphinx-doc,
# Test dependencies
locales-all,
ncurses-base,
man-db,
python3
Standards-Version: 4.1.5
# 4.6.2 is Debian 12/Ubuntu Noble 24.04; Ubuntu Jammy is 4.6.0.1
Standards-Version: 4.6.2
Homepage: https://fishshell.com/
Vcs-Git: https://github.com/fish-shell/fish-shell.git
Vcs-Browser: https://github.com/fish-shell/fish-shell
Package: fish
Architecture: any
# for col and lock - bsdmainutils is required in Ubuntu focal
Depends: bsdextrautils | bsdmainutils,
# for col and lock
Depends: bsdextrautils,
file,
# for the msgfmt command
gettext-base,
# for man
man-db,
# for terminal definitions
ncurses-base,
# for kill
procps,
python3 (>=3.5),

View File

@@ -17,11 +17,11 @@ Files: share/tools/web_config/js/alpine.js
Copyright: 2019-2021 Caleb Porzio and contributors
License: MIT
Files: share/tools/web_config/themes/Dracula.theme
Files: share/themes/Dracula.theme
Copyright: 2018 Dracula Team
License: MIT
Files: share/tools/web_config/themes/Nord.theme
Files: share/themes/Nord.theme
Copyright: 2016-2024 Sven Greb
License: MIT

View File

@@ -1,20 +1,25 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1
ifeq (,$(filter terse,$(DEB_BUILD_OPTIONS)))
export DH_VERBOSE=1
# VERBOSE to satisfy Debian policy 4.9, introduced in version 4.2.0
export CARGO_TERM_VERBOSE=true
endif
# The LTO profile sets CFLAGS/CXXFLAGS which confuse the compilation process; disable it
# LTO is still performed by rustc based on Cargo.toml
export DEB_BUILD_MAINT_OPTIONS=optimize=-lto
%:
dh $@
dh $@ --buildsystem=cmake --builddirectory=build
# Setting the build system is still required, because otherwise the GNUmakefile gets picked up
override_dh_auto_configure:
ln -s cargo-vendor/vendor vendor
ln -s cargo-vendor/.cargo .cargo
dh_auto_configure --buildsystem=cmake -- -DCMAKE_BUILD_TYPE=RelWithDebInfo
dh_auto_configure -- -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DRust_CARGO=$$(command -v cargo-1.85 || command -v cargo) \
-DRust_COMPILER=$$(command -v rustc-1.85 || command -v rustc)
override_dh_clean:
dh_clean --exclude=Cargo.toml.orig
@@ -22,4 +27,4 @@ override_dh_clean:
-unlink vendor
override_dh_auto_test:
make fish_run_tests
cd build && make fish_run_tests

View File

@@ -4,6 +4,7 @@ edition.workspace = true
rust-version.workspace = true
version = "0.0.0"
repository.workspace = true
license.workspace = true
[dependencies]
rsconf.workspace = true

View File

@@ -1,4 +1,21 @@
use std::{borrow::Cow, env, path::Path};
use std::{borrow::Cow, env, os::unix::ffi::OsStrExt, path::Path};
pub fn env_var(name: &str) -> Option<String> {
let err = match env::var(name) {
Ok(p) => return Some(p),
Err(err) => err,
};
use env::VarError::*;
match err {
NotPresent => None,
NotUnicode(os_string) => {
panic!(
"Environment variable {name} is not valid Unicode: {:?}",
os_string.as_bytes()
)
}
}
}
pub fn workspace_root() -> &'static Path {
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
@@ -12,8 +29,7 @@ fn cargo_target_dir() -> Cow<'static, Path> {
}
pub fn fish_build_dir() -> Cow<'static, Path> {
// FISH_BUILD_DIR is set by CMake, if we are using it.
option_env!("FISH_BUILD_DIR")
option_env!("FISH_CMAKE_BINARY_DIR")
.map(|d| Cow::Borrowed(Path::new(d)))
.unwrap_or(cargo_target_dir())
}
@@ -29,3 +45,41 @@ pub fn rebuild_if_paths_changed<P: AsRef<Path>, I: IntoIterator<Item = P>>(paths
rsconf::rebuild_if_path_changed(path.as_ref().to_str().unwrap());
}
}
pub fn rebuild_if_embedded_path_changed<P: AsRef<Path>>(path: P) {
// Not necessary in debug builds, where rust-embed reads from the filesystem.
if cfg!(any(not(debug_assertions), windows)) {
rebuild_if_path_changed(path);
}
}
// Target OS for compiling our crates, as opposed to the build script.
pub fn target_os() -> String {
env_var("CARGO_CFG_TARGET_OS").unwrap()
}
pub fn target_os_is_apple() -> bool {
matches!(target_os().as_str(), "ios" | "macos")
}
/// Detect if we're being compiled for a BSD-derived OS, allowing targeting code conditionally with
/// `#[cfg(bsd)]`.
///
/// Rust offers fine-grained conditional compilation per-os for the popular operating systems, but
/// doesn't necessarily include less-popular forks nor does it group them into families more
/// specific than "windows" vs "unix" so we can conditionally compile code for BSD systems.
pub fn target_os_is_bsd() -> bool {
let target_os = target_os();
let is_bsd = target_os.ends_with("bsd") || target_os == "dragonfly";
if matches!(
target_os.as_str(),
"dragonfly" | "freebsd" | "netbsd" | "openbsd"
) {
assert!(is_bsd, "Target incorrectly detected as not BSD!");
}
is_bsd
}
pub fn target_os_is_cygwin() -> bool {
target_os() == "cygwin"
}

View File

@@ -4,6 +4,7 @@ edition.workspace = true
rust-version.workspace = true
version = "0.0.0"
repository.workspace = true
license.workspace = true
[build-dependencies]
fish-build-helper.workspace = true

View File

@@ -1,53 +1,62 @@
#[cfg(not(clippy))]
use std::path::Path;
fn main() {
let mandir = fish_build_helper::fish_build_dir().join("fish-man");
let sec1dir = mandir.join("man1");
// Running `cargo clippy` on a clean build directory panics, because when rust-embed tries to
// embed a directory which does not exist it will panic.
let _ = std::fs::create_dir_all(sec1dir.to_str().unwrap());
#[cfg(not(clippy))]
build_man(&mandir);
let man_dir = fish_build_helper::fish_build_dir().join("fish-man");
let sec1_dir = man_dir.join("man1");
// Running `cargo clippy` on a clean build directory panics, because when rust-embed
// tries to embed a directory which does not exist it will panic.
let _ = std::fs::create_dir_all(&sec1_dir);
if !cfg!(clippy) {
build_man(&man_dir, &sec1_dir);
}
}
#[cfg(not(clippy))]
fn build_man(man_dir: &Path) {
fn build_man(man_dir: &Path, sec1_dir: &Path) {
use fish_build_helper::{env_var, workspace_root};
use std::{
env,
ffi::OsStr,
process::{Command, Stdio},
};
use fish_build_helper::workspace_root;
let workspace_root = workspace_root();
let doc_src_dir = workspace_root.join("doc_src");
let man_str = man_dir.to_str().unwrap();
fish_build_helper::rebuild_if_paths_changed([
&workspace_root.join("CHANGELOG.rst"),
&workspace_root.join("CONTRIBUTING.rst"),
&doc_src_dir,
]);
let sec1_dir = man_dir.join("man1");
let sec1_str = sec1_dir.to_str().unwrap();
let docsrc_dir = workspace_root.join("doc_src");
let docsrc_str = docsrc_dir.to_str().unwrap();
let sphinx_doc_sources = [
workspace_root.join("CHANGELOG.rst"),
workspace_root.join("CONTRIBUTING.rst"),
docsrc_dir.clone(),
];
fish_build_helper::rebuild_if_paths_changed(sphinx_doc_sources);
let args = &[
"-j", "auto", "-q", "-b", "man", "-c", docsrc_str,
// doctree path - put this *above* the man1 dir to exclude it.
// this is ~6M
"-d", man_str, docsrc_str, sec1_str,
];
let _ = std::fs::create_dir_all(sec1_str);
let args: &[&OsStr] = {
fn as_os_str<S: AsRef<OsStr> + ?Sized>(s: &S) -> &OsStr {
s.as_ref()
}
macro_rules! as_os_strs {
( [ $( $x:expr, )* ] ) => {
&[
$( as_os_str($x), )*
]
}
}
as_os_strs!([
"-j",
"auto",
"-q",
"-b",
"man",
"-c",
&doc_src_dir,
// doctree path - put this *above* the man1 dir to exclude it.
// this is ~6M
"-d",
&man_dir,
&doc_src_dir,
&sec1_dir,
])
};
rsconf::rebuild_if_env_changed("FISH_BUILD_DOCS");
if env::var("FISH_BUILD_DOCS") == Ok("0".to_string()) {
if env_var("FISH_BUILD_DOCS") == Some("0".to_string()) {
rsconf::warn!("Skipping man pages because $FISH_BUILD_DOCS is set to 0");
return;
}
@@ -57,18 +66,24 @@ fn build_man(man_dir: &Path) {
// - if we skipped the docs with sphinx not installed, installing it would not then build the docs.
// That means you need to explicitly set $FISH_BUILD_DOCS=0 (`FISH_BUILD_DOCS=0 cargo install --path .`),
// which is unfortunate - but the docs are pretty important because they're also used for --help.
let sphinx_build = match Command::new("sphinx-build")
let sphinx_build = match Command::new(option_env!("FISH_SPHINX").unwrap_or("sphinx-build"))
.args(args)
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
{
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
if env::var("FISH_BUILD_DOCS") == Ok("1".to_string()) {
panic!("Could not find sphinx-build to build man pages.\nInstall sphinx or disable building the docs by setting $FISH_BUILD_DOCS=0.");
if env_var("FISH_BUILD_DOCS") == Some("1".to_string()) {
panic!(
"Could not find sphinx-build required to build man pages.\n\
Install Sphinx or disable building the docs by setting $FISH_BUILD_DOCS=0."
);
}
rsconf::warn!("Cannot find sphinx-build to build man pages.");
rsconf::warn!("If you install it now you need to run `cargo clean` and rebuild, or set $FISH_BUILD_DOCS=1 explicitly.");
rsconf::warn!(
"Could not find sphinx-build required to build man pages. \
If you install Sphinx now, you need to trigger a rebuild to include man pages. \
For example by running `touch doc_src` followed by the build command."
);
return;
}
Err(e) => {

15
crates/common/Cargo.toml Normal file
View File

@@ -0,0 +1,15 @@
[package]
name = "fish-common"
edition.workspace = true
rust-version.workspace = true
version = "0.0.0"
repository.workspace = true
license.workspace = true
[dependencies]
libc.workspace = true
nix.workspace = true
once_cell.workspace = true
[lints]
workspace = true

60
crates/common/src/lib.rs Normal file
View File

@@ -0,0 +1,60 @@
use libc::STDIN_FILENO;
use once_cell::sync::OnceCell;
use std::env;
use std::os::unix::ffi::OsStrExt;
// These are in the Unicode private-use range. We really shouldn't use this
// range but have little choice in the matter given how our lexer/parser works.
// We can't use non-characters for these two ranges because there are only 66 of
// them and we need at least 256 + 64.
//
// If sizeof(wchar_t))==4 we could avoid using private-use chars; however, that
// would result in fish having different behavior on machines with 16 versus 32
// bit wchar_t. It's better that fish behave the same on both types of systems.
//
// Note: We don't use the highest 8 bit range (0xF800 - 0xF8FF) because we know
// of at least one use of a codepoint in that range: the Apple symbol (0xF8FF)
// on Mac OS X. See http://www.unicode.org/faq/private_use.html.
pub const ENCODE_DIRECT_BASE: char = '\u{F600}';
pub const ENCODE_DIRECT_END: char = char_offset(ENCODE_DIRECT_BASE, 256);
pub const fn char_offset(base: char, offset: u32) -> char {
match char::from_u32(base as u32 + offset) {
Some(c) => c,
None => panic!("not a valid char"),
}
}
pub fn subslice_position<T: Eq>(a: &[T], b: &[T]) -> Option<usize> {
if b.is_empty() {
return Some(0);
}
a.windows(b.len()).position(|aw| aw == b)
}
/// This function attempts to distinguish between a console session (at the actual login vty) and a
/// session within a terminal emulator inside a desktop environment or over SSH. Unfortunately
/// there are few values of $TERM that we can interpret as being exclusively console sessions, and
/// most common operating systems do not use them. The value is cached for the duration of the fish
/// session. We err on the side of assuming it's not a console session. This approach isn't
/// bullet-proof and that's OK.
pub fn is_console_session() -> bool {
static IS_CONSOLE_SESSION: OnceCell<bool> = OnceCell::new();
// TODO(terminal-workaround)
*IS_CONSOLE_SESSION.get_or_init(|| {
nix::unistd::ttyname(unsafe { std::os::fd::BorrowedFd::borrow_raw(STDIN_FILENO) })
.is_ok_and(|buf| {
// Check if the tty matches /dev/(console|dcons|tty[uv\d])
let is_console_tty = match buf.as_os_str().as_bytes() {
b"/dev/console" => true,
b"/dev/dcons" => true,
bytes => bytes.strip_prefix(b"/dev/tty").is_some_and(|rest| {
matches!(rest.first(), Some(b'u' | b'v' | b'0'..=b'9'))
}),
};
// and that $TERM is simple, e.g. `xterm` or `vt100`, not `xterm-something` or `sun-color`.
is_console_tty && env::var_os("TERM").is_none_or(|t| !t.as_bytes().contains(&b'-'))
})
})
}

View File

@@ -0,0 +1,22 @@
[package]
name = "fish-fallback"
edition.workspace = true
rust-version.workspace = true
version = "0.0.0"
repository.workspace = true
license.workspace = true
[dependencies]
fish-common.workspace = true
fish-wchar.workspace = true
fish-widecharwidth.workspace = true
libc.workspace = true
once_cell.workspace = true
widestring.workspace = true
[build-dependencies]
fish-build-helper.workspace = true
rsconf.workspace = true
[lints]
workspace = true

5
crates/fallback/build.rs Normal file
View File

@@ -0,0 +1,5 @@
use fish_build_helper::target_os_is_cygwin;
fn main() {
rsconf::declare_cfg("cygwin", target_os_is_cygwin())
}

View File

@@ -3,8 +3,8 @@
//!
//! Many of these functions are more or less broken and incomplete.
use crate::wchar::prelude::*;
use crate::widecharwidth::{WcLookupTable, WcWidth};
use fish_wchar::prelude::*;
use fish_widecharwidth::{WcLookupTable, WcWidth};
use once_cell::sync::Lazy;
use std::cmp;
use std::sync::atomic::{AtomicIsize, Ordering};
@@ -30,8 +30,8 @@
/// A safe wrapper around the system `wcwidth()` function
#[cfg(not(cygwin))]
pub fn wcwidth(c: char) -> isize {
extern "C" {
pub fn wcwidth(c: libc::wchar_t) -> libc::c_int;
unsafe extern "C" {
pub unsafe fn wcwidth(c: libc::wchar_t) -> libc::c_int;
}
const _: () = assert!(std::mem::size_of::<libc::wchar_t>() >= std::mem::size_of::<char>());
@@ -46,7 +46,7 @@ pub fn fish_wcwidth(c: char) -> isize {
// in the console session, but knows nothing about the capabilities of other terminal emulators
// or ttys. Use it from the start only if we are logged in to the physical console.
#[cfg(not(cygwin))]
if crate::common::is_console_session() {
if fish_common::is_console_session() {
return wcwidth(c);
}
@@ -116,21 +116,36 @@ pub fn wcscasecmp(lhs: &wstr, rhs: &wstr) -> cmp::Ordering {
}
/// Compare two wide strings in a case-insensitive fashion
pub fn wcscasecmp_fuzzy(lhs: &wstr, rhs: &wstr, canonicalize: fn(char) -> char) -> cmp::Ordering {
use std::char::ToLowercase;
use widestring::utfstr::CharsUtf32;
pub fn wcscasecmp_fuzzy(
lhs: &wstr,
rhs: &wstr,
extra_canonicalization: fn(char) -> char,
) -> cmp::Ordering {
lowercase(lhs.chars())
.map(extra_canonicalization)
.cmp(lowercase(rhs.chars()).map(extra_canonicalization))
}
/// This struct streams the underlying lowercase chars of a `UTF32String` without allocating.
///
/// `char::to_lowercase()` returns an iterator of chars and we sometimes need to cmp the last
/// char of one char's `to_lowercase()` with the first char of the other char's
/// `to_lowercase()`. This makes that possible.
struct ToLowerBuffer<'a, Canonicalize: Fn(char) -> char> {
pub fn lowercase(chars: impl Iterator<Item = char>) -> impl Iterator<Item = char> {
lowercase_impl(chars, |c| c.to_lowercase())
}
pub fn lowercase_rev(chars: impl DoubleEndedIterator<Item = char>) -> impl Iterator<Item = char> {
lowercase_impl(chars.rev(), |c| c.to_lowercase().rev())
}
fn lowercase_impl<ToLowercase: Iterator<Item = char>>(
chars: impl Iterator<Item = char>,
to_lowercase: fn(char) -> ToLowercase,
) -> impl Iterator<Item = char> {
/// This struct streams the underlying lowercase chars of a string without allocating.
struct ToLowerBuffer<Chars: Iterator<Item = char>, ToLowercase: Iterator<Item = char>> {
to_lowercase: fn(char) -> ToLowercase,
current: ToLowercase,
chars: std::iter::Map<CharsUtf32<'a>, Canonicalize>,
chars: Chars,
}
impl<'a, Canonicalize: Fn(char) -> char> Iterator for ToLowerBuffer<'a, Canonicalize> {
impl<Chars: Iterator<Item = char>, ToLowercase: Iterator<Item = char>> Iterator
for ToLowerBuffer<Chars, ToLowercase>
{
type Item = char;
fn next(&mut self) -> Option<Self::Item> {
@@ -138,45 +153,53 @@ fn next(&mut self) -> Option<Self::Item> {
return Some(c);
}
self.current = self.chars.next()?.to_lowercase();
self.current = (self.to_lowercase)(self.chars.next()?);
self.current.next()
}
}
impl<'a, Canonicalize: Fn(char) -> char> ToLowerBuffer<'a, Canonicalize> {
pub fn new(mut chars: std::iter::Map<CharsUtf32<'a>, Canonicalize>) -> Self {
impl<Chars: Iterator<Item = char>, ToLowercase: Iterator<Item = char>>
ToLowerBuffer<Chars, ToLowercase>
{
pub fn new(mut chars: Chars, to_lowercase: fn(char) -> ToLowercase) -> Self {
Self {
current: chars.next().map(|c| c.to_lowercase()).unwrap_or_else(|| {
let mut empty = 'a'.to_lowercase();
let _ = empty.next();
debug_assert!(empty.next().is_none());
empty
}),
to_lowercase,
current: chars.next().map_or_else(
|| {
let mut empty = to_lowercase('a');
let _ = empty.next();
debug_assert!(empty.next().is_none());
empty
},
to_lowercase,
),
chars,
}
}
}
let lhs = ToLowerBuffer::new(lhs.chars().map(canonicalize));
let rhs = ToLowerBuffer::new(rhs.chars().map(canonicalize));
lhs.cmp(rhs)
ToLowerBuffer::new(chars, to_lowercase)
}
#[test]
fn test_wcscasecmp() {
#[cfg(test)]
mod tests {
use super::wcscasecmp;
use fish_wchar::prelude::*;
use std::cmp::Ordering;
// Comparison with empty
assert_eq!(wcscasecmp(L!("a"), L!("")), Ordering::Greater);
assert_eq!(wcscasecmp(L!(""), L!("a")), Ordering::Less);
assert_eq!(wcscasecmp(L!(""), L!("")), Ordering::Equal);
#[test]
fn test_wcscasecmp() {
// Comparison with empty
assert_eq!(wcscasecmp(L!("a"), L!("")), Ordering::Greater);
assert_eq!(wcscasecmp(L!(""), L!("a")), Ordering::Less);
assert_eq!(wcscasecmp(L!(""), L!("")), Ordering::Equal);
// Basic comparison
assert_eq!(wcscasecmp(L!("A"), L!("a")), Ordering::Equal);
assert_eq!(wcscasecmp(L!("B"), L!("a")), Ordering::Greater);
assert_eq!(wcscasecmp(L!("A"), L!("B")), Ordering::Less);
// Basic comparison
assert_eq!(wcscasecmp(L!("A"), L!("a")), Ordering::Equal);
assert_eq!(wcscasecmp(L!("B"), L!("a")), Ordering::Greater);
assert_eq!(wcscasecmp(L!("A"), L!("B")), Ordering::Less);
// Multi-byte comparison
assert_eq!(wcscasecmp(L!("İ"), L!("i\u{307}")), Ordering::Equal);
assert_eq!(wcscasecmp(L!("ia"), L!("İa")), Ordering::Less);
// Multi-byte comparison
assert_eq!(wcscasecmp(L!("İ"), L!("i\u{307}")), Ordering::Equal);
assert_eq!(wcscasecmp(L!("ia"), L!("İa")), Ordering::Less);
}
}

View File

@@ -4,13 +4,18 @@ edition.workspace = true
rust-version.workspace = true
version = "0.0.0"
repository.workspace = true
license.workspace = true
description = "proc-macro for extracting strings for gettext translation"
[lib]
proc-macro = true
[dependencies]
fish-tempfile.workspace = true
proc-macro2.workspace = true
[build-dependencies]
rsconf.workspace = true
[lints]
workspace = true

View File

@@ -0,0 +1,3 @@
fn main() {
rsconf::rebuild_if_env_changed("FISH_GETTEXT_EXTRACTION_DIR");
}

View File

@@ -1,6 +1,7 @@
extern crate proc_macro;
use fish_tempfile::random_filename;
use proc_macro::TokenStream;
use std::{ffi::OsString, fs::OpenOptions, io::Write};
use std::{ffi::OsString, io::Write, path::PathBuf};
fn unescape_multiline_rust_string(s: String) -> String {
if !s.contains('\n') {
@@ -42,15 +43,14 @@ enum State {
unescaped
}
fn append_po_entry_to_file(message: &TokenStream, file_name: &OsString) {
let mut file = OpenOptions::new()
.create(true)
.append(true)
.open(file_name)
.unwrap_or_else(|e| panic!("Could not open file {file_name:?}: {e}"));
// Each entry is written to a fresh file to avoid race conditions arising when there are multiple
// unsynchronized writers to the same file.
fn write_po_entry_to_file(message: &TokenStream, dir: &OsString) {
let message_string = unescape_multiline_rust_string(message.to_string());
if message_string.contains('\n') {
panic!("Gettext strings may not contain unescaped newlines. Unescaped newline found in '{message_string}'")
panic!(
"Gettext strings may not contain unescaped newlines. Unescaped newline found in '{message_string}'"
)
}
// Crude check for format strings. This might result in false positives.
let format_string_annotation = if message_string.contains('%') {
@@ -59,48 +59,58 @@ fn append_po_entry_to_file(message: &TokenStream, file_name: &OsString) {
""
};
let po_entry = format!("{format_string_annotation}msgid {message_string}\nmsgstr \"\"\n\n");
let dir = PathBuf::from(dir);
let (path, result) =
fish_tempfile::create_file_with_retry(|| dir.join(random_filename(OsString::new())));
let mut file = result.unwrap_or_else(|e| {
panic!("Failed to create temporary file {path:?}:\n{e}");
});
file.write_all(po_entry.as_bytes()).unwrap();
}
/// The `message` is passed through unmodified.
/// If `FISH_GETTEXT_EXTRACTION_FILE` is defined in the environment,
/// this file is used to write the message,
/// If `FISH_GETTEXT_EXTRACTION_DIR` is defined in the environment,
/// the message ID is written into a new file in this directory,
/// so that it can then be used for generating gettext PO files.
/// The `message` must be a string literal.
///
/// # Panics
///
/// This macro panics if the `FISH_GETTEXT_EXTRACTION_FILE` variable is set and `message` has an
/// This macro panics if the `FISH_GETTEXT_EXTRACTION_DIR` variable is set and `message` has an
/// unexpected format.
/// Note that for example `concat!(...)` cannot be passed to this macro, because expansion works
/// outside in, meaning this macro would still see the `concat!` macro invocation, instead of a
/// string literal.
#[proc_macro]
pub fn gettext_extract(message: TokenStream) -> TokenStream {
if let Some(file_path) = std::env::var_os("FISH_GETTEXT_EXTRACTION_FILE") {
if let Some(dir_path) = std::env::var_os("FISH_GETTEXT_EXTRACTION_DIR") {
let pm2_message = proc_macro2::TokenStream::from(message.clone());
let mut token_trees = pm2_message.into_iter();
let first_token = token_trees
.next()
.expect("gettext_extract got empty token stream. Expected one token.");
if token_trees.next().is_some() {
panic!("Invalid number of tokens passed to gettext_extract. Expected one token, but got more.")
panic!(
"Invalid number of tokens passed to gettext_extract. Expected one token, but got more."
)
}
if let proc_macro2::TokenTree::Group(group) = first_token {
let mut group_tokens = group.stream().into_iter();
let first_group_token = group_tokens
.next()
.expect("gettext_extract expected one group token but got none.");
if group_tokens.next().is_some() {
panic!("Invalid number of tokens in group passed to gettext_extract. Expected one token, but got more.")
}
if let proc_macro2::TokenTree::Literal(_) = first_group_token {
append_po_entry_to_file(&message, &file_path);
} else {
panic!("Expected literal in gettext_extract, but got: {first_group_token:?}");
}
} else {
let proc_macro2::TokenTree::Group(group) = first_token else {
panic!("Expected group in gettext_extract, but got: {first_token:?}");
};
let mut group_tokens = group.stream().into_iter();
let first_group_token = group_tokens
.next()
.expect("gettext_extract expected one group token but got none.");
if group_tokens.next().is_some() {
panic!(
"Invalid number of tokens in group passed to gettext_extract. Expected one token, but got more."
)
}
if let proc_macro2::TokenTree::Literal(_) = first_group_token {
write_po_entry_to_file(&message, &dir_path);
} else {
panic!("Expected literal in gettext_extract, but got: {first_group_token:?}");
}
}
message

View File

@@ -4,6 +4,7 @@ edition.workspace = true
rust-version.workspace = true
version = "0.0.0"
repository.workspace = true
license.workspace = true
[dependencies]
phf.workspace = true

View File

@@ -1,16 +1,21 @@
use std::{
env,
ffi::OsStr,
path::{Path, PathBuf},
process::{Command, Stdio},
process::Command,
};
use fish_build_helper::env_var;
fn main() {
let cache_dir =
PathBuf::from(fish_build_helper::fish_build_dir()).join("fish-localization-map-cache");
embed_localizations(&cache_dir);
fish_build_helper::rebuild_if_path_changed(fish_build_helper::workspace_root().join("po"));
fish_build_helper::rebuild_if_path_changed(
fish_build_helper::workspace_root()
.join("localization")
.join("po"),
);
}
fn embed_localizations(cache_dir: &Path) {
@@ -20,40 +25,37 @@ fn embed_localizations(cache_dir: &Path) {
io::{BufWriter, Write},
};
let po_dir = fish_build_helper::workspace_root().join("po");
let po_dir = fish_build_helper::workspace_root()
.join("localization")
.join("po");
// Ensure that the directory is created, because clippy cannot compile the code if the
// directory does not exist.
std::fs::create_dir_all(cache_dir).unwrap();
let localization_map_path =
Path::new(&env::var("OUT_DIR").unwrap()).join("localization_maps.rs");
Path::new(&env_var("OUT_DIR").unwrap()).join("localization_maps.rs");
let mut localization_map_file = BufWriter::new(File::create(&localization_map_path).unwrap());
// This will become a map which maps from language identifiers to maps containing localizations
// for the respective language.
let mut catalogs = phf_codegen::Map::new();
match Command::new("msgfmt")
.arg("-h")
.stdout(Stdio::null())
.status()
{
match Command::new("msgfmt").arg("-h").output() {
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
rsconf::warn!(
"Cannot find msgfmt to build gettext message catalogs. Localization will not work."
);
rsconf::warn!(
"If you install it now you need to trigger a rebuild to get localization support."
);
rsconf::warn!(
"One way to achieve that is running `touch po` followed by the build command."
"Could not find msgfmt required to build message catalogs. \
Localization will not work. \
If you install gettext now, you need to trigger a rebuild to include localization support. \
For example by running `touch localization/po` followed by the build command."
);
}
Err(e) => {
panic!("Error when trying to run `msgfmt -h`: {e:?}");
}
Ok(_) => {
Ok(output) => {
let has_check_format =
String::from_utf8_lossy(&output.stdout).contains("--check-format");
for dir_entry_result in po_dir.read_dir().unwrap() {
let dir_entry = dir_entry_result.unwrap();
let po_file_path = dir_entry.path();
@@ -95,19 +97,32 @@ fn embed_localizations(cache_dir: &Path) {
// Generate the map file.
// Try to create new MO data and load it into `mo_data`.
let output = Command::new("msgfmt")
.arg("--check-format")
.arg("--output-file=-")
let mut tmp_mo_file = None;
let output = {
let mut cmd = &mut Command::new("msgfmt");
if has_check_format {
cmd = cmd.arg("--check-format");
} else {
tmp_mo_file = Some(cache_dir.join("messages.mo"));
};
cmd.arg(format!(
"--output-file={}",
tmp_mo_file
.as_ref()
.map_or("-", |path| path.to_str().unwrap())
))
.arg(&po_file_path)
.output()
.unwrap();
.unwrap()
};
if !output.status.success() {
panic!(
"msgfmt failed:\n{}",
String::from_utf8(output.stderr).unwrap()
);
}
let mo_data = output.stdout;
let mo_data =
tmp_mo_file.map_or(output.stdout, |path| std::fs::read(path).unwrap());
// Extract map from MO data.
let language_localizations = parse_mo_file(&mo_data).unwrap();

View File

@@ -4,6 +4,7 @@ edition.workspace = true
rust-version.workspace = true
version = "0.0.0"
repository.workspace = true
license.workspace = true
[lints]
workspace = true

15
crates/gettext/Cargo.toml Normal file
View File

@@ -0,0 +1,15 @@
[package]
name = "fish-gettext"
edition.workspace = true
rust-version.workspace = true
version = "0.0.0"
repository.workspace = true
license.workspace = true
[dependencies]
fish-gettext-maps.workspace = true
once_cell.workspace = true
phf.workspace = true
[lints]
workspace = true

268
crates/gettext/src/lib.rs Normal file
View File

@@ -0,0 +1,268 @@
use fish_gettext_maps::CATALOGS;
use once_cell::sync::Lazy;
use std::{collections::HashSet, sync::Mutex};
type Catalog = &'static phf::Map<&'static str, &'static str>;
pub struct SetLanguageLints<'a> {
pub duplicates: Vec<&'a str>,
pub non_existing: Vec<&'a str>,
}
#[derive(PartialEq, Eq, Clone, Copy)]
pub enum LanguagePrecedenceOrigin {
Default,
LocaleVariable(LocaleVariable),
LanguageEnvVar,
StatusLanguage,
}
#[derive(PartialEq, Eq, Clone, Copy)]
pub enum LocaleVariable {
#[allow(clippy::upper_case_acronyms)]
LANG,
#[allow(non_camel_case_types)]
LC_MESSAGES,
#[allow(non_camel_case_types)]
LC_ALL,
}
impl LocaleVariable {
fn as_language_precedence_origin(&self) -> LanguagePrecedenceOrigin {
LanguagePrecedenceOrigin::LocaleVariable(*self)
}
pub fn as_str(&self) -> &'static str {
match self {
Self::LANG => "LANG",
Self::LC_MESSAGES => "LC_MESSAGES",
Self::LC_ALL => "LC_ALL",
}
}
}
impl std::fmt::Display for LocaleVariable {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.as_str())
}
}
struct InternalLocalizationState {
precedence_origin: LanguagePrecedenceOrigin,
language_precedence: Vec<(String, Catalog)>,
}
pub struct PublicLocalizationState {
pub precedence_origin: LanguagePrecedenceOrigin,
pub language_precedence: Vec<String>,
}
/// Stores the current localization status.
/// `is_active` indicates whether localization is currently active, and the reason if it is
/// not.
/// The `origin` indicates where the values in `language_precedence` were taken from.
/// `language_precedence` stores the catalogs in the order they should be used.
///
/// This struct should be updated when the relevant variables change or `status language` is used
/// to modify the localization state.
static LOCALIZATION_STATE: Lazy<Mutex<InternalLocalizationState>> =
Lazy::new(|| Mutex::new(InternalLocalizationState::new()));
impl InternalLocalizationState {
fn new() -> Self {
Self {
precedence_origin: LanguagePrecedenceOrigin::Default,
language_precedence: vec![],
}
}
fn to_public(&self) -> PublicLocalizationState {
PublicLocalizationState {
precedence_origin: self.precedence_origin,
language_precedence: self
.language_precedence
.iter()
.map(|(lang, _)| lang.to_owned())
.collect(),
}
}
fn update_from_env(
&mut self,
message_locale: Option<(LocaleVariable, String)>,
language_var: Option<Vec<String>>,
) {
// Do not override values set via `status language`.
if self.precedence_origin == LanguagePrecedenceOrigin::StatusLanguage {
return;
}
if let Some((precedence_origin, locale)) = &message_locale {
// Regular locale names start with lowercase letters (`ll_CC`, followed by some suffix).
// The C or POSIX locale is special, and often used to disable localization.
// Their names are upper-case, but variants with suffixes (`C.UTF-8`) exist.
// To ensure that such variants are accounted for, we match on prefixes of the
// locale name.
// https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap07.html#tag_07_02
fn is_c_locale(locale: &str) -> bool {
locale.starts_with('C') || locale.starts_with("POSIX")
}
if is_c_locale(locale) {
self.precedence_origin =
LanguagePrecedenceOrigin::LocaleVariable(*precedence_origin);
self.language_precedence.clear();
return;
}
}
let (precedence_origin, language_list) = if let Some(list) = language_var {
(LanguagePrecedenceOrigin::LanguageEnvVar, list)
} else if let Some((precedence_origin, locale)) = message_locale {
let mut normalized_name = String::new();
// Strip off encoding and modifier. (We always expect UTF-8 and don't support modifiers.)
for c in locale.chars() {
if c.is_alphabetic() || c == '_' {
normalized_name.push(c);
} else {
break;
}
}
// At this point, the normalized_name should have the shape `ll` or `ll_CC`.
(
precedence_origin.as_language_precedence_origin(),
vec![normalized_name],
)
} else {
(LanguagePrecedenceOrigin::Default, vec![])
};
let mut seen_languages = HashSet::new();
self.language_precedence = language_list
.into_iter()
.flat_map(|lang| find_existing_catalogs(&lang))
.filter(|(lang, _)| seen_languages.insert(lang.to_owned()))
.collect();
self.precedence_origin = precedence_origin;
}
fn update_from_status_language_builtin<'a, 'b: 'a, S: AsRef<str> + 'a>(
&mut self,
langs: &'b [S],
) -> SetLanguageLints<'a> {
let mut seen = HashSet::new();
let mut duplicates = vec![];
for lang in langs {
let lang = lang.as_ref();
if !seen.insert(lang) {
duplicates.push(lang)
}
}
let mut existing_langs = vec![];
let mut non_existing = vec![];
for lang in langs {
let lang = lang.as_ref();
if let Some(catalog) = CATALOGS.get(lang) {
existing_langs.push((lang.to_owned(), *catalog));
} else {
non_existing.push(lang);
}
}
let mut seen = HashSet::new();
let unique_langs = existing_langs
.into_iter()
.filter(|(lang, _)| seen.insert(lang.to_owned()))
.collect();
self.language_precedence = unique_langs;
self.precedence_origin = LanguagePrecedenceOrigin::StatusLanguage;
SetLanguageLints {
duplicates,
non_existing,
}
}
}
/// Tries to find catalogs for `language`.
/// `language` must be an ISO 639 language code, optionally followed by an underscore and an ISO
/// 3166 country/territory code.
/// Uses the catalog with the exact same name as `language` if it exists.
/// If a country code is present (`ll_CC`), only the catalog named `ll` will be considered as a fallback.
/// If no country code is present (`ll`), all catalogs whose names start with `ll_` will be used in
/// arbitrary order.
fn find_existing_catalogs(language: &str) -> Vec<(String, Catalog)> {
// Try the exact name first.
// If there already is a corresponding catalog return the language.
if let Some(catalog) = CATALOGS.get(language) {
return vec![(language.to_owned(), catalog)];
}
let language_without_country_code = language.split_once('_').map_or(language, |(ll, _cc)| ll);
if language == language_without_country_code {
// We have `ll` format. In this case, try to find any catalog whose name starts with `ll_`.
// Note that it is important to include the underscore in the pattern, otherwise `ll` might
// fall back to `llx_CC`, where `llx` is a 3-letter language identifier.
let ll_prefix = format!("{language}_");
let mut lang_catalogs = vec![];
for (&lang_name, &catalog) in CATALOGS.entries() {
if lang_name.starts_with(&ll_prefix) {
lang_catalogs.push((lang_name.to_owned(), catalog));
}
}
lang_catalogs
} else {
// If `language` contained a country code, we only try to fall back to a catalog
// without a country code.
if let Some(catalog) = CATALOGS.get(language_without_country_code) {
vec![(language_without_country_code.to_owned(), catalog)]
} else {
vec![]
}
}
}
pub fn update_from_env(
locale: Option<(LocaleVariable, String)>,
language_var: Option<Vec<String>>,
) {
let mut localization_state = LOCALIZATION_STATE.lock().unwrap();
localization_state.update_from_env(locale, language_var);
}
pub fn update_from_status_language_builtin<'a, 'b: 'a, S: AsRef<str> + 'a>(
langs: &'b [S],
) -> SetLanguageLints<'a> {
let mut localization_state = LOCALIZATION_STATE.lock().unwrap();
localization_state.update_from_status_language_builtin(langs)
}
pub fn unset_from_status_language_builtin(
locale: Option<(LocaleVariable, String)>,
language_var: Option<Vec<String>>,
) {
let mut localization_state = LOCALIZATION_STATE.lock().unwrap();
localization_state.precedence_origin = LanguagePrecedenceOrigin::Default;
localization_state.update_from_env(locale, language_var);
}
pub fn status_language() -> PublicLocalizationState {
let localization_state = LOCALIZATION_STATE.lock().unwrap();
localization_state.to_public()
}
pub fn gettext(message_str: &'static str) -> Option<&'static str> {
let localization_state = LOCALIZATION_STATE.lock().unwrap();
// Use the localization from the highest-precedence language that has one available.
for (_, catalog) in localization_state.language_precedence.iter() {
if let Some(localized_str) = catalog.get(message_str) {
return Some(localized_str);
}
}
None
}
pub fn list_available_languages() -> Vec<&'static str> {
let mut langs: Vec<_> = CATALOGS.entries().map(|(&lang, _)| lang).collect();
langs.sort();
langs
}

View File

@@ -15,7 +15,7 @@ pub enum Arg<'a> {
#[cfg(feature = "widestring")]
WString(WString),
UInt(u64),
SInt(i64, u8), // signed integers track their width as the number of bits
SInt(i64),
Float(f64),
USizeRef(&'a mut usize), // for use with %n
}
@@ -59,7 +59,7 @@ pub fn as_str<'s>(&'s self, storage: &'s mut String) -> Result<&'s str, Error>
pub fn as_uint(&self) -> Result<u64, Error> {
match *self {
Arg::UInt(u) => Ok(u),
Arg::SInt(i, _w) => i.try_into().map_err(|_| Error::Overflow),
Arg::SInt(i) => i.try_into().map_err(|_| Error::Overflow),
_ => Err(Error::BadArgType),
}
}
@@ -68,25 +68,18 @@ pub fn as_uint(&self) -> Result<u64, Error> {
pub fn as_sint(&self) -> Result<i64, Error> {
match *self {
Arg::UInt(u) => u.try_into().map_err(|_| Error::Overflow),
Arg::SInt(i, _w) => Ok(i),
Arg::SInt(i) => Ok(i),
_ => Err(Error::BadArgType),
}
}
// If this is a signed value, then return the sign (true if negative) and the magnitude,
// masked to the value's width. This allows for e.g. -1 to be returned as 0xFF, 0xFFFF, etc.
// depending on the original width.
// If this is an unsigned value, simply return (false, u64).
pub fn as_wrapping_sint(&self) -> Result<(bool, u64), Error> {
/// Unwraps [`Arg::UInt`] to [`u64`].
/// Unwraps [`Arg::SInt`] and casts the [`i64`] to [`u64`].
/// Calling this on other variants of `[Arg]` is an error.
pub fn as_wrapping_sint(&self) -> Result<u64, Error> {
match *self {
Arg::UInt(u) => Ok((false, u)),
Arg::SInt(i, w) => {
// Need to shift twice in case w is 64.
debug_assert!(w > 0);
let mask = ((1u64 << (w - 1)) << 1).wrapping_sub(1);
let ui = (i as u64) & mask;
Ok((i < 0, ui))
}
Arg::UInt(u) => Ok(u),
Arg::SInt(i) => Ok(i as u64),
_ => Err(Error::BadArgType),
}
}
@@ -97,7 +90,7 @@ pub fn as_float(&self) -> Result<f64, Error> {
match *self {
Arg::Float(f) => Ok(f),
Arg::UInt(u) => Ok(u as f64),
Arg::SInt(i, _w) => Ok(i as f64),
Arg::SInt(i) => Ok(i as f64),
_ => Err(Error::BadArgType),
}
}
@@ -181,7 +174,7 @@ macro_rules! impl_to_arg {
$(
impl<'a> ToArg<'a> for $t {
fn to_arg(self) -> Arg<'a> {
Arg::SInt(self as i64, <$t>::BITS as u8)
Arg::SInt(self as i64)
}
}
)*
@@ -211,8 +204,6 @@ mod tests {
#[test]
fn test_to_arg() {
const SIZE_WIDTH: u8 = isize::BITS as u8;
assert!(matches!("test".to_arg(), Arg::Str("test")));
assert!(matches!(String::from("test").to_arg(), Arg::Str(_)));
#[cfg(feature = "widestring")]
@@ -224,17 +215,17 @@ fn test_to_arg() {
assert!(matches!('x'.to_arg(), Arg::UInt(120)));
let mut usize_val: usize = 0;
assert!(matches!((&mut usize_val).to_arg(), Arg::USizeRef(_)));
assert!(matches!(42i8.to_arg(), Arg::SInt(42, 8)));
assert!(matches!(42i16.to_arg(), Arg::SInt(42, 16)));
assert!(matches!(42i32.to_arg(), Arg::SInt(42, 32)));
assert!(matches!(42i64.to_arg(), Arg::SInt(42, 64)));
assert!(matches!(42isize.to_arg(), Arg::SInt(42, SIZE_WIDTH)));
assert!(matches!(42i8.to_arg(), Arg::SInt(42)));
assert!(matches!(42i16.to_arg(), Arg::SInt(42)));
assert!(matches!(42i32.to_arg(), Arg::SInt(42)));
assert!(matches!(42i64.to_arg(), Arg::SInt(42)));
assert!(matches!(42isize.to_arg(), Arg::SInt(42)));
assert_eq!((-42i8).to_arg(), Arg::SInt(-42, 8));
assert_eq!((-42i16).to_arg(), Arg::SInt(-42, 16));
assert_eq!((-42i32).to_arg(), Arg::SInt(-42, 32));
assert_eq!((-42i64).to_arg(), Arg::SInt(-42, 64));
assert_eq!((-42isize).to_arg(), Arg::SInt(-42, SIZE_WIDTH));
assert_eq!((-42i8).to_arg(), Arg::SInt(-42));
assert_eq!((-42i16).to_arg(), Arg::SInt(-42));
assert_eq!((-42i32).to_arg(), Arg::SInt(-42));
assert_eq!((-42i64).to_arg(), Arg::SInt(-42));
assert_eq!((-42isize).to_arg(), Arg::SInt(-42));
assert!(matches!(42u8.to_arg(), Arg::UInt(42)));
assert!(matches!(42u16.to_arg(), Arg::UInt(42)));
@@ -242,7 +233,7 @@ fn test_to_arg() {
assert!(matches!(42u64.to_arg(), Arg::UInt(42)));
assert!(matches!(42usize.to_arg(), Arg::UInt(42)));
let ptr = &42f32 as *const f32;
let ptr = std::ptr::from_ref(&42f32);
assert!(matches!(ptr.to_arg(), Arg::UInt(_)));
}

View File

@@ -3,8 +3,8 @@
mod tests;
use super::locale::Locale;
use super::printf_impl::{pad, ConversionSpec, Error, ModifierFlags};
use decimal::{Decimal, DigitLimit, DIGIT_WIDTH};
use super::printf_impl::{ConversionSpec, Error, ModifierFlags, pad};
use decimal::{DIGIT_WIDTH, Decimal, DigitLimit};
use std::cmp::min;
use std::fmt::Write;
@@ -279,7 +279,6 @@ fn format_a(mut y: f64, params: FormatParams<'_, impl Write>) -> Result<usize, E
// Compute the number of hex digits in the mantissa after the decimal.
// -1 for leading 1 bit (we are to the range [1, 2)), then divide by 4, rounding up.
#[allow(unknown_lints)] // for old clippy
#[allow(clippy::manual_div_ceil)]
const MANTISSA_HEX_DIGITS: usize = (MANTISSA_BITS - 1 + 3) / 4;
if had_prec && prec < MANTISSA_HEX_DIGITS {

View File

@@ -4,9 +4,8 @@
mod fmt_fp;
mod printf_impl;
pub use printf_impl::{sprintf_locale, Error, FormatString};
pub use printf_impl::{Error, FormatString, sprintf_locale};
pub mod locale;
pub use locale::{Locale, C_LOCALE, EN_US_LOCALE};
#[cfg(test)]
mod tests;

View File

@@ -66,11 +66,7 @@ fn next_group_size(&self, digits_left: usize) -> usize {
// Divide remaining digits by repeat_group.
// Apply any remainder to the first group.
let res = (digits_left - accum) % (repeat_group as usize);
if res > 0 {
res
} else {
repeat_group as usize
}
if res > 0 { res } else { repeat_group as usize }
}
}
@@ -122,86 +118,91 @@ pub fn separator_count(&self, digits_count: usize) -> usize {
group_repeat: true,
};
#[test]
fn test_apply_grouping() {
let input = "123456789";
let mut result: String;
#[cfg(test)]
mod tests {
use super::{C_LOCALE, EN_US_LOCALE, Locale};
// en_US has commas.
assert_eq!(EN_US_LOCALE.thousands_sep, Some(','));
result = EN_US_LOCALE.apply_grouping(input);
assert_eq!(result, "123,456,789");
#[test]
fn test_apply_grouping() {
let input = "123456789";
let mut result: String;
// Test weird locales.
let input: &str = "1234567890123456";
let mut locale: Locale = C_LOCALE;
locale.thousands_sep = Some('!');
// en_US has commas.
assert_eq!(EN_US_LOCALE.thousands_sep, Some(','));
result = EN_US_LOCALE.apply_grouping(input);
assert_eq!(result, "123,456,789");
locale.grouping = [5, 3, 1, 0];
locale.group_repeat = false;
result = locale.apply_grouping(input);
assert_eq!(result, "1234567!8!901!23456");
// Test weird locales.
let input: &str = "1234567890123456";
let mut locale: Locale = C_LOCALE;
locale.thousands_sep = Some('!');
// group_repeat doesn't matter because trailing group is 0
locale.grouping = [5, 3, 1, 0];
locale.group_repeat = true;
result = locale.apply_grouping(input);
assert_eq!(result, "1234567!8!901!23456");
locale.grouping = [5, 3, 1, 0];
locale.group_repeat = false;
result = locale.apply_grouping(input);
assert_eq!(result, "1234567!8!901!23456");
locale.grouping = [5, 3, 1, 2];
locale.group_repeat = false;
result = locale.apply_grouping(input);
assert_eq!(result, "12345!67!8!901!23456");
// group_repeat doesn't matter because trailing group is 0
locale.grouping = [5, 3, 1, 0];
locale.group_repeat = true;
result = locale.apply_grouping(input);
assert_eq!(result, "1234567!8!901!23456");
locale.grouping = [5, 3, 1, 2];
locale.group_repeat = true;
result = locale.apply_grouping(input);
assert_eq!(result, "1!23!45!67!8!901!23456");
}
locale.grouping = [5, 3, 1, 2];
locale.group_repeat = false;
result = locale.apply_grouping(input);
assert_eq!(result, "12345!67!8!901!23456");
#[test]
#[should_panic]
fn test_thousands_grouping_length_panics_if_no_sep() {
// We should panic if we try to group with no thousands separator.
assert_eq!(C_LOCALE.thousands_sep, None);
C_LOCALE.apply_grouping("123");
}
#[test]
fn test_thousands_grouping_length() {
fn validate_grouping_length_hint(locale: Locale, mut input: &str) {
loop {
let expected = locale.separator_count(input.len()) + input.len();
let actual = locale.apply_grouping(input).len();
assert_eq!(expected, actual);
if input.is_empty() {
break;
}
input = &input[1..];
}
locale.grouping = [5, 3, 1, 2];
locale.group_repeat = true;
result = locale.apply_grouping(input);
assert_eq!(result, "1!23!45!67!8!901!23456");
}
validate_grouping_length_hint(EN_US_LOCALE, "123456789");
#[test]
#[should_panic]
fn test_thousands_grouping_length_panics_if_no_sep() {
// We should panic if we try to group with no thousands separator.
assert_eq!(C_LOCALE.thousands_sep, None);
C_LOCALE.apply_grouping("123");
}
// Test weird locales.
let input = "1234567890123456";
let mut locale: Locale = C_LOCALE;
locale.thousands_sep = Some('!');
#[test]
fn test_thousands_grouping_length() {
fn validate_grouping_length_hint(locale: Locale, mut input: &str) {
loop {
let expected = locale.separator_count(input.len()) + input.len();
let actual = locale.apply_grouping(input).len();
assert_eq!(expected, actual);
if input.is_empty() {
break;
}
input = &input[1..];
}
}
locale.grouping = [5, 3, 1, 0];
locale.group_repeat = false;
validate_grouping_length_hint(locale, input);
validate_grouping_length_hint(EN_US_LOCALE, "123456789");
// group_repeat doesn't matter because trailing group is 0
locale.grouping = [5, 3, 1, 0];
locale.group_repeat = true;
validate_grouping_length_hint(locale, input);
// Test weird locales.
let input = "1234567890123456";
let mut locale: Locale = C_LOCALE;
locale.thousands_sep = Some('!');
locale.grouping = [5, 3, 1, 2];
locale.group_repeat = false;
validate_grouping_length_hint(locale, input);
locale.grouping = [5, 3, 1, 0];
locale.group_repeat = false;
validate_grouping_length_hint(locale, input);
locale.grouping = [5, 3, 1, 2];
locale.group_repeat = true;
validate_grouping_length_hint(locale, input);
// group_repeat doesn't matter because trailing group is 0
locale.grouping = [5, 3, 1, 0];
locale.group_repeat = true;
validate_grouping_length_hint(locale, input);
locale.grouping = [5, 3, 1, 2];
locale.group_repeat = false;
validate_grouping_length_hint(locale, input);
locale.grouping = [5, 3, 1, 2];
locale.group_repeat = true;
validate_grouping_length_hint(locale, input);
}
}

View File

@@ -472,7 +472,7 @@ pub fn sprintf_locale(
// If someone passes us a negative value, format it with the width
// we were given.
let lower = conv_spec.is_lower();
let (_, uint) = arg.as_wrapping_sint()?;
let uint = arg.as_wrapping_sint()?;
if uint != 0 {
if flags.alt_form {
prefix = if lower { "0x" } else { "0X" };

View File

@@ -1,8 +1,8 @@
use crate::arg::ToArg;
use crate::locale::{Locale, C_LOCALE, EN_US_LOCALE};
use crate::{sprintf_locale, Error, FormatString};
use libc::c_char;
use crate::locale::{C_LOCALE, EN_US_LOCALE, Locale};
use crate::{Error, FormatString, sprintf_locale};
use std::f64::consts::{E, PI, TAU};
use std::ffi::CStr;
use std::fmt;
// sprintf, checking length
@@ -77,7 +77,7 @@ fn write_str(&mut self, _s: &str) -> fmt::Result {
#[test]
fn smoke() {
assert_fmt!("Hello, %s!", "world" => "Hello, world!");
assert_fmt!("Hello, %ls!", "world" => "Hello, world!");
assert_fmt!("Hello, %ls!", "world" => "Hello, world!"); // length modifier
assert_fmt!("Hello, world! %d %%%%", 3 => "Hello, world! 3 %%");
assert_fmt!("" => "");
}
@@ -225,7 +225,7 @@ fn test_int() {
assert_fmt!("%d", -123 => "-123");
assert_fmt!("~%d~", 148 => "~148~");
assert_fmt!("00%dxx", -91232 => "00-91232xx");
assert_fmt!("%x", -9232 => "ffffdbf0");
assert_fmt!("%x", -9232 => "ffffffffffffdbf0");
assert_fmt!("%X", 432 => "1B0");
assert_fmt!("%09X", 432 => "0000001B0");
assert_fmt!("%9X", 432 => " 1B0");
@@ -234,6 +234,7 @@ fn test_int() {
assert_fmt!("%2o", 4 => " 4");
assert_fmt!("% 12d", -4 => " -4");
assert_fmt!("% 12d", 48 => " 48");
// with length modifier
assert_fmt!("%ld", -4_i64 => "-4");
assert_fmt!("%lld", -4_i64 => "-4");
assert_fmt!("%lX", -4_i64 => "FFFFFFFFFFFFFFFC");
@@ -248,6 +249,7 @@ fn test_int() {
assert_fmt!("%9X", 492 => " 1EC");
assert_fmt!("% 12u", 4 => " 4");
assert_fmt!("% 12u", 48 => " 48");
// with length modifier
assert_fmt!("%lu", 4_u64 => "4");
assert_fmt!("%llu", 4_u64 => "4");
assert_fmt!("%lX", 4_u64 => "4");
@@ -414,6 +416,7 @@ fn test_float() {
assert_fmt1!("%f", 0.0, "0.000000");
assert_fmt1!("%g", 0.0, "0");
assert_fmt1!("%#g", 0.0, "0.00000");
// with length modifier
assert_fmt1!("%la", 0.0, "0x0p+0");
assert_fmt1!("%le", 0.0, "0.000000e+00");
assert_fmt1!("%lf", 0.0, "0.000000");
@@ -430,7 +433,7 @@ fn test_float() {
assert_fmt1!("%.4f", 1.03125, "1.0312"); /* 0x1.08p0 */
assert_fmt1!("%.2f", 1.375, "1.38");
assert_fmt1!("%.1f", 1.375, "1.4");
assert_fmt1!("%.1lf", 1.375, "1.4");
assert_fmt1!("%.1lf", 1.375, "1.4"); // length modifier
assert_fmt1!("%.15f", 1.1, "1.100000000000000");
assert_fmt1!("%.16f", 1.1, "1.1000000000000001");
assert_fmt1!("%.17f", 1.1, "1.10000000000000009");
@@ -755,8 +758,8 @@ fn test_errors() {
sprintf_err!("%1", => BadFormatString);
sprintf_err!("%%%k", => BadFormatString);
sprintf_err!("%B", => BadFormatString);
sprintf_err!("%lC", 'q' => BadFormatString);
sprintf_err!("%lS", 'q' => BadFormatString);
sprintf_err!("%lC", 'q' => BadFormatString); // length modifier
sprintf_err!("%lS", 'q' => BadFormatString); // length modifier
sprintf_err!("%d", => MissingArg);
sprintf_err!("%d %u", 1 => MissingArg);
sprintf_err!("%*d", 5 => MissingArg);
@@ -852,25 +855,20 @@ fn test_float_hex_prec() {
// Note that our hex float formatting rounds according to the rounding mode,
// while libc may not; as a result we may differ in the last digit. So this
// requires manual comparison.
let mut c_storage = [0u8; 256];
let c_storage_ptr = c_storage.as_mut_ptr() as *mut c_char;
let mut rust_str = String::with_capacity(256);
let c_fmt = b"%.*a\0".as_ptr() as *const c_char;
let mut c_storage = [0u8; 256];
let mut libc_sprintf = libc_sprintf_one_float_with_precision(&mut c_storage, c"%.*a");
let mut failed = false;
for sign in [1.0, -1.0].into_iter() {
for mut v in [0.0, 0.5, 1.0, 1.5, PI, TAU, E].into_iter() {
v *= sign;
for preci in 1..=200_i32 {
for preci in 1..=200_usize {
rust_str.clear();
crate::sprintf!(=> &mut rust_str, "%.*a", preci, v);
let printf_str = unsafe {
let len = libc::snprintf(c_storage_ptr, c_storage.len(), c_fmt, preci, v);
assert!(len >= 0);
let sl = std::slice::from_raw_parts(c_storage_ptr as *const u8, len as usize);
std::str::from_utf8(sl).unwrap()
};
let printf_str = libc_sprintf(preci, v);
if rust_str != printf_str {
println!(
"Our printf and libc disagree on hex formatting of float: {v}
@@ -886,14 +884,33 @@ fn test_float_hex_prec() {
assert!(!failed);
}
fn test_exhaustive(rust_fmt: &str, c_fmt: *const c_char) {
fn libc_sprintf_one_float_with_precision<'a>(
storage: &'a mut [u8],
fmt: &'a CStr,
) -> impl FnMut(usize, f64) -> &'a str {
|preci, float_val| unsafe {
let storage_ptr = storage.as_mut_ptr();
let len = libc::snprintf(
storage_ptr.cast(),
storage.len(),
fmt.as_ptr(),
preci,
float_val,
);
assert!(len >= 0);
let sl = std::slice::from_raw_parts(storage_ptr, len as usize);
std::str::from_utf8(sl).unwrap()
}
}
fn test_exhaustive(rust_fmt: &str, c_fmt: &CStr) {
// "There's only 4 billion floats so test them all."
// This tests a format string expected to be of the form "%.*g" or "%.*e".
// That is, it takes a precision and a double.
println!("Testing {rust_fmt}");
let mut rust_str = String::with_capacity(128);
let mut c_storage = [0u8; 128];
let c_storage_ptr = c_storage.as_mut_ptr() as *mut c_char;
let mut libc_sprintf = libc_sprintf_one_float_with_precision(&mut c_storage, c_fmt);
for i in 0..=u32::MAX {
if i % 1000000 == 0 {
@@ -905,12 +922,7 @@ fn test_exhaustive(rust_fmt: &str, c_fmt: *const c_char) {
rust_str.clear();
crate::sprintf!(=> &mut rust_str, rust_fmt, preci, ff);
let printf_str = unsafe {
let len = libc::snprintf(c_storage_ptr, c_storage.len(), c_fmt, preci, ff);
assert!(len >= 0);
let sl = std::slice::from_raw_parts(c_storage_ptr as *const u8, len as usize);
std::str::from_utf8(sl).unwrap()
};
let printf_str = libc_sprintf(preci, ff);
if rust_str != printf_str {
println!(
"Rust and libc disagree on formatting float {i:x}: {ff}\n
@@ -929,19 +941,19 @@ fn test_exhaustive(rust_fmt: &str, c_fmt: *const c_char) {
#[ignore]
fn test_float_g_exhaustive() {
// To run: cargo test test_float_g_exhaustive --release -- --ignored --nocapture
test_exhaustive("%.*g", b"%.*g\0".as_ptr() as *const c_char);
test_exhaustive("%.*g", c"%.*g");
}
#[test]
#[ignore]
fn test_float_e_exhaustive() {
// To run: cargo test test_float_e_exhaustive --release -- --ignored --nocapture
test_exhaustive("%.*e", b"%.*e\0".as_ptr() as *const c_char);
test_exhaustive("%.*e", c"%.*e");
}
#[test]
#[ignore]
fn test_float_f_exhaustive() {
// To run: cargo test test_float_f_exhaustive --release -- --ignored --nocapture
test_exhaustive("%.*f", b"%.*f\0".as_ptr() as *const c_char);
test_exhaustive("%.*f", c"%.*f");
}

View File

@@ -0,0 +1,14 @@
[package]
name = "fish-tempfile"
edition.workspace = true
rust-version.workspace = true
version = "0.0.0"
repository.workspace = true
license.workspace = true
[dependencies]
nix = { workspace = true, features = ["fs", "feature"] }
rand.workspace = true
[lints]
workspace = true

171
crates/tempfile/src/lib.rs Normal file
View File

@@ -0,0 +1,171 @@
use std::{
ffi::OsString,
fs::{File, OpenOptions},
io::ErrorKind,
path::PathBuf,
};
use rand::distr::{Alphanumeric, Distribution};
pub struct TempFile {
file: File,
path: PathBuf,
}
impl TempFile {
pub fn get(&self) -> &File {
&self.file
}
pub fn get_mut(&mut self) -> &mut File {
&mut self.file
}
pub fn path(&self) -> &PathBuf {
&self.path
}
}
impl Drop for TempFile {
fn drop(&mut self) {
let _ = std::fs::remove_file(&self.path);
}
}
pub struct TempDir {
path: PathBuf,
}
impl TempDir {
pub fn path(&self) -> &PathBuf {
&self.path
}
}
impl Drop for TempDir {
fn drop(&mut self) {
let _ = std::fs::remove_dir_all(&self.path);
}
}
/// Creates a random filename with the given prefix.
/// Appends a random sequence of alphanumeric ASCII characters.
pub fn random_filename(mut prefix: OsString) -> OsString {
let mut rng = rand::rng();
let suffix_length = 10;
let random_part: String = Alphanumeric
.sample_iter(&mut rng)
.take(suffix_length)
.map(char::from)
.collect();
assert_eq!(random_part.len(), suffix_length);
prefix.push(random_part);
prefix
}
/// Tries to create a new file at the path returned by `generate_path`.
/// If a file already exists at this path, `generate_path` will be called again and file creation
/// will be retried. This is repeated until a new file is created, or an error occurs.
pub fn create_file_with_retry(
generate_path: impl Fn() -> PathBuf,
) -> (PathBuf, std::io::Result<File>) {
loop {
let path = generate_path();
match OpenOptions::new()
.read(true)
.write(true)
.create_new(true)
.open(&path)
{
Ok(file) => {
return (path, Ok(file));
}
Err(e) => {
if e.kind() != ErrorKind::AlreadyExists {
return (path, Err(e));
}
}
}
}
}
/// Tries to create a new temporary file in the operating system's default location for temporary
/// files.
/// On success, a [`TempFile`] is returned.
/// When this struct is dropped, the backing file will be deleted.
pub fn new_file() -> std::io::Result<TempFile> {
let (path, result) = create_file_with_retry(|| {
std::env::temp_dir().join(random_filename(OsString::from("fish_tmp_")))
});
let file = result?;
Ok(TempFile { file, path })
}
/// Tries to create a new temporary directory using `mkdtemp`.
/// On success, a [`TempDir`] is returned.
/// When this struct is dropped, the backing directory, including all its contents, will be deleted.
pub fn new_dir() -> std::io::Result<TempDir> {
let template = std::env::temp_dir().join("fish_tmp_XXXXXX");
let path = nix::unistd::mkdtemp(&template)?;
Ok(TempDir { path })
}
#[cfg(test)]
mod tests {
use std::{
fs::File,
io::{Read, Seek, Write},
};
#[test]
fn create_tempfile() {
super::new_file().unwrap();
}
#[test]
#[should_panic(expected = "file should no longer exist")]
fn use_tempfile() {
let mut tempfile = super::new_file().unwrap();
let expected_content = "test";
{
let file = tempfile.get_mut();
file.write_all(expected_content.as_bytes()).unwrap();
file.seek(std::io::SeekFrom::Start(0)).unwrap();
}
let mut actual_content = String::new();
{
let mut file = tempfile.get();
file.read_to_string(&mut actual_content).unwrap();
}
let path = tempfile.path().to_owned();
drop(tempfile);
assert_eq!(expected_content, actual_content);
File::open(&path).expect("file should no longer exist");
}
#[test]
fn create_tempdir() {
super::new_dir().unwrap();
}
#[test]
#[should_panic(expected = "file should no longer exist")]
fn use_tempdir() {
let tempdir = super::new_dir().unwrap();
let file_path = tempdir.path().join("foo");
let expected_content = "test";
{
let mut file = File::create(&file_path).unwrap();
file.write_all(expected_content.as_bytes()).unwrap();
}
{
let mut file = File::open(&file_path).unwrap();
let mut actual_content = String::new();
file.read_to_string(&mut actual_content).unwrap();
assert_eq!(expected_content, actual_content);
}
drop(tempdir);
File::open(&file_path).expect("file should no longer exist");
}
}

14
crates/wchar/Cargo.toml Normal file
View File

@@ -0,0 +1,14 @@
[package]
name = "fish-wchar"
edition.workspace = true
rust-version.workspace = true
version = "0.0.0"
repository.workspace = true
license.workspace = true
[dependencies]
fish-common.workspace = true
widestring.workspace = true
[lints]
workspace = true

View File

@@ -1,11 +1,51 @@
use std::{iter, slice};
//! Support for wide strings.
//!
//! There are two wide string types that are commonly used:
//! - wstr: a string slice without a nul terminator. Like `&str` but wide chars.
//! - WString: an owning string without a nul terminator. Like `String` but wide chars.
use crate::{
common::subslice_position,
wchar::{wstr, WString},
L,
};
use widestring::utfstr::CharsUtf32;
use fish_common::{ENCODE_DIRECT_BASE, ENCODE_DIRECT_END, subslice_position};
use std::{iter, slice};
pub use widestring::{Utf32Str as wstr, Utf32String as WString, utfstr::CharsUtf32};
pub mod prelude {
pub use crate::{IntoCharIter, L, ToWString, WExt, WString, wstr};
}
/// Creates a wstr string slice, like the "L" prefix of C++.
/// The result is of type wstr.
/// It is NOT nul-terminated.
#[macro_export]
macro_rules! L {
($string:expr) => {
widestring::utf32str!($string)
};
}
/// Encode a literal byte in a UTF-32 character. This is required for e.g. the echo builtin, whose
/// escape sequences can be used to construct raw byte sequences which are then interpreted as e.g.
/// UTF-8 by the terminal. If we were to interpret each of those bytes as a codepoint and encode it
/// as a UTF-32 character, printing them would result in several characters instead of one UTF-8
/// character.
///
/// See <https://github.com/fish-shell/fish-shell/issues/1894>.
pub fn encode_byte_to_char(byte: u8) -> char {
char::from_u32(u32::from(ENCODE_DIRECT_BASE) + u32::from(byte))
.expect("private-use codepoint should be valid char")
}
/// Decode a literal byte from a UTF-32 character.
pub fn decode_byte_from_char(c: char) -> Option<u8> {
if c >= ENCODE_DIRECT_BASE && c < ENCODE_DIRECT_END {
Some(
(u32::from(c) - u32::from(ENCODE_DIRECT_BASE))
.try_into()
.unwrap(),
)
} else {
None
}
}
/// Helpers to convert things to widestring.
/// This is like std::string::ToString.
@@ -56,44 +96,26 @@ fn to_wstring(&self) -> WString {
macro_rules! impl_to_wstring_unsigned {
($($t:ty), *) => {
$(
impl ToWString for $t {
fn to_wstring(&self) -> WString {
to_wstring_impl(*self as u64, false)
impl ToWString for $t {
fn to_wstring(&self) -> WString {
to_wstring_impl(*self as u64, false)
}
}
}
)*
)*
};
}
impl_to_wstring_unsigned!(u8, u16, u32, u64, u128, usize);
#[test]
fn test_to_wstring() {
assert_eq!(0_u64.to_wstring(), "0");
assert_eq!(1_u64.to_wstring(), "1");
assert_eq!(0_i64.to_wstring(), "0");
assert_eq!(1_i64.to_wstring(), "1");
assert_eq!((-1_i64).to_wstring(), "-1");
assert_eq!((-5_i64).to_wstring(), "-5");
let mut val: i64 = 1;
loop {
assert_eq!(val.to_wstring(), val.to_string());
let Some(next) = val.checked_mul(-3) else {
break;
};
val = next;
}
assert_eq!(u64::MAX.to_wstring(), "18446744073709551615");
assert_eq!(i64::MIN.to_wstring(), "-9223372036854775808");
assert_eq!(i64::MAX.to_wstring(), "9223372036854775807");
}
/// A trait for a thing that can produce a double-ended, cloneable
/// iterator of chars.
/// Common implementations include char, &str, &wstr, &WString.
pub trait IntoCharIter {
type Iter: DoubleEndedIterator<Item = char> + Clone;
fn chars(self) -> Self::Iter;
fn extend_wstring(&self, _out: &mut WString) -> bool {
false
}
}
impl IntoCharIter for char {
@@ -110,12 +132,23 @@ fn chars(self) -> Self::Iter {
}
}
impl<'a> IntoCharIter for &'a String {
type Iter = std::str::Chars<'a>;
fn chars(self) -> Self::Iter {
str::chars(self)
}
}
impl<'a> IntoCharIter for &'a [char] {
type Iter = iter::Copied<slice::Iter<'a, char>>;
fn chars(self) -> Self::Iter {
self.iter().copied()
}
fn extend_wstring(&self, out: &mut WString) -> bool {
out.push_utfstr(wstr::from_char_slice(self));
true
}
}
impl<'a> IntoCharIter for &'a wstr {
@@ -123,6 +156,9 @@ impl<'a> IntoCharIter for &'a wstr {
fn chars(self) -> Self::Iter {
wstr::chars(self)
}
fn extend_wstring(&self, out: &mut WString) -> bool {
self.as_char_slice().extend_wstring(out)
}
}
impl<'a> IntoCharIter for &'a WString {
@@ -130,6 +166,9 @@ impl<'a> IntoCharIter for &'a WString {
fn chars(self) -> Self::Iter {
wstr::chars(self)
}
fn extend_wstring(&self, out: &mut WString) -> bool {
self.as_char_slice().extend_wstring(out)
}
}
// Also support `str.chars()` itself.
@@ -148,6 +187,23 @@ fn chars(self) -> Self::Iter {
}
}
impl<'a: 'b, 'b> IntoCharIter for &'b std::borrow::Cow<'a, str> {
type Iter = std::str::Chars<'b>;
fn chars(self) -> Self::Iter {
str::chars(self)
}
}
impl<'a: 'b, 'b> IntoCharIter for &'b std::borrow::Cow<'a, wstr> {
type Iter = CharsUtf32<'b>;
fn chars(self) -> Self::Iter {
wstr::chars(self)
}
fn extend_wstring(&self, out: &mut WString) -> bool {
self.as_char_slice().extend_wstring(out)
}
}
/// Return true if `prefix` is a prefix of `contents`.
fn iter_prefixes_iter<Prefix, Contents>(prefix: Prefix, mut contents: Contents) -> bool
where
@@ -178,10 +234,10 @@ fn next(&mut self) -> Option<Self::Item> {
if let Some(idx) = chars.iter().position(|c| *c == self.split) {
let (prefix, rest) = chars.split_at(idx);
self.chars = Some(&rest[1..]);
return Some(wstr::from_char_slice(prefix));
Some(wstr::from_char_slice(prefix))
} else {
self.chars = None;
return Some(wstr::from_char_slice(chars));
Some(wstr::from_char_slice(chars))
}
}
}
@@ -324,8 +380,28 @@ fn as_char_slice(&self) -> &[char] {
#[cfg(test)]
mod tests {
use super::*;
use crate::wchar::L;
/// Write some tests.
#[test]
fn test_to_wstring() {
assert_eq!(0_u64.to_wstring(), "0");
assert_eq!(1_u64.to_wstring(), "1");
assert_eq!(0_i64.to_wstring(), "0");
assert_eq!(1_i64.to_wstring(), "1");
assert_eq!((-1_i64).to_wstring(), "-1");
assert_eq!((-5_i64).to_wstring(), "-5");
let mut val: i64 = 1;
loop {
assert_eq!(val.to_wstring(), val.to_string());
let Some(next) = val.checked_mul(-3) else {
break;
};
val = next;
}
assert_eq!(u64::MAX.to_wstring(), "18446744073709551615");
assert_eq!(i64::MIN.to_wstring(), "-9223372036854775808");
assert_eq!(i64::MAX.to_wstring(), "9223372036854775807");
}
#[test]
fn test_find_char() {
assert_eq!(Some(0), L!("abc").find_char('a'));

View File

@@ -0,0 +1,10 @@
[package]
name = "fish-widecharwidth"
edition.workspace = true
rust-version.workspace = true
version = "0.0.0"
repository.workspace = true
license = "CC0-1.0"
[lints]
workspace = true

View File

@@ -1,5 +1,5 @@
/**
* widechar_width.rs for Unicode 16.0.0
* widechar_width.rs for Unicode 17.0.0
* See https://github.com/ridiculousfish/widecharwidth/
*
* SHA1 file hashes:
@@ -11,11 +11,11 @@
* The other hashes are simple `sha1sum` style hashes.
* )
*
* generate.py: 2747bb9402d8eeeca8e566ff947f14308511ecb1
* template.js: 7921c1fe6bcb4ce17108929b599bfda097caedb7
* UnicodeData.txt: 91df83276154240bcedef82a09bde77aa182cf8d
* EastAsianWidth.txt: 0885c0fc1c21eb58954a3bfb785d78559b361d92
* emoji-data.txt: 1df2f8329dd9f5c238674807de736f316c6b9d87
* generate.py: b35da43f176cc0d5880c67356ebb064048c5bac4
* template.js: c455e7c973da323c43c98d6975fb8b024bf118f1
* UnicodeData.txt: 50dffef1b7d1f97b72e4c2adceb9b2245f0f34ba
* EastAsianWidth.txt: 2cadc5034b6206ad84b75898a1d4186bb38fc12b
* emoji-data.txt: 3d123e12f70f63e609c4281ce83dfdd9ac7443d2
*/
type R = (u32, u32);
@@ -215,7 +215,8 @@ pub enum WcWidth {
(0x01A55, 0x01A5E),
(0x01A60, 0x01A7C),
(0x01A7F, 0x01A7F),
(0x01AB0, 0x01ACE),
(0x01AB0, 0x01ADD),
(0x01AE0, 0x01AEB),
(0x01B00, 0x01B04),
(0x01B34, 0x01B44),
(0x01B6B, 0x01B73),
@@ -281,7 +282,7 @@ pub enum WcWidth {
(0x10D24, 0x10D27),
(0x10D69, 0x10D6D),
(0x10EAB, 0x10EAC),
(0x10EFC, 0x10EFF),
(0x10EFA, 0x10EFF),
(0x10F46, 0x10F50),
(0x10F82, 0x10F85),
(0x11000, 0x11002),
@@ -343,6 +344,7 @@ pub enum WcWidth {
(0x11A47, 0x11A47),
(0x11A51, 0x11A5B),
(0x11A8A, 0x11A99),
(0x11B60, 0x11B67),
(0x11C2F, 0x11C36),
(0x11C38, 0x11C3F),
(0x11C92, 0x11CA7),
@@ -397,6 +399,10 @@ pub enum WcWidth {
(0x1E2EC, 0x1E2EF),
(0x1E4EC, 0x1E4EF),
(0x1E5EE, 0x1E5EF),
(0x1E6E3, 0x1E6E3),
(0x1E6E6, 0x1E6E6),
(0x1E6EE, 0x1E6EF),
(0x1E6F5, 0x1E6F5),
(0x1E8D0, 0x1E8D6),
(0x1E944, 0x1E94A),
(0xE0100, 0xE01EF),
@@ -434,10 +440,10 @@ pub enum WcWidth {
(0x0FF01, 0x0FF60),
(0x0FFE0, 0x0FFE6),
(0x16FE0, 0x16FE4),
(0x16FF0, 0x16FF1),
(0x17000, 0x187F7),
(0x18800, 0x18CD5),
(0x18CFF, 0x18D08),
(0x16FF0, 0x16FF6),
(0x17000, 0x18CD5),
(0x18CFF, 0x18D1E),
(0x18D80, 0x18DF2),
(0x1AFF0, 0x1AFF3),
(0x1AFF5, 0x1AFFB),
(0x1AFFD, 0x1AFFE),
@@ -461,7 +467,7 @@ pub enum WcWidth {
(0x1F57A, 0x1F57A),
(0x1F5A4, 0x1F5A4),
(0x1F6D1, 0x1F6D2),
(0x1F6D5, 0x1F6D7),
(0x1F6D5, 0x1F6D8),
(0x1F6DC, 0x1F6DF),
(0x1F6F4, 0x1F6FC),
(0x1F7E0, 0x1F7EB),
@@ -473,11 +479,12 @@ pub enum WcWidth {
(0x1F985, 0x1F9BF),
(0x1F9C1, 0x1F9FF),
(0x1FA70, 0x1FA7C),
(0x1FA80, 0x1FA89),
(0x1FA8F, 0x1FAC6),
(0x1FACE, 0x1FADC),
(0x1FADF, 0x1FAE9),
(0x1FAF0, 0x1FAF8),
(0x1FA80, 0x1FA8A),
(0x1FA8E, 0x1FAC6),
(0x1FAC8, 0x1FAC8),
(0x1FACD, 0x1FADC),
(0x1FADF, 0x1FAEA),
(0x1FAEF, 0x1FAF8),
(0x20000, 0x2FFFD),
(0x30000, 0x3FFFD),
];
@@ -688,7 +695,6 @@ pub enum WcWidth {
(0x0085C, 0x0085D),
(0x0085F, 0x0085F),
(0x0086B, 0x0086F),
(0x0088F, 0x0088F),
(0x00892, 0x00896),
(0x00984, 0x00984),
(0x0098D, 0x0098E),
@@ -772,7 +778,7 @@ pub enum WcWidth {
(0x00C49, 0x00C49),
(0x00C4E, 0x00C54),
(0x00C57, 0x00C57),
(0x00C5B, 0x00C5C),
(0x00C5B, 0x00C5B),
(0x00C5E, 0x00C5F),
(0x00C64, 0x00C65),
(0x00C70, 0x00C76),
@@ -784,7 +790,7 @@ pub enum WcWidth {
(0x00CC5, 0x00CC5),
(0x00CC9, 0x00CC9),
(0x00CCE, 0x00CD4),
(0x00CD7, 0x00CDC),
(0x00CD7, 0x00CDB),
(0x00CDF, 0x00CDF),
(0x00CE4, 0x00CE5),
(0x00CF0, 0x00CF0),
@@ -880,7 +886,8 @@ pub enum WcWidth {
(0x01A8A, 0x01A8F),
(0x01A9A, 0x01A9F),
(0x01AAE, 0x01AAF),
(0x01ACF, 0x01AFF),
(0x01ADE, 0x01ADF),
(0x01AEC, 0x01AFF),
(0x01B4D, 0x01B4D),
(0x01BF4, 0x01BFB),
(0x01C38, 0x01C3A),
@@ -909,13 +916,12 @@ pub enum WcWidth {
(0x02072, 0x02073),
(0x0208F, 0x0208F),
(0x0209D, 0x0209F),
(0x020C1, 0x020CF),
(0x020C2, 0x020CF),
(0x020F1, 0x020FF),
(0x0218C, 0x0218F),
(0x0242A, 0x0243F),
(0x0244B, 0x0245F),
(0x02B74, 0x02B75),
(0x02B96, 0x02B96),
(0x02CF4, 0x02CF8),
(0x02D26, 0x02D26),
(0x02D28, 0x02D2C),
@@ -948,10 +954,7 @@ pub enum WcWidth {
(0x0A4C7, 0x0A4CF),
(0x0A62C, 0x0A63F),
(0x0A6F8, 0x0A6FF),
(0x0A7CE, 0x0A7CF),
(0x0A7D2, 0x0A7D2),
(0x0A7D4, 0x0A7D4),
(0x0A7DD, 0x0A7F1),
(0x0A7DD, 0x0A7F0),
(0x0A82D, 0x0A82F),
(0x0A83A, 0x0A83F),
(0x0A878, 0x0A87F),
@@ -988,9 +991,6 @@ pub enum WcWidth {
(0x0FB3F, 0x0FB3F),
(0x0FB42, 0x0FB42),
(0x0FB45, 0x0FB45),
(0x0FBC3, 0x0FBD2),
(0x0FD90, 0x0FD91),
(0x0FDC8, 0x0FDCE),
(0x0FE1A, 0x0FE1F),
(0x0FE53, 0x0FE53),
(0x0FE67, 0x0FE67),
@@ -1060,7 +1060,7 @@ pub enum WcWidth {
(0x108F6, 0x108FA),
(0x1091C, 0x1091E),
(0x1093A, 0x1093E),
(0x10940, 0x1097F),
(0x1095A, 0x1097F),
(0x109B8, 0x109BB),
(0x109D0, 0x109D1),
(0x10A04, 0x10A04),
@@ -1092,7 +1092,8 @@ pub enum WcWidth {
(0x10EAA, 0x10EAA),
(0x10EAE, 0x10EAF),
(0x10EB2, 0x10EC1),
(0x10EC5, 0x10EFB),
(0x10EC8, 0x10ECF),
(0x10ED9, 0x10EF9),
(0x10F28, 0x10F2F),
(0x10F5A, 0x10F6F),
(0x10F8A, 0x10FAF),
@@ -1175,7 +1176,8 @@ pub enum WcWidth {
(0x11A48, 0x11A4F),
(0x11AA3, 0x11AAF),
(0x11AF9, 0x11AFF),
(0x11B0A, 0x11BBF),
(0x11B0A, 0x11B5F),
(0x11B68, 0x11BBF),
(0x11BE2, 0x11BEF),
(0x11BFA, 0x11BFF),
(0x11C09, 0x11C09),
@@ -1197,7 +1199,9 @@ pub enum WcWidth {
(0x11D8F, 0x11D8F),
(0x11D92, 0x11D92),
(0x11D99, 0x11D9F),
(0x11DAA, 0x11EDF),
(0x11DAA, 0x11DAF),
(0x11DDC, 0x11DDF),
(0x11DEA, 0x11EDF),
(0x11EF9, 0x11EFF),
(0x11F11, 0x11F11),
(0x11F3B, 0x11F3D),
@@ -1226,17 +1230,19 @@ pub enum WcWidth {
(0x16B78, 0x16B7C),
(0x16B90, 0x16D3F),
(0x16D7A, 0x16E3F),
(0x16E9B, 0x16EFF),
(0x16E9B, 0x16E9F),
(0x16EB9, 0x16EBA),
(0x16ED4, 0x16EFF),
(0x16F4B, 0x16F4E),
(0x16F88, 0x16F8E),
(0x16FA0, 0x16FDF),
(0x16FE5, 0x16FEF),
(0x16FF2, 0x16FFF),
(0x17001, 0x187F6),
(0x187F8, 0x187FF),
(0x16FF7, 0x16FFF),
(0x17001, 0x187FE),
(0x18CD6, 0x18CFE),
(0x18D01, 0x18D07),
(0x18D09, 0x1AFEF),
(0x18D01, 0x18D1D),
(0x18D1F, 0x18D7F),
(0x18DF3, 0x1AFEF),
(0x1AFF4, 0x1AFF4),
(0x1AFFC, 0x1AFFC),
(0x1AFFF, 0x1AFFF),
@@ -1251,8 +1257,10 @@ pub enum WcWidth {
(0x1BC89, 0x1BC8F),
(0x1BC9A, 0x1BC9B),
(0x1BCA4, 0x1CBFF),
(0x1CCFA, 0x1CCFF),
(0x1CEB4, 0x1CEFF),
(0x1CCFD, 0x1CCFF),
(0x1CEB4, 0x1CEB9),
(0x1CED1, 0x1CEDF),
(0x1CEF1, 0x1CEFF),
(0x1CF2E, 0x1CF2F),
(0x1CF47, 0x1CF4F),
(0x1CFC4, 0x1CFFF),
@@ -1305,7 +1313,10 @@ pub enum WcWidth {
(0x1E300, 0x1E4CF),
(0x1E4FA, 0x1E5CF),
(0x1E5FB, 0x1E5FE),
(0x1E600, 0x1E7DF),
(0x1E600, 0x1E6BF),
(0x1E6DF, 0x1E6DF),
(0x1E6F6, 0x1E6FD),
(0x1E700, 0x1E7DF),
(0x1E7E7, 0x1E7E7),
(0x1E7EC, 0x1E7EC),
(0x1E7EF, 0x1E7EF),
@@ -1363,10 +1374,9 @@ pub enum WcWidth {
(0x1F249, 0x1F24F),
(0x1F252, 0x1F25F),
(0x1F266, 0x1F2FF),
(0x1F6D8, 0x1F6DB),
(0x1F6D9, 0x1F6DB),
(0x1F6ED, 0x1F6EF),
(0x1F6FD, 0x1F6FF),
(0x1F777, 0x1F77A),
(0x1F7DA, 0x1F7DF),
(0x1F7EC, 0x1F7EF),
(0x1F7F1, 0x1F7FF),
@@ -1376,25 +1386,26 @@ pub enum WcWidth {
(0x1F888, 0x1F88F),
(0x1F8AE, 0x1F8AF),
(0x1F8BC, 0x1F8BF),
(0x1F8C2, 0x1F8FF),
(0x1FA54, 0x1FA5F),
(0x1F8C2, 0x1F8CF),
(0x1F8D9, 0x1F8FF),
(0x1FA58, 0x1FA5F),
(0x1FA6E, 0x1FA6F),
(0x1FA7D, 0x1FA7F),
(0x1FA8A, 0x1FA8E),
(0x1FAC7, 0x1FACD),
(0x1FA8B, 0x1FA8D),
(0x1FAC7, 0x1FAC7),
(0x1FAC9, 0x1FACC),
(0x1FADD, 0x1FADE),
(0x1FAEA, 0x1FAEF),
(0x1FAEB, 0x1FAEE),
(0x1FAF9, 0x1FAFF),
(0x1FB93, 0x1FB93),
(0x1FBFA, 0x1FFFD),
(0x1FBFB, 0x1FFFD),
(0x20001, 0x2A6DE),
(0x2A6E0, 0x2A6FF),
(0x2A701, 0x2B738),
(0x2B73A, 0x2B73F),
(0x2A701, 0x2B73E),
(0x2B741, 0x2B81C),
(0x2B81E, 0x2B81F),
(0x2B821, 0x2CEA0),
(0x2CEA2, 0x2CEAF),
(0x2B821, 0x2CEAC),
(0x2CEAE, 0x2CEAF),
(0x2CEB1, 0x2EBDF),
(0x2EBE1, 0x2EBEF),
(0x2EBF1, 0x2EE5C),
@@ -1403,7 +1414,8 @@ pub enum WcWidth {
(0x30001, 0x31349),
(0x3134B, 0x3134F),
(0x31351, 0x323AE),
(0x323B0, 0x3FFFD),
(0x323B1, 0x33478),
(0x3347A, 0x3FFFD),
(0x40000, 0x4FFFD),
(0x50000, 0x5FFFD),
(0x60000, 0x6FFFD),
@@ -1515,7 +1527,7 @@ pub enum WcWidth {
fn in_table(arr: &[R], c: u32) -> bool {
arr.binary_search_by(|(start, end)| {
if c >= *start && c <= *end {
std::cmp::Ordering::Equal
core::cmp::Ordering::Equal
} else {
start.cmp(&c)
}

1
debian/compat vendored
View File

@@ -1 +0,0 @@
12

View File

@@ -6,9 +6,12 @@ allow = [
"BSD-2-Clause",
"BSD-3-Clause",
"BSL-1.0",
"CC0-1.0",
"GPL-2.0",
"GPL-2.0-only",
"ISC",
"LGPL-2.0",
"LGPL-2.0-or-later",
"MIT",
"MPL-2.0",
"PSF-2.0",

View File

@@ -31,7 +31,7 @@ The work will **proceed on master**: no long-lived branches. Tests and CI contin
The Rust code will initially resemble the replaced C++. Fidelity to existing code is more important than Rust idiomaticity, to aid review and bisecting. But don't take this to extremes - use judgement.
The port will proceed "outside in." We'll start with leaf components (e.g. builtins) and proceed towards the core. Some components will have both a Rust and C++ implementation (e.g. FLOG), in other cases we'll change the existing C++ to invoke the new Rust implementations (builtins).
The port will proceed "outside in." We'll start with leaf components (e.g. builtins) and proceed towards the core. Some components will have both a Rust and C++ implementation (e.g. flog), in other cases we'll change the existing C++ to invoke the new Rust implementations (builtins).
After porting the C++, we'll replace CMake.

View File

@@ -18,7 +18,7 @@ We use forks of the last two - see the [FFI section](#ffi) below. No special act
### Build Dependencies
fish-shell currently depends on Rust 1.70 or later. To install Rust, follow https://rustup.rs.
fish-shell currently depends on Rust 1.85 or later. To install Rust, follow https://rustup.rs.
### Build via CMake
@@ -58,7 +58,7 @@ The basic development loop for this port:
- Do this even if it results in less idiomatic Rust, but avoid being super-dogmatic either way.
- One technique is to paste the C++ into the Rust code, commented out, and go line by line.
4. Decide whether any existing C++ callers should invoke the Rust implementation, or whether we should keep the C++ one.
- Utility functions may have both a Rust and C++ implementation. An example is `FLOG` where interop is too hard.
- Utility functions may have both a Rust and C++ implementation. An example is `flog` where interop is too hard.
- Major components (e.g. builtin implementations) should _not_ be duplicated; instead the Rust should call C++ or vice-versa.
5. Remember to run `cargo fmt` and `cargo clippy` to keep the codebase somewhat clean (otherwise CI will fail). If you use rust-analyzer, you can run clippy automatically by setting `rust-analyzer.checkOnSave.command = "clippy"`.
@@ -93,7 +93,7 @@ None of the Rust string types are nul-terminated. We're taking this opportunity
One may create a `&wstr` from a string literal using the `wchar::L!` macro:
```rust
use crate::wchar::prelude::*;
use crate::prelude::*;
// This imports wstr, the L! macro, WString, a ToWString trait that supplies .to_wstring() along with other things
fn get_shell_name() -> &'static wstr {
@@ -116,7 +116,7 @@ fn get_shell_name() -> &'static wstr {
#### The wchar prelude
We have a prelude to make working with these string types a whole lot more ergonomic. In particular `WExt` supplies the null-terminated-compatible `.char_at(usize)`,
and a whole lot more methods that makes porting C++ code easier. It is also preferred to use char-based-methods like `.char_count()` and `.slice_{from,to}()`
and a whole lot more methods that makes porting C++ code easier. It is also preferred to use char-based-methods like `.char_count()` and `.slice_{from,to}()`
of the `WExt` trait over directly calling `.len()` and `[usize..]/[..usize]`, as that makes the code compatible with a potential future change to UTF8-strings.
```rust
@@ -144,7 +144,7 @@ These types should be confined to the FFI modules, in particular `wchar_ffi`. Th
### Format strings
Rust's builtin `std::fmt` modules do not accept runtime-provided format strings, so we mostly won't use them, except perhaps for FLOG / other non-translated text.
Rust's builtin `std::fmt` modules do not accept runtime-provided format strings, so we mostly won't use them, except perhaps for flog / other non-translated text.
Instead we'll continue to use printf-style strings, with a Rust printf implementation.

View File

@@ -1,5 +1,3 @@
.. _cmd-_:
_ - call fish's translations
============================
@@ -25,6 +23,8 @@ If other programs launched via fish should respect these locale variables they h
For :envvar:`LANGUAGE` you can use a list, or use colons to separate multiple languages.
If the :ref:`status language set <status-language>` command was used, its arguments specify the language precedence, and the environment variables are ignored.
Options
-------

View File

@@ -1,5 +1,3 @@
.. _cmd-abbr:
abbr - manage fish abbreviations
================================
@@ -10,8 +8,8 @@ Synopsis
abbr --add NAME [--position command | anywhere] [-r | --regex PATTERN] [-c | --command COMMAND]
[--set-cursor[=MARKER]] ([-f | --function FUNCTION] | EXPANSION)
abbr --erase NAME ...
abbr --rename OLD_WORD NEW_WORD
abbr --erase [ [-c | --command COMMAND]... ] NAME ...
abbr --rename [ [-c | --command COMMAND]... ] OLD_WORD NEW_WORD
abbr --show
abbr --list
abbr --query NAME ...
@@ -48,7 +46,7 @@ Combining these features, it is possible to create custom syntaxes, where a regu
> abbr >> ~/.config/fish/config.fish
> abbr --erase (abbr --list)
Alternatively you can keep them in a separate :ref:`configuration file <configuration>` by doing something like the following::
> abbr > ~/.config/fish/conf.d/myabbrs.fish
@@ -136,9 +134,10 @@ Other subcommands
::
abbr --rename OLD_NAME NEW_NAME
abbr --rename [ [-c | --command COMMAND]... ] OLD_NAME NEW_NAME
Renames an abbreviation, from *OLD_NAME* to *NEW_NAME*
Renames an abbreviation, from *OLD_NAME* to *NEW_NAME*.
For command-specific abbreviations, the ``--command`` options must be provided to disambiguate which abbreviation to rename.
::
@@ -154,9 +153,10 @@ Prints the names of all abbreviation
::
abbr [-e | --erase] NAME
abbr [-e | --erase] [ [-c | --command COMMAND]... ] NAME ...
Erases the abbreviation with the given name
Erases the abbreviation with the given name.
For command-specific abbreviations, the ``--command`` options must be provided to disambiguate which abbreviation to rename.
::

View File

@@ -1,5 +1,3 @@
.. _cmd-alias:
alias - create a function
=========================
@@ -48,12 +46,12 @@ The following code will create ``rmi``, which runs ``rm`` with additional argume
::
alias rmi="rm -i"
# This is equivalent to entering the following function:
function rmi --wraps rm --description 'alias rmi=rm -i'
rm -i $argv
end
``alias`` sometimes requires escaping, as you can see here::
# This needs to have the spaces escaped or "Chrome.app..."

View File

@@ -1,5 +1,3 @@
.. _cmd-and:
and - conditionally execute a command
=====================================

View File

@@ -1,5 +1,3 @@
.. _cmd-argparse:
argparse - parse options passed to a fish script or function
============================================================

View File

@@ -1,5 +1,3 @@
.. _cmd-begin:
begin - start a new block of code
=================================
@@ -35,10 +33,10 @@ The following code sets a number of variables inside of a block scope. Since the
begin
set -l PIRATE Yarrr
...
end
echo $PIRATE
# This will not output anything, since the PIRATE variable
# went out of scope at the end of the block

View File

@@ -1,5 +1,3 @@
.. _cmd-bg:
bg - send jobs to background
============================
@@ -42,6 +40,6 @@ The typical use is to run something, stop it with ctrl-z, and then continue it i
If only 123 and 789 exist, it will still background them and print an error about 456.
``bg 123 banana`` or ``bg banana 123`` will complain that "banana" is not a valid job specifier.
``bg 123 banana`` or ``bg banana 123`` will complain that "banana" is not a valid process ID.
``bg %2`` will background job 2.

View File

@@ -1,5 +1,3 @@
.. _cmd-bind:
bind - handle fish key bindings
===============================
Synopsis
@@ -147,12 +145,17 @@ The following special input functions are available:
``backward-kill-line``
move everything from the beginning of the line to the cursor to the killring
.. _cmd-bind-backward-kill-path-component:
``backward-kill-path-component``
move one path component to the left of the cursor to the killring. A path component is everything likely to belong to a path component, i.e. not any of the following: `/={,}'\":@ |;<>&`, plus newlines and tabs.
``backward-kill-word``
move the word to the left of the cursor to the killring. The "word" here is everything up to punctuation or whitespace.
``backward-path-component``
move one :ref:`path component <cmd-bind-backward-kill-path-component>` to the left.
``backward-word``
move one word to the left
@@ -243,6 +246,9 @@ The following special input functions are available:
commandline, does not accept the current autosuggestion (if any). Does not change the selected item in the completion pager,
if shown.
``forward-path-component``
move one :ref:`path component <cmd-bind-backward-kill-path-component>` to the right; or if at the end of the commandline, accept a path component from the current autosuggestion.
``forward-single-char``
move one character to the right; or if at the end of the commandline, accept a single char from the current autosuggestion.
@@ -310,6 +316,9 @@ The following special input functions are available:
``kill-line``
move everything from the cursor to the end of the line to the killring
``kill-path-component``
move one :ref:`path component <cmd-bind-backward-kill-path-component>` to the killring.
``kill-selection``
move the selected text to the killring

View File

@@ -1,5 +1,3 @@
.. _cmd-block:
block - temporarily block delivery of events
============================================

View File

@@ -1,5 +1,3 @@
.. _cmd-break:
break - stop the current inner loop
===================================

Some files were not shown because too many files have changed in this diff Show More