Compare commits

...

1700 Commits

Author SHA1 Message Date
David Adam
8dbbe71bc6 disable Linux development builds for now
I'll add the rest of the infrastructure later.
2026-04-13 21:12:51 +08:00
David Adam
d9d9eced98 workflow: build development builds on master branch 2026-04-12 21:11:26 +08:00
David Adam
64a829f0df add workflow to create development build source packages 2026-04-12 18:50:56 +08:00
Nahor
440e7fcbc1 Fix failing system tests on Cygwin
The main changes are:
- disabling some checks related to POSIX file permissions when a filesystem is
mounted with "noacl" (default on MSYS2)
- disabling some checks related to symlinks when using fake ones (file copy)

Windows with acl hasn't been tested because 1) Cygwin itself does not have any
Rust package yet to compile fish, and 2) MSYS2 defaults to `noacl`

Part of #12171
2026-04-11 18:55:00 +08:00
Nahor
52495c8124 tests: make realpath tests easier to debug
- Use the different strings for different checks to more easily narrow down
where a failure happens
- Move CHECK comments outside a `if...else...end` to avoid giving the impression
that the check only runs in the `if` case.

Part of #12171
2026-04-11 18:44:22 +08:00
Vishrut Sachan
467b03d715 git completions: prioritize recent commits for rebase --interactive
Fixes #12537

Closes #12619
2026-04-11 18:33:05 +08:00
Johannes Altmanninger
b5c40478f6 Fix typo, closes #12586, closes #12577 2026-04-11 18:33:05 +08:00
Johannes Altmanninger
1286745e78 Remove bits for async-signal-safety of old SIGTERM handler
This is implied by the parent commit.

To enable this, stop trying to run cleanup in panic handlers if we
panic on a background thread.
2026-04-11 18:25:26 +08:00
Yakov Till
b99ae291d6 Save history on SIGTERM and SIGHUP before exit
Previously, SIGTERM immediately re-raised with SIG_DFL, killing
fish without saving history. SIGHUP deferred via a flag but never
re-raised, so the parent saw a normal exit instead of signal death.

Unify both signals: the handler stores the signal number in a single
AtomicI32, the reader loop exits normally, throwing_main() saves
history and re-raises with SIG_DFL so the parent sees WIFSIGNALED.

Fixes #10300

Closes #12615
2026-04-11 18:06:02 +08:00
Daniel Rainer
8ae71c80f4 refactor: extract string escape and unescape funcs
Move the functions for escaping and unescaping strings from
`src/common.rs` into `fish_common`. It might make sense to move them
into a dedicated crate at some point, but for now just move them to the
preexisting crate to unblock other extraction.

Closes #12625
2026-04-11 17:49:50 +08:00
Daniel Rainer
cf6170200c refactor: move const to fish_widestring
Another step to eliminate dependency cycles between `src/expand.rs` and
`src/common.rs`.

Part of #12625
2026-04-11 17:49:49 +08:00
Daniel Rainer
c13038b968 refactor: move move char consts to widestring
This time, move char constants from `src/expand.rs` to
`fish_widestring`, which resolves a dependency cycle between
`src/expand.rs` and `src/common.rs`.

Part of #12625
2026-04-11 17:49:48 +08:00
Daniel Rainer
816077281d refactor: move encoding functions to widestring
The decoding functions for our widestrings are already in the
`fish_widestring` crate, so by symmetry, it makes sense to put the
encoding functions there as well. This also makes it easier to depend on
these functions, giving more options when it comes to further code
extraction.

Part of #12625
2026-04-11 17:49:47 +08:00
Daniel Rainer
78ea24a262 refactor: move char definitions into widestring
Use `fish_widestring` as the place where char definitions live. This has
the advantage that all our code can depend on `fish_widestring` without
introducing dependency cycles. Having a common place for character
definitions also makes it easier to see which chars have a special
meaning assigned to them.

This change also unblocks some follow-up refactoring by removing a
dependency cycle between `src/common.rs` and `src/wildcard.rs`.

Part of #12625
2026-04-11 17:49:46 +08:00
Daniel Rainer
6a5b9bcde1 refactor: move PUA-decoding function to widestring
These functions don't depend on `wcstringutil` functionality, so there
is no need for them to be there. The advantage of putting them into our
`widestring` crate is that quite a lot of code depends on it, and
extracting some of that code would result in crate dependency cycles if
the functions stayed in the `wcstringutil` crate. Our `widestring` crate
does not depend on any of our other crates, so there won't be any cyclic
dependency issues with code in it.

Part of #12625
2026-04-11 17:49:45 +08:00
Daniel Rainer
b7b786aabf cleanup: move escape_string_with_quote
It makes a lot more sense to have this function in the same module as
the other escaping functions. There was no usage of this function in
`parse_util` except for the test, so it makes little sense to keep the
function there. Moving it also eliminates a pointless cyclic dependency
between `common` and `parse_util`.

Part of #12625
2026-04-11 17:49:43 +08:00
Daniel Rainer
dc63b7bb20 cleanup: don't export write_loop twice
Exporting it as both `safe_write_loop` and `write_loop` is redundant and
causes inconsistencies. Remove the `pub use` and use `write_loop` for
the function name. It is shorter, and in Rust the default assumption is
that code is safe unless otherwise indicated, so there is no need to be
explicit about it.

Part of #12625
2026-04-11 17:49:42 +08:00
Daniel Rainer
9c819c020e refactor: don't reexport fish_common in common
Not reexporting means that imports have to change to directly import
from `fish_common`. This makes it easier to see which dependencies on
`src/common.rs` actually remain, which helps with identifying candidates
for extraction.

While at it, group some imports.

Part of #12625
2026-04-11 17:49:41 +08:00
Daniel Rainer
dc9b1141c8 refactor: extract fish_reserved_codepoint
Part of #12625
2026-04-11 17:49:40 +08:00
Daniel Rainer
3d364478ee refactor: remove dep on key mod from common
Removing this dependency allows extracting the `fish_reserved_codepoint`
function, and other code depending on it in subsequent commits.

Part of #12625
2026-04-11 17:49:39 +08:00
Daniel Rainer
faf331fdad refactor: use macro for special key char def
Reduce verbosity of const definitions. Define a dedicated const for the
base of the special key encoding range. This range is 256 bytes wide, so
by defining consts via an u8 offset from the base, we can guarantee that
the consts fall into the allocated range. Ideally, we would also check
for collisions, but Rust's const capabilities don't allow for that as
far as I'm aware.

Having `SPECIAL_KEY_ENCODE_BASE` in the `rust-widestring` crate allows
getting rid of the dependency on `key::Backspace` in the
`fish_reserved_codepoint` function, which unblocks code extraction.

Part of #12625
2026-04-11 17:49:37 +08:00
Daniel Rainer
47b6c0aec2 cleanup: rename and document UTF-8 decoding function
While the function is only used to decode single codepoints, nothing in
its implementation limits it to single codepoints, so the name
`decode_one_codepoint_utf8` is misleading. Change it to the simpler and
more accurate `decode_utf8`. Add a doc comment to describe the
function's behavior.

Part of #12625
2026-04-11 17:49:36 +08:00
Daniel Rainer
eb478bfc3e refactor: remove syntactic deps on main crate
Part of #12625
2026-04-11 17:49:35 +08:00
Johannes Altmanninger
63cf79f5f6 Reuse function for creating sighupint topic monitor 2026-04-11 17:27:25 +08:00
Johannes Altmanninger
ff284d642e tests/checks/tmux-abbr.fish: fix on BusyBox less (alpine CI) 2026-04-11 17:03:46 +08:00
Johannes Altmanninger
cc64da62a9 fish_color_valid_path: also apply bg and underline colors
Closes #12622
2026-04-11 17:03:46 +08:00
Johannes Altmanninger
a974fe990f fish_color_valid_path: respect explicit normal foreground 2026-04-11 17:03:46 +08:00
David Adam
39239724ec make_vendor_tarball: drop unused tar search 2026-04-10 05:56:00 +08:00
Daniel Rainer
524a7bac6e l10n: restore translations from error rewrite
Most translations were adjusted correctly, but a few were missed, so
restore them here.

Closes #12623
2026-04-09 01:36:53 +08:00
Nahor
d649c2aab4 string: remove StringError::NotANumber
Use the more generic `StringError::InvalidArgs` instead

Closes #12556
2026-04-08 14:11:31 +08:00
Nahor
30e6aa85e2 error rewrite: use new Error to report errors
To homogenize error reporting format, use a new Error struct. Currently this
is used for builtins and ensuring a common cmd/subcmd prefix.

Part of #12556
2026-04-08 14:11:31 +08:00
Nahor
abd7442521 printf: de-duplicate code
Part of #12556
2026-04-08 14:05:05 +08:00
Johannes Altmanninger
f5c48038b5 Skip tmux-abbr's "pipe builtin into less" test on BusyBox less
Fails on Alpine CI.
2026-04-08 14:04:15 +08:00
Daniel Rainer
895a6e7034 l10n(fr): use non-breaking space before colon
Closes #12617
2026-04-08 13:54:04 +08:00
Johannes Altmanninger
2193e88423 Pass job group down to builtin_print_help
Repro:

	$ abbr -h | less
	fish: Job 1, 'abbr --help | less' has stopped

Bisects to 5ece9bec6c (__fish_print_help: use man as-is, 2025-08-29).

Root cause is similar to
https://github.com/fish-shell/fish-shell/issues/8699#issuecomment-1030762748
except it's specific to how __fish_print_help is invoked, since
"__fish_print_help abbr | less" works fine.

Fix this by letting __fish_print_help access the terminal.

Fixes #12612

Solved by Claude in a single prompt:

---

 ▐▛███▜▌   Claude Code v2.1.92
▝▜█████▛▘  Sonnet 4.6
  ▘▘ ▝▝    ~/git/fish-shell

❯ "abbr -h | less" gets a signal, resulting in the message "fish: Job 1, 'abbr -h | less' has stopped"
whereas "__fish_print_help abbr | less" works just fine, even though "abbr -h" should run exactly that.
Why this difference?

[...]

● Now I can give you a clear answer.

  ---
  The difference comes down to job group inheritance when man is
  spawned.

  The deferred execution order

  In abbr -h | less, fish uses the "deferred process" optimization:
  since abbr is a non-external process piping into an external one,
  fish launches less first,
   transfers the terminal to less's process group, then runs the
   deferred abbr builtin. By the time abbr's help function spawns man,
   the terminal already
  belongs to less's pgroup.

  Same thing happens with __fish_print_help abbr | less — the outer
  less is launched first and gets the terminal.

  Where the paths diverge

  Function case (__fish_print_help abbr | less):
  get_performer_for_function (exec.rs:1050) captures job.group.clone()
  and passes it to eval_node. So when command man runs inside the
  function, it's given the outer pipeline's job group — the same
  one that owns the terminal. man's inner less pager joins that group
  and can read from the terminal freely. ✓

  Builtin case (abbr -h | less): builtin_print_help calls
  parser.eval(&cmd, streams.io_chain) (shared.rs:652). parser.eval
  is defined as:

  pub fn eval(&self, cmd: &wstr, io: &IoChain) -> EvalRes {
      self.eval_with(cmd, io, None, BlockType::top, false)
      //                      ^^^^ job_group = None
  }

  job_group = None means man creates a brand-new job group with no
  terminal access. When man spawns its less pager, the pager tries
  to read keyboard input from
   the terminal, but the terminal belongs to the outer less's process
   group. The pager receives SIGTTIN → stops → the whole job is
   reported as stopped.

  The fix

  builtin_print_help should pass streams.job_group to the eval call
  (which is already populated at exec.rs:1192). Changing line 652 from:

  let res = parser.eval(&cmd, streams.io_chain);

  to:

  let res = parser.eval_with(&cmd, streams.io_chain, streams.job_group.as_ref(), BlockType::top, false);

  would give man the outer job's job group, letting its pager access
  the terminal just like the function case.

✻ Sautéed for 13m 0s
2026-04-07 20:21:38 +08:00
Kayce Basques
86c3778c2a docs: Format path as inline code
Closes #12609
2026-04-07 18:52:36 +08:00
Nahor
d2653b7cac tmux-set.fish: fix spurious CI failure
Part of #12556
2026-04-07 17:49:57 +08:00
Johannes Altmanninger
cf16949ce7 contrib/debian/control: remove insufficient mdoc dependency
On Debian, mandoc provides "/usr/bin/mman", not "/usr/bin/man", so that
package alone is not enough.  Users that want to use mandoc could use a
package that "Provides: man", for example by creating symlink to "mman".

See https://github.com/fish-shell/fish-shell/issues/12596#issuecomment-4188332803
2026-04-07 17:49:57 +08:00
Daniel Rainer
85311546de refactor: extract fish-feature-flags crate
Another step in splitting up the main library crate.

Note that this change requires removing the `#[cfg(test)]` annotations
around the `LOCAL_OVERRIDE_STACK` code, because otherwise the code would
be removed in test builds for other packages, making the `#[cfg(test)]`
functions unusable from other packages, and functions with such feature
gates in their body would have the code guarded by these gates removed
in test builds for tests in other packages.

Closes #12494
2026-04-07 17:49:57 +08:00
Daniel Rainer
c44aa32a15 cleanup: remove syntactic dependency on main crate
This is done in preparation for extracting this file into its own crate.

Part of #12494
2026-04-07 17:49:57 +08:00
Daniel Rainer
65bc9b9e3e refactor: stop aliasing feature_test function
Having a public function named `test` is quite unspecific. Exporting it
both as `test` and `feature_test` results in inconsistent usage. Fix
this by renaming the function to `feature_test` and removing the alias.

Part of #12494
2026-04-07 17:49:57 +08:00
Daniel Rainer
8125f78a84 refactor: use override stack for feature tests
Several features of fish can be toggled at runtime (in practice at
startup). To keep track of the active features, `FEATURES`, an array of
`AtomicBool` is used. This can safely be shared across threads without
requiring locks.

Some of our tests override certain features to test behavior with a
specific value of the feature. Prior to this commit, they did this by
using thread-local versions of `FEATURES` instead of the process-wide
version used in non-test builds. This approach has two downsides:
- It does not allow nested overrides.
- It prevents using the code across package boundaries.
The former is a fairly minor issue, since I don't think we need nested
overrides. The latter prevents splitting up our large library crate,
since `#[cfg(test)]`-guarded code can only be used within a single
package.

To resolve these issues, a new approach to feature overrides in
tests is introduced in this commit: Instead of having a thread-local
version of `FEATURES`, all code, whether test or not, uses the
process-wide `FEATURES`. For non-test code, there is no change. For test
code, `FEATURES` is now also used. To override features in tests, a new
`with_overridden_feature` function is added, which replaces
`scoped_test` and `set`. It works by maintaining a thread-local stack of
feature overrides (`LOCAL_OVERRIDE_STACK`). The overridden `FeatureFlag`
and its new value are pushed to the stack, then the code for which the
override should be active is run, and finally the stack is popped again.
Feature tests now have to scan the stack for the first appearance of the
`FeatureFlag`, or use the value in `FEATURES` if the stack does not
contain the `FeatureFlag`. In most cases, the stack will be empty or
contain very few elements, so scanning it should not take long. For now,
it's only active in test code, so non-test code is unaffected. The plan
is to change this when the feature flag code is extracted from the main
library crate. This would slightly slow down feature tests in non-test
code, but there the stack will always be empty, since we only override
features in tests.

Part of #12494
2026-04-07 17:49:57 +08:00
Daniel Rainer
f0f48b4859 cleanup: stop needlessly exporting struct fields
Part of #12494
2026-04-07 17:49:57 +08:00
David Adam
a009f87630 build_tools: add sh script to build linux packages 2026-04-07 10:57:41 +08:00
David Adam
edb66d4d4e remove dput_cf_gen, not actually helpful 2026-04-07 10:57:41 +08:00
Nahor
f3f675b4cc Standardized error messages: constant names
Part of #12556
2026-04-05 13:15:47 +08:00
Nahor
434610494f argparse: fix error status code
To homogenize error reporting format, use a new Error struct. Currently this
is used for builtins and ensuring a common cmd/subcmd prefix.

Part of #12556
2026-04-05 13:15:47 +08:00
Dennis Yildirim
3cce1f3f4c Added completions for git verify-commit and verify-tag
Closes #12607
2026-04-05 13:14:31 +08:00
Johannes Altmanninger
a5bde7954e Update changelog 2026-04-05 13:07:29 +08:00
Nahor
99d63c21f1 Add tests to exercise all builtin error messages
With a few exceptions, only one test is added for a given message, even
when there are multiple ways to trigger the same message (e.g. different
invalid option combinations, or triggered in shared functions such as
`builtin_unknown_option`)

Includes a few very minor fixes, such as missing a newline, or using the
wrong var name.

Closes #12603
2026-04-05 00:22:42 +08:00
Nahor
c3e3658157 ulimit: remove unreachable error message
When there is no limit value, ulimit will have printed the current one
and exited

Part of #12603
2026-04-05 00:22:41 +08:00
Nahor
8d92016e72 string: error messages fixes
- fix wrong pattern used in `string replace` error message
- replace unreachable error with `unreachable!` in `string`
- fix cmd being used in place of subcmd 

Part of #12603
2026-04-05 00:22:41 +08:00
Nahor
f6a72b4e19 status: replace unreachable code with an assert!
Part of #12603
2026-04-05 00:22:40 +08:00
Nahor
2f9c2df10d set: report an error when called with -a,-p and no NAME
Previously executing `set -a` or `set -p` would just list all the
variables, which does not make sense since the user specifically ask
for an action (append/prepend).

Update the help page synopsis

Part of #12603
2026-04-05 00:22:40 +08:00
Johannes Altmanninger
0367aaea7d Disable relocatable tree logic when DATADIR or SYSCONFDIR are non-default
If all of

	$PREFIX/bin/fish
	$PREFIX/share/fish
	$PREFIX/etc/fish

exist, then fish assumes it's in a relocatable directory tree.
This is used by homebrew (PREFIX=/usr/local) and maybe also nix(?).

Other Linux distros prefer to use /etc/fish instead of $PREFIX/etc/fish
[1].  To do so, they need to pass -DCMAKE_INSTALL_SYSCONFDIR=/etc.
The relocatable tree logic assumes default data and sysconf dirs
(relative to a potentially relocatable prefix). If the user changes
any of those, and the relocatable tree logic happens to kick in,
that'd overrule user preference, which is surprising.

So a non-default data or sysconf path is a strong enough signal that
we want to disable the relocatable tree logic. Do that.

Closes #10748

[1]: ff2f69cd56/PKGBUILD (L43)
2026-04-04 01:22:54 +08:00
Johannes Altmanninger
e25b4b6f05 tests/checks/realpath.fish: fix on macOS 2026-04-03 23:26:37 +08:00
Yakov Till
90cbfd288e Fix test_history_path_detection panic: call test_init()
test_history_path_detection calls add_pending_with_file_detection(),
which spawns a thread pool task via ThreadPool::perform(). This
requires threads::init() to have been called, otherwise
assert_is_background_thread() panics.

Add the missing test_init() call, matching other tests that use
subsystems requiring initialization.

Closes #12604
2026-04-03 14:48:53 +08:00
Nahor
68453843d4 set: fix unreachable error messages
- Remove unreachable error message in `handle_env_return()`
While we could have put an empty block in `handle_env_return()` and
removed the condition on `NotFound` in `erase()`, we prefered to use
`unreachable!` in case `handle_env_return()` gets called in new scenarios
in the future

- Make reachable the error message when asking to show a slice

Part of #12603
2026-04-03 13:53:42 +08:00
Nahor
fb57f95391 realpath: fix random error message
With empty argument, `realpath` skips all processing, so the error
message, based on `errno`, was unrelated and changed depending on what
failed before. E.g:

```
$ builtin realpath "" /tmp "" /no-exist ""
builtin realpath: : Resource temporarily unavailable
/tmp
builtin realpath: : Invalid argument
/dont-exist
builtin realpath: : No such file or directory
```

Part of #12603
2026-04-03 13:53:41 +08:00
Nahor
1ed276292b read: remove unnecessary code
`to_stdout` is set to `true` if and only if `argv` is not empty.
- `argv` length and `to_stdout` are redundant, so we can remove `to_stdout`
- some tests in `validate_read_args` are necessarily false

Part of #12603
2026-04-03 13:53:41 +08:00
Branch Vincent
09e46b00cc completions: update ngrok
Closes #12598
2026-04-03 13:53:41 +08:00
Johannes Altmanninger
695bc293a9 contrib/debian/control: allow any "man" virtual pkg (man-db/mandoc)
We support multiple "man" implementations; at least man-db's and
mandoc's.

So we can relax the mandoc dependency to a dependency on the virtual
package providing "man". Note that as of today, "mandoc" fails to
have a "Provides: man".

However since Debian policy says in
https://www.debian.org/doc/debian-policy/ch-relationships.html

> To specify which of a set of real packages should be the default
> to satisfy a particular dependency on a virtual package, list the
> real package as an alternative before the virtual one.

we want to list possible real packages anyway, so do that.

Closes #12596
2026-04-03 12:20:08 +08:00
Nahor
344ff7be88 printf: remove unreachable code
Remove an unreachable, yet translated, error string and make the code
more idiomatic

Closes #12594
2026-04-01 09:37:57 +08:00
Nahor
014e3b3aff math: fix error message
Fix badly formatted error message, and make it translatable

Part of #12594
2026-04-01 09:37:57 +08:00
Nahor
68c7baff90 read: remove deprecation error for -i
`-i` has been an error and undocumented for 8 years now (86362e7) but
still requires some translating today. Time to retire it fully.

Part of #12594
2026-04-01 09:37:56 +08:00
Johannes Altmanninger
6eaad2cd80 Remove some redundant translation sources 2026-03-31 14:55:04 +08:00
Johannes Altmanninger
b321e38f5a psub: add missing line endings to error messages
Fixes #12593
2026-03-31 14:43:34 +08:00
Daniel Rainer
a32dd63163 fix: simplify and correct trimming of features
The previous handling was unnecessarily complex and had a bug introduced
by porting from C++ to Rust: The substrings `\0x0B` and `\0x0C` in Rust
mean `\0` (the NUL character) followed by the regular characters `0B`
and `0C`, respectively, so feature names starting or ending with these
characters would have these characters stripped away.

Replace this handling by built-in functionality, and simplify some
syntax. We now trim all whitespace, instead of just certain ASCII
characters, but I think there is no reason to limit trimming to ASCII.

Closes #12592
2026-03-31 14:43:34 +08:00
Bacal Mesfin
ef90afa5b9 feat: add completions for dnf copr
Closes #12585
2026-03-31 14:43:34 +08:00
r-vdp
7bd37dfe55 create_manpage_completions: handle groff \X'...' device control escapes
help2man 1.50 added \X'tty: link URL' hyperlink escapes to generated
man pages. coreutils 9.10 is the first widely-deployed package to ship
these, and it broke completion generation for most of its commands
(only 17/106 man pages parsed successfully).

The escape wraps option text like this:

  \X'tty: link https://example.com/a'\fB\-a, \-\-all\fP\X'tty: link'

Two places needed fixing:

- remove_groff_formatting() didn't strip \X'...', so Type1-4 parsers
  extracted garbage option names like "--all\X'tty"

- Deroffer.esc_char_backslash() didn't recognize \X, falling through
  to the generic single-char escape which stripped only the \, leaving
  "X'tty: link ...'" as literal text. Option lines then started with
  X instead of -, so TypeDeroffManParser's is_option() check failed.

Also handle \Z'...' (zero-width string) which has identical syntax.

Closes #12578
2026-03-31 13:15:52 +08:00
Johannes Altmanninger
14ce56d2a5 Remove unused fish_wcwidth wrapper 2026-03-30 13:57:27 +08:00
Johannes Altmanninger
01ee6f968d Support backward-word-end when cursor is past end
Closes #12581
2026-03-30 13:57:27 +08:00
Johannes Altmanninger
7f6dcde5e0 Fix backward-delete-char not stopping after control characters
Fixes 146384abc6 (Stop using wcwidth entirely, 2026-03-15)

Fixes #12583
2026-03-30 13:57:27 +08:00
Johannes Altmanninger
34fc573668 Modernize wcwidth API
Return None rather than -1 for nonprintables.  We probably still
differ from wcwidth which is bad (given we use the same name), but
hopefully not in a way that matters.

Fixes 146384abc6 (Stop using wcwidth entirely, 2026-03-15).
2026-03-30 13:57:10 +08:00
Johannes Altmanninger
93cbf2a0e8 Reuse wcswidth logic for rendered characters 2026-03-29 17:04:14 +08:00
Nahor
8194c6eb79 cd: replace unreachable code with assert
Closes #12584
2026-03-29 16:49:24 +08:00
Nahor
3194572156 bind: replace fake enum (c_int) with a real Rust enum
Part of #12584
2026-03-29 16:49:24 +08:00
Johannes Altmanninger
e635816b7f Fix Vi mode dl deleting from wrong character
Fixes b9b32ad157 (Fix vi mode dl and dh regressions, 2026-02-25).

Closes #12580
(which describes only the issue already fixed by b9b32ad157).
2026-03-28 21:45:33 +08:00
Johannes Altmanninger
2b3ecf22da start new cycle
Created by ./build_tools/release.sh 4.6.0
2026-03-28 13:16:34 +08:00
Johannes Altmanninger
c7ecc3bd78 Release 4.6.0
Created by ./build_tools/release.sh 4.6.0
2026-03-28 12:56:37 +08:00
Johannes Altmanninger
828a20ef30 Use cfg!(apple) 2026-03-28 12:41:58 +08:00
Fabian Boehm
7f5692dfd3 Skip ttyname on apple systems
Not relevant there because they don't have a "console session" as
such, and the ttyname call may hang.

Fixes #12506
2026-03-27 17:36:08 +01:00
Fabian Boehm
454939d5ab Update docs for fish_emoji_width defaulting to 2 2026-03-27 16:23:30 +01:00
Johannes Altmanninger
8756bc3afb Update changelog 2026-03-27 22:24:03 +08:00
Johannes Altmanninger
272f5dda83 Revert "CI: disable failing ubuntu-asan job"
This reverts commit 23ce9de1c3.

The compilation failure on Rust nightly was fixed in rust-shellexpand
commit b6173f0 (Rename WstrExt and WstrRefExt methods, 2026-02-23).
2026-03-27 22:23:08 +08:00
Johannes Altmanninger
dde33bab7e Clean up word-end special case handling in forward-word 2026-03-27 22:22:29 +08:00
David Adam
63f642c9dd CHANGELOG: log #12562 2026-03-27 22:21:08 +08:00
Fabian Boehm
146384abc6 Stop using wcwidth entirely
wcwidth isn't a great idea - it returns "-1" for anything it doesn't
know and non-printables, which can easily break text.

It is also unclear that it would be accurate to the system console,
and that's a minority use-case over using ssh to access older systems.

Additionally, it means we use one less function from libc and
simplifies the code.

Closes #12562
2026-03-27 21:31:19 +08:00
Fabian Boehm
8561008513 Unconditionally default emoji width to 2
"Emoji width" refers to the width of emoji codepoints. Since Unicode
9, they're classified as "wide" according to
TR11 (https://www.unicode.org/reports/tr11/).

Unicode 9 was released in 2016, and this slowly percolated into C
libraries and terminals. Glibc updated its default in 2.26, released
in August 2017.

Until now, we'd guess support for unicode 9 by checking the system
wcwidth function for an emoji - if it returned 2, we'd set our emoji
width to 2 as well.

However, that's a problem in the common case of using ssh to connect
to an old server - modern desktop OS, old server LTS OS, boom.

So now we instead just figure you've got a system that's *displaying*
the emoji that has been updated in the last 9 years.

In effect we're putting the burden on those who run old RHEL et al as
their client OS. They need to set $fish_emoji_width to 1.

Fixes #12500

Part of #12562
2026-03-27 21:31:19 +08:00
Remo Senekowitsch
88d01f7eb8 completions/cargo: avoid auto-installing toolchain via rustup
When cargo is installed via rustup, running cargo actually goes through
a proxy managed by rustup. This proxy determines the actual toolchain
to use, depending on environment variables, directory overrides etc. In
some cases, the proxy may automatically install the selected toolchain
if it's not yet installed, for example when first working on a project
that pins its rust toolchain via a `rust-toolchain.toml` file. In that
case, running cargo in the completion script can block the prompt for
a very long time. To avoid this, we instruct the rustup proxy not to
auto-install any toolchain with an environment variable.

Closes #12575
2026-03-27 20:11:22 +08:00
rohan436
4467822f6e docs: fix typo in MANPATH guidance string
Closes #12574
2026-03-27 18:55:38 +08:00
Johannes Altmanninger
5fe1cfb895 Bump initial Primary DA query timeout
Commit 7ef4e7dfe7 (Time out terminal queries after a while,
2025-09-21) though that "2 seconds ought to be enough for anyone".
But that's not true in practice: when rebooting a macOS system, it
can take longer. Let's see if 10 seconds is enough.  It should be fine
to have such a high timeout since this shouldn't happen in other cases.

Closes #12571
2026-03-26 16:31:24 +08:00
Daan De Meyer
484032fa9e Support SHELL_PROMPT_PREFIX, SHELL_PROMPT_SUFFIX, and SHELL_WELCOME
Add support for the SHELL_PROMPT_PREFIX, SHELL_PROMPT_SUFFIX, and
SHELL_WELCOME environment variables as standardized by systemd v257.

SHELL_PROMPT_PREFIX and SHELL_PROMPT_SUFFIX are automatically prepended
and appended to the left prompt at the shell level, so all prompts
(default, custom, and sample) pick them up without modification.

SHELL_WELCOME is displayed after the greeting when an interactive shell
starts.

These variables provide a standard interface for tools like systemd's
run0 to communicate session context to the shell.

Fixes https://github.com/fish-shell/fish-shell/issues/10924

Closes #12570
2026-03-26 15:45:50 +08:00
Johannes Altmanninger
fdd10ba9b2 Fix forward-word regression on single-char words followed by punctuation
The `forward-word` readline command on "a-a-a" is wrong (jumps to
"a"); on "aa-aa-aa" it's right (jumps to "-"); that's a regression
from bbb2f0de8d (feat(vi-mode): make word movements vi-compliant,
2026-01-10).

The is_word_end check for ForwardWordEmacs only tests for blank
(whitespace) after the current char. In the Punctuation style, words
also end before punctuation.

Fix this.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

See https://github.com/fish-shell/fish-shell/issues/12543#issuecomment-4125223455
2026-03-26 15:31:00 +08:00
Nahor
8679464689 color: prefer set_color --reset over set_color normal
`set_color normal` is too ambiguous and easily misinterpreted since
it actually reset all colors and modes instead of resetting just
the foreground color as one without prior knowledge might expect.

Closes #12548
2026-03-25 21:53:05 +08:00
Rodolfo Gatti
9ea760c401 Accept |& as an alias for &|
Closes #12565
2026-03-25 21:53:05 +08:00
Steffen Winter
d36c53c6e2 functions: dynamically query gentoo system paths
Use portageq to retrieve system paths instead of hardcoding them in.
This helps especially in Gentoo Prefix, where the installation is not
in / but rather offset inside a subdirectory (usually a users home
directory).

This only affects the "slow" path. When eix is installed it will be used
instead. It already accounts for Prefix installations.

Closes #12552
2026-03-25 21:53:05 +08:00
Steffen Winter
b047450cd0 functions: enable eix fast path for gentoo packages
The idea is taken from the deprecated/unused __fish_print_portage_packages.

Part of #12552
2026-03-25 21:53:05 +08:00
Johannes Altmanninger
0b93989080 fix ProcStatus::status_value in pipeline after ctrl-z
Repro (with default prompt):

	$ HOME=$PWD target/debug/fish -C '
	  function sleep_func; sleep 1; false; end
	  commandline "sleep 2 | sleep 3 | sleep 4 | sleep_func"
	  '
	Welcome to fish, the friendly interactive shell
	Type help for instructions on how to use fish
	johannes@e15 ~> sleep 2 | sleep 3 | sleep 4 | sleep_func
	^Zfish: Job 1, 'sleep 2 | sleep 3 | sleep 4 | s…' has stopped
	johannes@e15 ~ [0|SIGTSTP|SIGTSTP|1]> 

I'm not sure why the first sleep is not reported as stopped.

Co-authored-by: Lieuwe Rooijakkers <lieuwerooijakkers@gmail.com>

Fixes issue #12301

Closes #12550
2026-03-25 21:53:05 +08:00
rohan436
6b4ab05cbc docs: fix duplicated word in language docs
Closes #12554
2026-03-25 17:36:37 +08:00
Johannes Altmanninger
b5c367f8bf Bounds check backward-word-end
While at it, narrow the bounds check for forward movements,
no need to check for impossible cases.

Fixes #12555
2026-03-25 17:36:21 +08:00
Fabian Boehm
a6959aba2a Delete AGENTS.md again
This was an attempt at making vibecoded PRs slightly more palatable,
but it is itself an unpopular move.

Fixes #12526.
2026-03-19 18:41:36 +01:00
Noah Hellman
0a07e8dbdf pager: set col width only once
a bit hidden when column width is overwritten afterwards

Closes #12546
2026-03-16 16:13:21 +08:00
Noah Hellman
b2f350d235 pager: left-align descriptions
left aligned columns are usually easier to read in most cases (except for
e.g. numbers which descriptions are usually not)

Part of #12546
2026-03-16 16:13:21 +08:00
Noah Hellman
d1407cfde6 pager: add Column struct
to group column info, will add more

Part of #12546
2026-03-16 16:06:21 +08:00
Noah Hellman
f076aa1637 pager: take iterator for print_max
avoid unnecessary allocations just to create temporary wstrs

Part of #12546
2026-03-16 16:06:21 +08:00
Noah Hellman
96602f5096 pager tests: add multi-column tests
check alignment of descriptions

Part of #12546
2026-03-16 15:37:38 +08:00
Noah Hellman
a36fc0b316 pager tests: add completions helper
will be especially helpful for multi-completion tests

Part of #12546
2026-03-16 15:37:37 +08:00
Noah Hellman
d7f413bee9 add contrib/shell.nix
Closes #12544
2026-03-15 17:46:24 +08:00
Noah Hellman
81e9e0bd5c tests: use /bin/sh instead of /bin/ls, /bin/echo
/bin/ls and /bin/echo do not necessarily exist on all systems, e.g.
nixos.

/bin/sh should at least exist on more systems than /bin/ls and /bin/echo

Part of #12544
2026-03-15 17:46:24 +08:00
Noah Hellman
5c042575b0 highlight test: use /usr/bin/env instead of /bin/cat
/bin/cat doesn't exist on e.g. nixos, which only has /bin/sh and
/usr/bin/env.

/usr/bin/env should at least exist on more systems than /bin/cat

Part of #12544
2026-03-15 17:46:24 +08:00
Noah Hellman
a0d8d27f45 tests: use command instead of absolute paths
These binaries are not guaranteed to exist at /bin/X on all systems,
e.g. nixos does not place binaries there, but as long as they are in the
PATH we can find them with command.

Part of #12544
2026-03-15 17:46:24 +08:00
Johannes Altmanninger
d1d4cbf3f8 build_tools/update_translations.fish 2026-03-15 17:46:24 +08:00
Steffen Winter
7f41c8ba1f completions/coredumpctl: update for systemd 259
Closes #12545
2026-03-15 16:17:32 +08:00
Steffen Winter
c8989e1849 completions/run0: update for systemd 259
Part of #12545
2026-03-15 16:17:32 +08:00
Helen Chong
ae4e258884 chore(update-dependencies.sh): pin Catppuccin theme repository commit for fetching
See also https://github.com/catppuccin/fish/pull/41

Closes #12525
2026-03-15 16:14:39 +08:00
Nahor
3f0b4d38ff set_color: use only on/off for boolean options
This is done partly for consistency `underline` where we still need
`off` but where true/false doesn't make sense, and partly to simplify
user choices and the code.

See #12507

Closes #12541
2026-03-15 16:12:40 +08:00
t4k44
e9379904fb l10n: add Japanese translation
Closes #12499
2026-03-14 18:30:17 +01:00
Helen Chong
116671c577 docs(changelog): fix typo for Catppuccin color themes
Closes #12524
2026-03-13 15:04:05 +08:00
xtqqczze
53e1718a68 fix: pointer and signal handler casts
- avoid UB from `usize` → pointer cast
- use correct type for `sa_sigaction`

Closes #12488
2026-03-13 15:04:05 +08:00
Nahor
eab84c896e completions/docker: don't load if docker is not started
In WSL, if Docker is not started, the `docker` command is a script
that prints an error message to stdout instead of a valid script.

`docker.exe` is available and can return the completion script. However
any completion will end up calling that `docker` script anyway,
resulting further errors due to the unexpected output.

Closes #12538
2026-03-13 14:37:50 +08:00
JANMESH ARUN SHEWALE
ddf99b7063 Fix vi mode x and X keys to populate kill-ring
Closes #12420
Closes #12536
2026-03-13 14:29:06 +08:00
JANMESH ARUN SHEWALE
bcda4c5c4d fish_indent: preserve comments before brace blocks
Closes #12523
Closes #12505
2026-03-13 14:22:21 +08:00
rohan436
1244a47d86 docs: fix separator spelling in argparse docs
Closes #12533
2026-03-13 14:22:21 +08:00
Julien Gautier
4279a4f879 Update 'mount' completion script with the generated one, and update_translations
Closes #12531
2026-03-13 14:22:21 +08:00
Daniel Danner
efebb7bcdb docs/set: Fix mention of --export
Closes #12530
2026-03-13 14:22:21 +08:00
Daniel Rainer
226e818c25 resource usage: print KiB, not kb
The value shown is in KiB (2^{10} bytes), according to
`man 2 getrusage`, not kb (10^3 bits), so reflect this in the variable
name and output.

Closes #12529
2026-03-13 14:22:21 +08:00
Johannes Altmanninger
888e6d97f9 Address code review comments
See #12502
2026-03-13 14:22:21 +08:00
Nahor
eb7ea0ef9b set_color: add --foreground and --reset options
`--foreground` has two purposes:
- allow resetting the foreground color to its default, without also
resetting the other colors and modes
- improve readibility and unify the `set_color` arguments

`--reset` also has two purposes:
- provide a more intuitive way to reset the text formatting
- allow setting the colors and modes from a clean state without
requiring two calls to `set_color`

Part 3/3 of #12495

Closes #12507
2026-03-13 14:22:21 +08:00
Nahor
4e41d142fd set_color: allow resetting the underline style
Part 2/3 of #12495

Part of #12507
2026-03-13 14:22:00 +08:00
Nahor
a893dd10f4 set_color: allow resetting specific attributes
Add an optional `on`/`off`` value to italics/reverse/striketrough
to allow turning of the attribute without having to use the `normal`
color, i.e. reset the whole style

Part 1/3 of #12495

Part of #12507
2026-03-13 14:22:00 +08:00
Johannes Altmanninger
cba82a3c64 Remove code duplication 2026-03-13 14:22:00 +08:00
Nahor
6e8c32eb12 Remove the Default trait for text face/styling
The notion of default is context dependent: there is the default for
the state (default color, non-bold, no underline, ...) and the default
for a change (no color change, no underline change, ...).

Currently, using a single default works because either the style
attributes cannot be turned off individually (the user is expected
to reset to default then re-set necessary attributes), or the code
has special handling for specific scenarios (e.g. highlighting).

So in preparation for later commits, where attribute can be turned off
individually, make the two defaults explicit.

Part of #12507
2026-03-13 14:06:21 +08:00
Nahor
8ef9864c0c Cleaner fix for #[rustfmt::skip] on expressions
Part of #12507
2026-03-13 12:24:28 +08:00
Nahor
786ac339b8 Remove EnterStandoutMode
Now that terminfo has been removed, EnterStandoutMode is just a duplicate
of EnterReverseMode.

Part of #12507
2026-03-13 12:24:28 +08:00
Johannes Altmanninger
dbb6ae6cf5 Update changelog 2026-03-10 09:56:05 +08:00
Nahor
c4aa03a1fd complete: fix completion of commands starting with -
When trying to complete a command starting with `-`, and more
specifically when trying to get the description of possible commands,
the dash was interpreted as an option for `__fish_describe_command`,
resulting in an "unknown option" most of the time.

This is a regression introduced when adding option parsing to
`__fish_describe_command`

Fixes 7fc27e9e5 (cygwin: improve handling of `.exe` file extension, 2025-11-22)
Fixes #12510

Closes #12522
2026-03-10 09:56:05 +08:00
Nahor
e9340a3c43 CI: rebase MSYS2 dll
This fixes, or should make it less likely, spurious CI failures because
of:
`child_info_fork::abort: address space needed by <DLL> is already occupied`

The issue is that Unix `fork()`, given how it works, preserves
libraries' addresses. Windows does not have such a function, so Cygwin
needs emulate it by moving the libraries in a child process to match
the addresses in its parent. This leads to conflicts if Windows already
loaded something there.

As a workaround, Cygwin has a `rebase` application to assign specific
addresses to each DLL and forcing Windows to use those. This generally
fixes the issue (until a DLL is updated that is, but that's not
a concern for CI since everything is rebuilt from scratch every time).

In the case of #12515 though, the failing DLL is a temporary one built
during the compilation. So a rebase of MSYS2 packages will not quite
fix the problem. However, by moving other DLLs at specific locations,
it reduce the risk of collision to only be between the temporary ones.

Fixes #12515

Closes #12521
2026-03-10 09:56:05 +08:00
Volodymyr Chernetskyi
143a53d9c3 feat: add completions for tflint
Closes #12520
2026-03-10 09:56:05 +08:00
Volodymyr Chernetskyi
a282acf083 feat: add git completions for interpret-trailers
Closes #12519
2026-03-10 09:55:42 +08:00
Mike Yuan
cbd5d7640a functions/history: honor explicitly specified --color=
This partially reverts 324223ddff.

The offending commit broke the ability to set color mode via option
completely in interactive sessions.

Closes #12511
2026-03-09 17:15:55 +11:00
Delapouite
6f262afe8e doc: add link to not command from if command
It's very common to want to express negation in a `if` command.
Therefore a quick way to learn about the `not` command is handy.

Closes #12512
2026-03-09 17:15:55 +11:00
Daniel Rainer
310eba7156 cleanup: use nix version of getrusage
Change the behavior when `getrusage` fails. Previously, failure was
masked by using 0 values for everything. This is misleading. Instead, we
now panic on such failures, because they should never occur with our
usage of the function.

Closes #12502
2026-03-09 17:15:55 +11:00
Daniel Rainer
0223edc639 cleanup: use nix version of getpid
Alternatively, we could also use `nix::unistd::Pid::this()`.

Part of #12502
2026-03-09 16:52:08 +11:00
Daniel Rainer
6d0bb4a6b8 cleanup: replace custom umask wrapper by nix
Part of #12502
2026-03-09 16:52:08 +11:00
Daniel Rainer
7992fda9fe refactor: extract perror
Part of #12502
2026-03-09 16:52:08 +11:00
Daniel Rainer
bf5fa4f681 feat: implement perror_nix
Similar to `perror_io`, we don't need to make a libc call for `nix`
results, since the error variant contains the errno, from which a static
mapping to an error message exists. Avoid using `perror` and instead use
`perror_io` or `perror_nix` as appropriate where possible.

The `perror_io` and `perror_nix` functions could be combined by
implementing `fish_printf::ToArg` for `nix::errno::Errno`, but such a
function would violate type safety, as it would allow passing any
formattable argument, not necessarily limited to functions with a `%s`
formatting.

Part of #12502
2026-03-09 16:52:08 +11:00
Daniel Rainer
735f3ae6ad cleanup: remove obsolete wperror
Part of #12502
2026-03-09 16:52:08 +11:00
Daniel Rainer
131febed2a cleanup: remove unnecessary wstr usage
Part of #12502
2026-03-09 16:52:07 +11:00
Daniel Rainer
61dec20abd cleanup: inline wrename function
This function was only used in a single place and does not do anything
complicated, so inline it.

Part of #12502
2026-03-09 16:52:07 +11:00
Daniel Rainer
c0bb0d6584 refactor: extract write_to_fd into util crate
Part of #12502
2026-03-09 16:52:07 +11:00
Daniel Rainer
c5e4fed021 format: use 4-space indents in more files
Change some files which have lines whose indentation is not a multiple
of the 4 spaces specified in the editorconfig file.

Some of these changes are fixes or clear improvements (e.g. in Rust
macros which rustfmt can't format properly). Other changes don't clearly
improve the code style, and in some cases it might actually get worse.

The goal is to eventually be able to use our editorconfig for automated
style checks, but there are a lot of cases where conforming to the
limited editorconfig style spec does not make sense, so I'm not sure how
useful such automated checks can be.

Closes #12408
2026-03-09 16:52:07 +11:00
Daniel Rainer
1df7a8ba29 cleanup: remove obsolete ellipsis complexity
Previously, we chose the ellipsis character/string based on the locale.
We now assume a UTF-8 locale, and accordingly always use the Unicode
HORIZONTAL ELLIPSIS U+2026 `…`. When this was changed, some of the logic
for handling different ellipsis values was left behind. It no longer
serves a purpose, so remove it.

The functions returning constants are replaced by constants. Since the
ellipsis as a `wstr` is only used in a single file, make it a local
const there and define it via the `ELLIPSIS_CHAR` const.

Put the `ELLIPSIS_CHAR` definition into `fish-widestring`, removing the
dependency of `fish-wcstringutil` on `fish-common`, helping future
extraction efforts.

One localized message contains an ellipsis, which was inserted via a
placeholder, preventing translators from localizing it. Since the
ellipsis is a constant, put it directly into the localized string.

Closes #12493
2026-03-03 15:14:39 +11:00
Daniel Rainer
121b8fffa6 fix: version test on shallow, dirty git repo
In shallow, dirty git repo, the version identifier will look something
like `fish, version 4.5.0-g971e0b7-dirty`, with no commit counter
indicating the commits since the last version. Our regex did not handle
this case.

Make the commit counter optional, which also allows removing the second
alternative in the regex, since it's now subsumed by the first.

Fixes #12497

Closes #12498
2026-03-03 15:14:39 +11:00
Johannes Altmanninger
9c4190e40a Retry writes on signals other than INT/HUP
Fixes #12496
2026-03-03 15:14:39 +11:00
Daniel Rainer
f000149837 refactor: move FilenameRef into fish_common
Closes #12492
2026-03-03 15:14:39 +11:00
Daniel Rainer
f6f50df43d refactor: extract more from src/common.rs
This time, functions for decoding `wstr` into various types and the
`ToCString` trait are extracted.

Part of the wider goal of slimming down the main library to improve
incremental build performance and reduce dependency cycles.

Part of #12492
2026-03-03 15:14:39 +11:00
Daniel Rainer
29160a1592 gettext: support non-ASCII msgids for Rust
The `msguniq` call for deduplicating the msgids originating from Rust
previously did not get a header entry (empty msgid with msgstr
containing metadata). This works fine as long as all msgids are
ASCII-only. But when a non-ASCII character appears in a msgid, `msguniq`
errors out without a header specifying the encoding. To resolve this,
add the header to the input of this `msguniq` invocation and then remove
the header again using sed to prevent duplicating it for the outer
msguniq call at the end of the file.

Closes #12491
2026-03-03 15:14:39 +11:00
Julio Napurí
fcdcae72c5 l10n: add spanish translation
Closes #12489
2026-03-03 15:14:38 +11:00
Daniel Rainer
971e0b7d37 l10n: create common function for finding l10n/po dir
Reduce repetition and make it easier to relocate the directory. This
approach will also be useful for Fluent.

Closes #12484
2026-02-26 14:34:46 +11:00
Daniel Rainer
d6ac8a48c0 xtasks: make files_with_extension more accessible
This function is useful beyond the formatting module, so put it into the
top level of the library.

Closes #12483
2026-02-26 14:34:46 +11:00
Daniel Rainer
2ba031677f xtask: don't panic on failure
Panicking suggests that an assumption of our code was violated.
The current use of panics in xtasks is for expected failures, so it's
better to avoid panicking and instead just print the error message to
stderr and exit 1.

Closes #12482
2026-02-26 14:34:46 +11:00
Johannes Altmanninger
c15ea5d1e6 CI: deny unknown lints on Rust stable
Closes #12334
2026-02-25 18:22:48 +11:00
Johannes Altmanninger
78f3c95641 Reliably suppress warning about unknown Rust lints
Lint table order is unspecified, leading to spurious "unknown
lint" errors which ought to have been suppressed, see
https://github.com/rust-lang/cargo/issues/16518

From https://rust-lang.github.io/rfcs/3389-manifest-lint.html

> lower (particularly negative) numbers ... show up first on the
> command-line to tools like rustc

So we can use the priority property to make sure that unknown lints
are suppressed before rustc processes the other lint specifications.

Part of #12334
2026-02-25 18:22:48 +11:00
Aditya Giri
149fec8f02 string: accept --char alias for pad and shorten
Closes #12460
2026-02-25 18:18:21 +11:00
Daniel Rainer
1b0fa8f804 unicode: use new decoded_width function
For now, only add it in a single place. There are more instances where
width calculation could be improved, but this one has already been
converted to use the `unicode-width` crate before, so conversion is easy
and a strict improvement.

Closes #12457
2026-02-25 18:18:21 +11:00
Daniel Rainer
c38dd1f420 unicode: add function for width computation
Accurately computing the width of arbitrary strings is a non-trivial
problem. We outsource the logic for it to the `unicode-width` crate. But
directly passing our PUA-encoded strings to the crate would give
incorrect results whenever a PUA codepoint is encoded in our string,
since one input PUA codepoint is converted into 3 consecutive codepoints
in our encoding. Therefore, we need to decode before performing width
calculations. Our regular decoding decodes to raw bytes, which is
incompatible with the `unicode-width` crate, since it expects `char`s,
and the decoded bytes could be invalid UTF-8, making their width
undefined. We tackle this problem by building a custom iterator which
does on-the-fly decoding. Encoded PUA codepoints are turned back into
the original codepoints, and any other PUA-encoded bytes are replaced by
one replacement character (U+FFFD) per byte. The latter is not necessary
since PUA codepoints have a defined width of 1, so we could also forward
the PUA-encoded bytes which encode invalid UTF-8 input instead of
inserting the replacement character. The choice to use the replacement
character is made to avoid producing a char sequence where some PUA
codepoints represent themselves, whereas others still encode non-UTF-8
bytes. Such a mix of semantics would be confusing if the char sequence
is ever used for anything else. Replacement characters make it clear
that there are no remaining encoded semantics. Note that using the char
sequences produced in this way for any purpose other than width
computation is not intended. For output, our pre-existing decoding to
bytes should be used, which allows preserving non-UTF-8 bytes.

The implementation of the iterator is not entirely straightforward,
since we need to read up to 3 chars to be able to decide whether we have
an encoded PUA character. Therefore, we need to cache some chars across
invocations of the iterator's `next` and `next_back` invocations. This
is done via a custom buffer struct, which does not require dynamic
allocations.

The tests for the new functionality are only in the main crate because
the encoding function is not available in the `fish-widestring` crate.
Once that is resolved, the tests should be moved.

Part of #12457
2026-02-25 18:18:21 +11:00
Johannes Altmanninger
b9b32ad157 Fix vi mode dl and dh regressions
Also improve AGENTS.md though we should totally point to
CONTRIBUTING.rst instead.

Fixes #12461
2026-02-25 18:18:21 +11:00
Janne Pulkkinen
45ac6472e2 completions/protontricks: update options
New options were added and the help text updated for the old to better
tell them apart.

Closes #12477
2026-02-25 18:18:21 +11:00
Janne Pulkkinen
9235c5de6c completions/protontricks: use new flag for complete
`protontricks -l` will launch a graphical prompt to choose Steam
installation if multiple installations are found. `-L/--list-all`
is a new flag introduced in 1.14.0 that retrieves all games without user
interaction.

Also silence stderr, since it can cause warning messages to be printed.

Part of #12477
2026-02-25 16:47:54 +11:00
Johannes Altmanninger
6c091dbaf4 Remove spurious intermediate ⏎ symbol on prompt redraw
Commit 7ac9ce7ffb (Reduce the number of escape sequences for text
styles, 2026-02-06) includes a bad merge conflict resolution of
a conflict with 38513de954 (Remove duplicated code introduced in
commit 289057f, 2026-02-07). Fix that.

Fixes #12476
2026-02-25 16:47:25 +11:00
Daniel Rainer
3e7e57945c format: replace style.fish by xtask
Replace the `build_tools/style.fish` script by an xtask. This eliminates
the need for a fish binary for performing the formatting/checking. The
`fish_indent` binary is still needed. Eventually, this should be made
available as a library function, so the xtask can use that instead of
requiring a `fish_indent` binary in the `$PATH`.

The new xtask is called `format` rather than `style`, because that's a
more fitting description of what it does (and what the script it
replaces did).

The old script's behavior is not replicated exactly:
- Specifying `--all` and explicit paths is supported within a single
  invocation.
- Explicit arguments no longer have to be files. If a directory is
  specified, all files within it will be considered.
- The git check for un-staged changes is no longer filtered by file
  names, mainly to simplify the implementation.
- A warning is now printed if neither the `--all` flag nor a path are
  provided as arguments. The reason for this is that one might assume
  that omitting these arguments would default to formatting everything
  in the current directory, but instead no formatting will happen in
  this case.
- The wording of some messages is different.

The design of the new code tries to make it easy to add formatters for
additional languages, or change the ones we already have. This is
achieved by separating the code into one function per language, which
can be modified without touching the code for the other languages.
Adding support for a new formatter/language only requires adding a
function which builds the formatter command line based on the arguments
to the xtask, and calling that function from the main `format` function.

Closes #12467
2026-02-24 16:33:04 +11:00
Johannes Altmanninger
23ce9de1c3 CI: disable failing ubuntu-asan job
The rust-shellexpand dependency (via rust-embed)
fails to build on nightly Rust; Fix is at
https://gitlab.com/ijackson/rust-shellexpand/-/merge_requests/19
2026-02-23 15:49:34 +11:00
exploide
6aee7bf378 completions/ip: complete netns for ip l set dev netns, plus some option arguments
Closes #12464
2026-02-23 14:25:09 +11:00
David Adam
5b360238b2 dput_cf_gen: drop -x flag, only used for development 2026-02-21 10:58:12 +08:00
David Adam
5b44c9668f add script to generate a dput.cf for Ubuntu PPA uploads 2026-02-21 10:38:24 +08:00
Peter Ammon
d01a403c65 Cleanup ParserTestErrorBits harder
We don't need this bitwise operator override.
2026-02-17 19:13:13 -08:00
Peter Ammon
b65649725e Cleanup ParserTestErrorBits
This was a weird type that made sense in C++ but not so much in Rust.
Let's clean this up.
2026-02-16 22:29:30 -08:00
Johannes Altmanninger
89c2f1bd6b start new cycle
Created by ./build_tools/release.sh 4.5.0
2026-02-17 11:54:05 +11:00
Johannes Altmanninger
3478f78a05 Release 4.5.0
Created by ./build_tools/release.sh 4.5.0
2026-02-17 11:32:33 +11:00
Johannes Altmanninger
19cedb01bc changelog 2026-02-17 11:31:17 +11:00
xtqqczze
cb24c4a863 rust: use const_locks feature
Closes #12454
2026-02-17 11:28:58 +11:00
xtqqczze
93478e7c51 simplify serialize_with_vars
Closes #12453
2026-02-17 11:28:58 +11:00
xtqqczze
4eac5f4d9d clippy: fix unused_trait_names lint
https://rust-lang.github.io/rust-clippy/master/index.html#unused_trait_names

Closes #12450
2026-02-17 11:28:58 +11:00
xtqqczze
e76370b3b7 clippy: fix str_to_string lint
https://rust-lang.github.io/rust-clippy/master/index.html#str_to_string

Closes #12449
2026-02-17 11:13:34 +11:00
Daniel Rainer
1e3153c3fb unicode: fix history search cursor positioning
The cursor position calculation did not correctly account for the width
of Unicode text, resulting in the cursor being placed to far left in
scenarios with characters taking up 2 cells, such as in Chinese text.

Fix this by combining the entire line into a string and computing the
length of the resulting string using the `unicode-width` crate.

This is the first code in the main crate making use of `unicode-width`.
Eventually, we'll probably want to use it in more places, to get better
and consistent results.

Fixes #12444

Closes #12446
2026-02-17 11:13:25 +11:00
Peter Ammon
d0a95e4fde Fix some dumb clipply 2026-02-15 11:25:40 -08:00
Peter Ammon
7174ebbb4b Slightly refactor history tests
This introduces a create_test_history helper function; it looks sort of
silly now but will be useful for upcoming history improvements.
2026-02-15 11:09:14 -08:00
Peter Ammon
e81cec1633 Fix kill-word-vi on macOS/BSDs
`seq 0` outputs nothing on Linux but `1 0` on macOS and BSDs, breaking
this word motion. Fix it by not running `seq 0`.
2026-02-14 12:06:51 -08:00
Johannes Altmanninger
02c04550fd Fix Vi mode cw deleting trailing whitespace
Fixes 38e633d49b (fish_vi_key_bindings: add support for count,
2025-12-16).

Fixes #12443
2026-02-12 14:11:26 +11:00
David Adam
b0bfc7758a CHANGELOG: editing 2026-02-11 16:41:00 +08:00
Weixie Cui
cbf21b13d7 fix: unwrap may cause panic
Closes #12441
2026-02-11 14:49:54 +11:00
Aman Verma
14f3c3e13e completions: use upstream completions for dua
Our completions had gone out-of-date. They didn't support invocations
like `dua path/to/folder`, instead requiring a subcommand.

Closes #12438
2026-02-11 14:46:01 +11:00
Johannes Altmanninger
05ea6e9e66 Remove unused "Output" trait
Continue incidental cleanup started in earlier commit (Reduce the
number of escape sequences for text styles, 2026-02-06).
2026-02-11 14:37:38 +11:00
Nahor
74d2e6d5d8 Rip support for terminfo database
The terminfo database hasn't been used by default since 4.1.0
(see #11344, #11345)

Closes #12439
2026-02-11 14:37:38 +11:00
Nahor
1b8f9c2b03 Initialize Features using a loop
This removes the need to update `Features::new()` every time a feature
is added or removed

Part of #12439
2026-02-11 14:37:38 +11:00
Johannes Altmanninger
491158dfad Output reset_text_face: minor simplification 2026-02-11 14:37:38 +11:00
Johannes Altmanninger
7fa08e31c6 Tweak naming for outputter buffer consumer
Rust idiomatic naming is "take" for "move", also Rust might actually
move the object to a different memory adress, which is fine because
all Rust objects are trivially relocatable.
2026-02-11 14:22:14 +11:00
Nahor
7ac9ce7ffb Reduce the number of escape sequences for text styles
When setting graphics attributes (SGR), combine them into a single
escape sequence to reduce the length of the string and make it slightly
easier to read by people when needed.

Some terminal/parser[^1] may have a cap on the number of parameters, so
we limit the number to 16.

[^1]: https://vt100.net/emu/dec_ansi_parser: "There is no limit to the
number of characters in a parameter string, although a maximum of 16
parameters need be stored. If more than 16 parameters arrive, all
the extra parameters are silently ignored.""

Closes #12429
2026-02-11 14:22:14 +11:00
Johannes Altmanninger
197779697d Remove unused Output implementations
I think the OutputStream was used only in old fish_indent code.
The BufferedOutputter seems obsolete, maybe because DerefMut covers
this.
2026-02-11 14:22:14 +11:00
Weixie Cui
96fabe4b29 fix: update 2026-02-10 14:21:04 +01:00
David Adam
4a4d35b625 completions/dput: add new completions 2026-02-10 16:02:31 +08:00
David Adam
92739a06e2 completions/dscacheutil: correct description 2026-02-10 15:46:53 +08:00
David Adam
244e9586ca completions/chsh: remove stray whitespace 2026-02-10 15:44:29 +08:00
David Adam
13a2ccae66 release.sh: add a couple of explanatory comments 2026-02-10 14:29:16 +08:00
David Adam
ed34845b10 Debian packaging: don't link the .cargo directory from vendor tarball
The main tarball did not contain a .cargo directory, but it does now,
and this symlink ends up in the wrong place and is not needed.
2026-02-10 13:07:01 +08:00
Daniel Rainer
74b104c9f6 cleanup: delete unmaintained Dockerfile
This Dockerfile has been broken for quite a while now, at least since
Rust is required for building fish. No one seems to have complained
about it being broken, so there is no point in keeping it around. The
`docker` directory contains several Dockerfiles which could be used
instead.

https://github.com/fish-shell/fish-shell/pull/12408#discussion_r2770432433

Closes #12435
2026-02-09 12:16:52 +11:00
Francisco Giordano
1f8cdf85b6 Fix ctrl-l interference with history search
Closes #12436
2026-02-09 12:16:33 +11:00
David Adam
dc02a8ce35 CI: run apt-get update before any apt install
Try to avoid surprises down the track by doing this across the board.
2026-02-09 00:04:40 +08:00
Pothi Kalimuthu
65e726324a Fix the link to GitHub repo 2026-02-08 23:38:46 +08:00
Johannes Altmanninger
fe3c42af9e Work around github actions python failure
github actions runners have python 3.12, so the upgrade to debian
stable's 3.13 broke things:

	+ env UV_PYTHON=python uv --no-managed-python lock --check --exclude-newer=2026-02-01T13:00:00Z
	Using CPython 3.12.3 interpreter at: /usr/bin/python
	error: The requested interpreter resolved to Python 3.12.3, which is incompatible with the project's Python requirement: `>=3.13` (from `project.requires-python`)
	Error: Process completed with exit code 2.

Steps:
1. edit pyproject.toml and
2. uv lock --upgrade --exclude-newer="$(awk -F'"' <uv.lock '/^exclude-newer[[:space:]]*=/ {print $2}')"

In future we should maybe use managed python?
2026-02-08 14:03:53 +11:00
Johannes Altmanninger
28c7e7173f Fix fish_indent_interrupt CI workaround 2026-02-08 14:01:45 +11:00
Johannes Altmanninger
a897a26daa Test Vi mode dfX
Tests d25965afba (Vi mode: hack in support for df and friends,
2026-02-06).
2026-02-08 13:16:07 +11:00
Johannes Altmanninger
ffce214362 Test fish_vi_key_bindings argument
Tests 6d01138797 (Fix vi key bindings regression when called with
argument, 2026-02-04).
2026-02-08 13:16:07 +11:00
Liam Snow
bdb8e4847f dir_iter: handle missing d_type on illumos
Closes #12410
Fixes #11099
2026-02-08 13:16:07 +11:00
Liam Snow
9750d8c3ad path: return Unknown for remoteness check on illumos
Part of #12410
2026-02-08 13:12:41 +11:00
Johannes Altmanninger
dadec16661 path_remoteness: use cfg_if 2026-02-08 13:12:41 +11:00
Liam Snow
b5cd2763db spawn: POSIX_SPAWN flags are not i32 on illumos
Part of #12410
2026-02-08 13:12:41 +11:00
Liam Snow
a08dd70354 env: define _CS_PATH const for illumos
Part of #12410
2026-02-08 13:12:41 +11:00
Liam Snow
5b39d1fc6a ulimit: add illumos to platforms missing MEMLOCK/NPROC limits
Part of #12410
2026-02-08 13:12:41 +11:00
Nahor
38513de954 Remove duplicated code introduced in commit 289057f
Closes #12432
2026-02-08 13:12:41 +11:00
Johannes Altmanninger
cc1ae25c3a Fix kill-a-word kill-inner-word bounds checks if at end of command line
These commands are meant to be used in Vi mode when the cursor is on
a valid character, so there's not much reason to try to make them do
something when the cursor is past-end.  Do nothing, like we already
do for the empty commandline.

Reported in #12430
2026-02-08 13:12:41 +11:00
Johannes Altmanninger
002fa0e791 Fix cursor position after accepting Vi mode autosuggestion
Closes #12430
2026-02-08 13:12:41 +11:00
Jack Pickle
0589de7523 fix git stash completions not working after flags
update __fish_git_stash_not_using_subcommand check for actual subcommands
instead of treating any word after 'stash' as a subcommand.

stay dry by adding__fish_git_stash_is_push helper that matches both implicit and explicit push.

fixes #11307

Closes #12421
2026-02-08 13:12:41 +11:00
Johannes Altmanninger
4e7e0139fd Update to sphinx 9.1
sphinx==9.1.0 depends on Python>=3.12,
so change our pinning policy to fit.
Note we still support Python 3.9 in user-facing code.

Steps:
1. edit updatecli.d/python.yml
2. remove bad "uv lock" from build_tools/update-dependencies.sh
   (didn't respect exclude-newer)
3. updatecli apply --config updatecli.d/python.yml
4. uv lock --upgrade --exclude-newer="$(date --date='7 days ago' --iso-8601)"
2026-02-08 13:12:41 +11:00
Johannes Altmanninger
c044e1d433 update-dependencies.sh: update and pin 3rd party github workflows 2026-02-08 13:12:41 +11:00
Johannes Altmanninger
fb0edf564e Add AGENTS.md
LLM-generated contributions tend to produce too many redundant
comments. Fix that.  This doesn't work OOTB for Claude, but it's easy
to tell it to respect AGENTS.md..
2026-02-08 13:12:41 +11:00
Salman Muin Kayser Chishti
969ce68d5d Upgrade GitHub Actions for Node 24 compatibility
Signed-off-by: Salman Muin Kayser Chishti <13schishti@gmail.com>

Closes #12422
2026-02-08 12:59:26 +11:00
Salman Muin Kayser Chishti
6ef2e04518 Upgrade GitHub Actions to latest versions
Signed-off-by: Salman Muin Kayser Chishti <13schishti@gmail.com>

Closes #12423
2026-02-08 12:59:26 +11:00
Johannes Altmanninger
bc84fe9407 tests/pexpects/fish_indent_interrupt: skip in CI
This fails intermittently in CI. Disable it.  We disable a lot of
other tests as well which is why we run tests on developer machines
before pushing to master.

See #12351
2026-02-08 12:59:26 +11:00
Peter Ammon
38e8416da5 test_history_path_detection to adopt custom history directories
Simplifies this test by making it no longer serial.
2026-02-07 12:29:54 -08:00
Peter Ammon
cf0e07aecd test_history_formats to adopt custom history directories
Simplifies this test by making it no longer serial.
2026-02-07 12:23:13 -08:00
Peter Ammon
8e014bbf97 test_history_formats to adopt custom history directories
Simplifies this test by making it no longer serial.
2026-02-07 12:20:11 -08:00
Peter Ammon
f9013ad7a6 Allow histories to be created outside of the default path
Currently history files are written to the "data directory"
(XDG_DATA_HOME). This is awkward in testing since we have to put files
into this directory.

Allow histories to have their own directory, so that they don't
interfere with other files. This will help simplify some tests.

Adopt this in some (but not all) history tests.
2026-02-07 12:20:09 -08:00
Johannes Altmanninger
8d2d50573a changelog 2026-02-06 15:38:50 +11:00
Johannes Altmanninger
d25965afba Vi mode: hack in support for df and friends
Commit 38e633d49b (fish_vi_key_bindings: add support for count,
2025-12-16) introduced an operator mode which kind of makes a lot of
sense for today's fish.  If we end up needing more flexibility and
tighter integration, we might want to move some of this into core.

Unfortunately the change is at odds with our cursed forward-jump
implementation.  The forward-jump special input function works by
magically reading the next key from stdin, which causes problems when
we are executing a script:

	commandline -f begin-selection
	commandline -f forward-jump
	commandline -f end-selection

here end-selection will be executed immediately
and forward-jump fails to wait for a keystroke.

We should get rid of forward-jump implementation.

For now, replace only the broken thing with a dedicated bind mode
for each of f/F/t/T.

Fixes #12417
2026-02-06 15:38:50 +11:00
Johannes Altmanninger
6f895935a9 bind.rst: update meaning of --silent option
We can probably even remove this, since the remaining behavior doesn't
seem useful.
2026-02-06 15:19:49 +11:00
Johannes Altmanninger
70ebc969f9 fish_vi_key_bindings: remove unused "bind -s" option
Commit 46d1334f95 (Silence bind errors in default key bindings,
2017-10-03) worked around errors arising from "bind -k".
We no longer use that, so remove that.
2026-02-06 15:19:49 +11:00
Simon Olofsson
6d01138797 Fix vi key bindings regression when called with argument
Commit bbb2f0de8d added a ctrl-right binding to override the shared
binding with forward-word-vi for vi-compliance. However, it incorrectly
passed $argv which caused the error:
  "bind: cannot parse key 'default'"

when calling fish_vi_key_bindings with a mode argument like:
  fish_vi_key_bindings "default"

Fix that.

Co-Authored-By: Johannes Altmanninger <aclopte@gmail.com>

Closes #12413
2026-02-06 12:40:53 +11:00
Daniel Rainer
779f1371a1 l10n: localize colon followed by content
Some languages have different conventions regarding colons. In order to
handle this better in cases with non-constant strings, as is the case in
`describe_with_prefix`, use localization to figure out how colons should
be localized.

This approach fixes the extra whitespace inserted after Chinese colons.
See #12405.

Closes #12414
2026-02-06 12:05:03 +11:00
Daniel Rainer
5d24a846e3 cleanup: simplify pushing to WString
Part of #12414
2026-02-06 12:05:02 +11:00
madblobfish
c4f1c25a87 completion/rfkill: add completions for toggle command
"toggle" command was not considered in the completions

Closes #12412
2026-02-06 12:05:02 +11:00
Daniel Rainer
7d754b2865 ci: update before apt install
GitHub does not consistently provide images with up-to-date package
lists, causing `apt install` failures.
Work around this by updating the package list.
https://github.com/actions/runner-images/issues/13636
https://github.com/actions/runner-images/issues/12599

Closes #12418
2026-02-06 11:42:30 +11:00
Johannes Altmanninger
232e38f105 Fix rst syntax in changelog 2026-02-06 11:41:23 +11:00
Tristan Partin
725afc71fd Fix fish_mode_prompt formatting error
"variable" was in the formatted portion of the text when it should not
have been.

Signed-off-by: Tristan Partin <tristan@partin.io>
2026-02-05 07:14:21 +01:00
David Adam
6d60eaf04e CMake: use cargo variable to call cargo
Fixes the build where a custom cargo binary is passed in.
2026-02-03 11:10:34 +08:00
Johannes Altmanninger
7c1d8cf4f1 start new cycle
Created by ./build_tools/release.sh 4.4.0
2026-02-03 12:39:46 +11:00
Johannes Altmanninger
e1a0df68fc Release 4.4.0
Created by ./build_tools/release.sh 4.4.0
2026-02-03 12:11:51 +11:00
Johannes Altmanninger
14832117b6 release.sh: regression fixes
The error check in make_tarball.sh gives a false negative when building
from a release tag.
2026-02-03 12:10:40 +11:00
Johannes Altmanninger
56deaafb34 Remove extra newline in error log
Introduced in 149594f974 (Initial revision, 2005-09-20).
2026-02-03 11:58:52 +11:00
Johannes Altmanninger
b8b36f3293 de.po: fix typo 2026-02-03 11:58:52 +11:00
Daniel Rainer
a9ab708494 gettext: enforce trimmed msgids
Now that we have trimmed our msgids, add an assertion to ensure that
they stay trimmed. Note that we don't check msgstrs. We could do so when
building the maps which get put into the executable, but there we also
include messages originating from fish scripts, and there we don't
enforce trimmed messages, so limiting the checks to only messages
originating from the Rust code there would not be trivial.

Closes #12405
2026-02-03 11:58:52 +11:00
Daniel Rainer
a33363902c gettext: don't put tabs into localizable strings
This allows the strings to be simpler, and keeps
localization-independent formatting out of localizable strings.

Tab-based formatting is brittle, and should probably be reworked.

This is also the final piece to have no more leading or trailing
whitespace in our localizable strings in the Rust code.

Part of #12405
2026-02-03 11:58:52 +11:00
Daniel Rainer
3ca3d10e28 gettext: simplify localizable string
Only the first line needs to be localized, so don't include the rest for
localization.

Part of #12405
2026-02-03 11:58:52 +11:00
Daniel Rainer
05c236481f gettext: remove leading spaces
Now, non of the localizable strings in Rust have any more leading or
trailing spaces, making it easier to use them with Fluent. Again, there
are some slight issues with Chinese translations, which now have
additional whitespace.

Part of #12405
2026-02-03 11:58:52 +11:00
Daniel Rainer
25e2bdb7de gettext: remove trailing spaces
Another step towards trimming the localizable strings. Fix
inconsistencies in some of the translations. Translations for zh_CN are
not entirely consistent between using ASCII colons and `:`. If the
latter is used, which also happens for zh_TW, no trailing space is
present in the translation even if it is present in the msgid. This
means that the new code will show excessive whitespace after these
colons, since a regular space is inserted outside of the localization
code. While this might not be pretty, I don't think it really breaks
anything, and not having to deal with trailing whitespace simplifies
working with Fluent.

Part of #12405
2026-02-03 11:58:52 +11:00
Daniel Rainer
12bd4cf9e9 l10n: don't localize PID
This simplifies our table formatting. Since none of our translations
modify the string `PID`, it seems reasonable to assume that the term
does not benefit from localization.

Part of #12405
2026-02-03 11:58:52 +11:00
Daniel Rainer
0d79681070 gettext: remove remaining trailing newlines
Complete the work started in
e78e3f16e (gettext: remove trailing newlines, 2026-01-30)

Now, there are no remaining trailing newlines in the localizable strings
in our Rust sources. A bit more work is still needed to get rid of a few
leading and trailing spaces, the goal being that for all localizable
strings `s` in our Rust sources, `s == s.trim()`.

Includes a bit of drive-by refactoring.

Part of #12405
2026-02-03 11:58:52 +11:00
Daniel Rainer
47d7f52149 editorconfig: use indent_size=2 for Vagrantfiles
This matches the existing formatting of the files.

Part of #12408
2026-02-03 11:26:59 +11:00
Daniel Rainer
000a5cc80a format: add final newlines to files
Part of #12408
2026-02-03 11:26:59 +11:00
Daniel Rainer
66f51f5166 editorconfig: remove special handling for *.in
The file we have whose names end in `.in` are not Makefiles, so there is
no reason to deviate from our default formatting for them.

Part of #12408
2026-02-03 11:26:59 +11:00
Daniel Rainer
7360deee74 format: remove trailing whitespace
Part of #12408
2026-02-03 11:26:59 +11:00
Daniel Rainer
e0916e793b format: don't use tabs for indentation
This is done in accordance with our editorconfig file.

Part of #12408
2026-02-03 11:26:59 +11:00
Daniel Rainer
f43a79bc13 editorconfig: set indent_style=tab for makefiles
Replace mixed indentation in GNUmakefile used for alignment by a single
tab increase in indentation

Part of #12408
2026-02-03 11:26:59 +11:00
Daniel Rainer
fb56a6a54d editorconfig: set YAML indent_size to 2
This matches what we're already using, except for a few inconsistencies.

Part of #12408
2026-02-03 11:26:59 +11:00
Timen Zandbergen
f6936f222a Add strikethrough TextStyling
Closes #12369
2026-02-03 11:26:59 +11:00
Johannes Altmanninger
553aa40b34 Fix crash in Vi's "dge" due to misplaced cursor
kill-selection does not respect fish_cursor_end_mode; fix that.
2026-02-02 12:49:39 +11:00
Johannes Altmanninger
ac9c339e5a Vi bindings: remove unused special input functions
These were only needed before the new approach from 38e633d49b
(fish_vi_key_bindings: add support for count, 2025-12-16).
2026-02-02 12:33:50 +11:00
Johannes Altmanninger
0ae3b33f2f tarball: remove unused git-archive knob
The problem introduced by 081c469f6f (tarball: include
.cargo/config.toml again, 2026-01-13) seems solved by 09d8570922
(debian packaging: generate patches automatically, 2026-02-01),
so the argument to make_tarball.sh is no longer needed.
2026-02-02 12:22:45 +11:00
Johannes Altmanninger
6dbe5637ef redirect_tty_after_sighup: minor simplification 2026-02-02 11:25:03 +11:00
David Adam
09d8570922 debian packaging: generate patches automatically
The vendor tarball drops a new version of .cargo/config into place,
which the Debian toolchain does not like (as it is an unexpected
modification of the original tarball). Tell dpkg-source to generate a
patch automatically, as trying to do it in fish's packaging scripts is
brittle.
2026-02-01 22:59:12 +08:00
Johannes Altmanninger
4ab433418e Update changelog 2026-02-01 20:13:13 +11:00
Johannes Altmanninger
73e3b47ebd tarball: capture Git version
Commit 92dae88f62 (tarball: remove redundant "version" file,
2026-01-12) committed to using Cargo.toml as single source of truth
for our version string.

This works fine for tarballs built from a tag, but those built from
an arbitrary Git commit will show a misleading version ("4.3.3"
instead of something like "4.3.3-190-g460081725b5-dirty").

Fix this by copying the Git version to the tarball's Cargo.{toml,lock}.

It's not clear if we really need this (it's only for nightly builds)
so we might end up reverting this.

Ref: https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$BdRagDGCV-8yVjBs0i3QyWUdBK820vTmjuSBqgpsuJY

Note that OBS builds are probably still broken from 081c469f6f
(tarball: include .cargo/config.toml again, 2026-01-13); see
https://github.com/fish-shell/fish-shell/pull/12292#discussion_r2694000477
2026-02-01 20:13:13 +11:00
Johannes Altmanninger
bb7dce941a termios: use nix wrapper 2026-02-01 20:13:13 +11:00
Johannes Altmanninger
55e9255264 termios: remove repeated assignment to global 2026-02-01 19:58:51 +11:00
Johannes Altmanninger
cf53ef02c4 termios: simplify set-operations for toggling flow control 2026-02-01 19:58:23 +11:00
Johannes Altmanninger
c8ea418154 Update Cargo dependencies 2026-02-01 12:14:36 +11:00
Peter Ammon
44920b4be8 Pre-allocate certain string capacities
Reduce some allocation churn.
2026-01-31 10:51:33 -08:00
Tiago de Paula
b980e50acf __fish_complete_suffix: Remove –foo= from token
Otherwise we get --foo=--foo= suggested.

Fixes #12374. Related to #9538.

Closes #12400
2026-01-31 14:12:50 +11:00
Daniel Rainer
e78e3f16e1 gettext: remove trailing newlines
Remove trailing newlines from msgids. Newlines do not need to be
localized, so translators should not have to care about them.

In addition to simplifying the jobs of translators using gettext, not
having trailing newlines also makes it easier to port localizations to
Fluent.

Closes #12399
2026-01-31 14:12:50 +11:00
Johannes Altmanninger
714c2f7373 builtin commandline: minor refactoring 2026-01-31 14:12:50 +11:00
Johannes Altmanninger
f1036beb1f Use std::iter::once 2026-01-31 14:12:50 +11:00
Daniel Rainer
bd4e55b149 io: delete unused append_narrow function
Closes #12396
2026-01-31 14:12:50 +11:00
Daniel Rainer
22e5e63a65 io: remove append_char
Its functionality is subsumed by `append`. In some cases, the call can
be omitted and replaced by an `appendln`.

Part of #12396
2026-01-31 14:12:49 +11:00
Daniel Rainer
414dba994f io: accept intoCharIter in more functions
This makes them more general than the previous versions which expected
`&wstr`. It comes at the cost of additional eager calls to `chars()`.

To implement `appendln` without having to call `append` twice, implement
`IntoCharIter` for chained iterators whose elements are both the kind of
iterator specified by `IntoCharIter`.

Because `IntoCharIter` is not implemented for owned types to avoid
allocations, some call sites which used to pass `WString` need to be
updated to pass references instead, which constitutes the bulk of the
changes in this commit.

Part of #12396
2026-01-31 14:12:49 +11:00
xtqqczze
934def3b75 clippy fix semicolon_if_nothing_returned lint
https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned

Closes #12395
2026-01-31 14:12:49 +11:00
JANMESH ARUN SHEWALE
74c2837d87 dnf: support subcommand aliases in completions
Closes #12393
2026-01-31 14:12:49 +11:00
xtqqczze
40c480c2cf clippy: fix nightly while_let_loop lint
https://rust-lang.github.io/rust-clippy/master/index.html#while_let_loop

Closes #12391
2026-01-31 14:12:49 +11:00
Johannes Altmanninger
ad82c7ebf1 fish_update_completions: fix escaping of | and ~
Fixes #12345
2026-01-31 14:12:49 +11:00
xtqqczze
86b126628c fix: update SourceLineCache to use NonNull for last_source pointer
Closes #12401
2026-01-31 14:12:49 +11:00
Johannes Altmanninger
24ee3afdae Address MSRV clippy lint 2026-01-31 14:12:49 +11:00
Peter Ammon
08a9f5e683 Remove LineCounter
LineCounter was a funny type which aided in eagerly computing line
numbers. It's no longer needed as we lazily compute lines, so remove it.
2026-01-30 09:30:57 -08:00
Peter Ammon
ffb09a429d Lazily compute line numbers
Prior to this commit, the line number of each block (say, begin, or
function call, etc) was computed eagerly and stored in the block. However
this line number is only used in rare cases, when printing backtraces.

Instead of storing the line number, store the node in the abstract syntax
tree along with the (shared) source text, and only compute the line numbers
when a backtrace is required.

This is about a ~4% improvement on seq_echo benchmark.
2026-01-30 09:27:17 -08:00
Johannes Altmanninger
87048330b7 Update to Rust 1.93 2026-01-30 15:34:43 +11:00
andreacfromtheapp
c2f7c5fbeb feat: add catpuccin themes
Apologies about the unsolicited PR. I hope this helps.

Adding Catppuccin themes from: https://github.com/catppuccin/fish

They note:

Q: Where's the Latte theme?
A: All three themes contain Latte as the light variant. Install any of
them, and then set your system or terminal theme to light mode.

Not sure about Fish Shell policy to keep them up to date here, I hope
this is not a nuissance.

Closes #12299
2026-01-30 15:34:43 +11:00
Tiago de Paula
4fde7e4f2f completion/quilt: list predefined spec filters
Closes #12370
2026-01-30 15:34:43 +11:00
Tiago de Paula
3369cf9a70 completion/quilt: complete grep
Part of #12370
2026-01-30 15:34:43 +11:00
Tiago de Paula
ff5e83cd42 completion/quilt: complete diff context sizes
Part of #12370
2026-01-30 15:34:43 +11:00
Tiago de Paula
193a564c8f completion/quilt: add patch name suggestions
Part of #12370
2026-01-30 15:34:43 +11:00
Tiago de Paula
296e2369d7 completion/quilt: handle refresh -z[name]
Avoid suggestions like `-zh`, `-z=[name]` and `-z [name]`.

Part of #12370
2026-01-30 15:34:43 +11:00
Tiago de Paula
16cb7cc550 completion/quilt: add switches for 0.69
Add missing switch options for quilt, synced with the latest version.

Part of #12370
2026-01-30 15:34:43 +11:00
Tiago de Paula
c86b8c8130 completion/quilt: make subcommands exclusive
Includes the missing `revert` command.

Part of #12370
2026-01-30 15:34:43 +11:00
Tiago de Paula
1b1badfd02 completion/quilt: split commands
Part of #12370
2026-01-30 15:34:43 +11:00
Tiago de Paula
b7f990fe4a completion/quilt: update descriptions
Part of #12370
2026-01-30 15:34:43 +11:00
Razzi Abuissa
e639efb77c completions/git: add some completions for git rev-parse
I took the verbiage mostly from `man git-rev-parse` (slightly shortened
since space is at a premium for completions):

       --is-inside-git-dir
           When the current working directory is below the repository directory print "true", otherwise "false".

       --is-inside-work-tree
           When the current working directory is inside the work tree of the repository print "true", otherwise "false".

Closes #12382
2026-01-30 15:34:43 +11:00
Luc J. Bourhis
41c2f8b9e0 completions/pandoc: deprecate --self-contained, add replacements
Closes #12385
2026-01-30 15:34:43 +11:00
Johannes Altmanninger
78b33eb47b changelog 2026-01-30 15:34:43 +11:00
xtqqczze
7e1164762c clippy fix nightly map_unwrap_or lint
https://rust-lang.github.io/rust-clippy/master/index.html#map_unwrap_or

Closes #12376
2026-01-30 15:34:43 +11:00
Tiago de Paula
8a9203e8e3 completion/pacman: suggest absolute paths for -F
Closes #12347
2026-01-30 15:34:43 +11:00
Tiago de Paula
99cae405ca completion/pacman: completions for -S $repo/$package
Part of #12347
2026-01-30 15:34:43 +11:00
Tiago de Paula
f11c9c5105 completion/pacman: fix argument order
- fixed argument order for `-Sg`, `-Sl`, `-Qg`, `-Qp` and `-Qo`
- removed completions for `-Dk`
- added "Package Group" completions for `-Q` and `-R`
- remove package completions for `-F `

Part of #12347
2026-01-30 15:34:43 +11:00
Tiago de Paula
f8f98d2581 completion/pacman: dump options for --arch and -U
Add lists with most known archictures for Arch Linux Ports and
all possible options for PKGEXT. Also simplified option list
for `--color` and improved completions for `--config`.

Part of #12347
2026-01-30 15:34:43 +11:00
Tiago de Paula
e7648662ae completion/pacman: list only installed groups for -Qg
Part of #12347
2026-01-30 15:34:43 +11:00
Tiago de Paula
69c4021646 completion/pacman: update descriptions
Some description were slightly off from what they currently do.
Also added `disable-sandbox*` options for Pacman 7.

Part of #12347
2026-01-30 15:34:43 +11:00
Tiago de Paula
d0084cb9df completion/pacman: enforce consistent style
Keep the same argument order and string quoting across the file.
Also avoid variables for simple function calls.

Part of #12347
2026-01-30 15:34:43 +11:00
Tiago de Paula
5f59582e63 completion/pacman: use function to check main operation
Should be simpler and safer than double expansion of a loop variable.

Part of #12347
2026-01-30 15:34:43 +11:00
Tiago de Paula
c89c516467 completion/pacman: sort options like the man page
Should hopefully be easier to update options it in the future.

Part of #12347
2026-01-30 15:34:43 +11:00
Johannes Altmanninger
40bf0e0ce9 tests/man: skip if documentation has not been built
Closes #12291
2026-01-30 15:34:43 +11:00
xtqqczze
07e3e924c3 build(deps): bump actions/checkout to 6 2026-01-30 08:06:16 +08:00
Johannes Altmanninger
f2bb5b5d7f Work around intermittent test_complete failure
test_complete and test_history_races both have the #[serial]
annotations.  Still, "cargo test" sometimes fails with

   thread 'complete::tests::test_complete' (370134) panicked at             │
   src/complete.rs:2814:13:                                                 │
   assertion `left == right` failed                                         │
     left: [("TTestWithColon", false), ("history-races-test-balloon",       │
   true), ("test/", true)]                                                  │
    right: [("TTestWithColon", false), ("test/", true)]                     │

I don't understand why this happens (filesystem race condition?)
but let's fix it by having "test_complete" ignore files from other
tests.

Fixes #12184
2026-01-27 22:10:05 +11:00
Johannes Altmanninger
3bd6771ae7 screen: fix test name 2026-01-27 22:06:52 +11:00
Johannes Altmanninger
527176ca97 test_driver: reduce default concurrency to reduce flakiness
Unlimited concurrency frequently makes system tests fail when when run
as "tests/test_driver.py" or "cargo xtask check".  Add a workaround
until we fix them.

Use $(nproc), which is already the default for RUST_TEST_THREADS
and CARGO_BUILD_JOBS, and it works pretty reliably on my laptop.
It's possible that we can increase it a bit to make it faster,
but until the tests are improved, we can't increase it much without
risking failures.

Ref: https://github.com/fish-shell/fish-shell/pull/12292#discussion_r2713370474

Tracking issue: #11815
2026-01-27 22:06:52 +11:00
Daniel Rainer
0cd8d64607 nix: get user info without direct libc calls
The `get_home` function has no users, so delete it instead of rewriting
it.

Closes #12380
2026-01-27 21:50:54 +11:00
Daniel Rainer
68e408b930 nix: use gethostname
Part of #12380
2026-01-27 21:50:54 +11:00
Daniel Rainer
74b03de449 nix: use killpg
Part of #12380
2026-01-27 21:50:54 +11:00
Daniel Rainer
ac1c77d499 wutil: use std file utils instead of libc in test
Part of #12380
2026-01-27 21:50:54 +11:00
Daniel Rainer
c7aaf4249a wutil: use std::fs::rename
Part of #12380
2026-01-27 21:50:54 +11:00
Daniel Rainer
11dda63f7b wutil: use std::fs::read_link
Part of #12380
2026-01-27 21:50:54 +11:00
Daniel Rainer
04b799c0c5 nix: use access
Part of #12380
2026-01-27 21:50:54 +11:00
Daniel Rainer
44f9363e39 wutil: libc::unlink -> std::fs::remove_file
Part of #12380
2026-01-27 21:50:54 +11:00
Daniel Rainer
43513d3fca sleep: use stdlib instead of libc::usleep
Part of #12380
2026-01-27 21:50:54 +11:00
Daniel Rainer
e41f2f6588 nix: use fchdir
Part of #12380
2026-01-27 21:50:54 +11:00
Daniel Rainer
17d870a842 nix: allow converting fish Pid to nix Pid
Part of #12380
2026-01-27 21:50:54 +11:00
Daniel Rainer
ab02558181 nix: use waitpid for disowned pids
Use the `nix::sys::wait::waitpid` function instead of libc's `waitpid`
for reaping disowned PIDs.
Note that this commit changes behavior. Previously, any updates received
for the PID were interpreted as the process having exited. However,
`waitpid` also indicates that processes were stopped or continued, or,
on Linux, that a ptrace event occurred. If the process has not exited,
it cannot be reaped, so I think it should be kept in the list of
disowned PIDs.

Part of #12380
2026-01-27 21:50:54 +11:00
Daniel Rainer
fa1a128aeb nix: use getpgrp wrapper
Part of #12380
2026-01-27 21:50:54 +11:00
Daniel Rainer
1f0a7e7697 nix: use wrappers for geteuid and getegid
The nix crate offers thin wrappers around these functions which allow us
to get rid of our own libc wrappers, reducing the amount of code marked
`unsafe`.

Part of #12380
2026-01-27 21:50:54 +11:00
Daniel Rainer
cce788388f encoding: remove or annotate WString::from_str
We want to discourage direct conversion from regular Rust strings to
`WString`, since our `WString`s are assumed to use the PUA encoding
scheme. If the input string contains certain PUA codepoints and the
resulting `WString` is decoded, it would not result in the same bytes as
the UTF-8 encoding of the input string. To avoid this, use
`str2wcstring`.

There are two remaining usages of `WString::from_str` which have been
annotated to indicate why they are there.
2026-01-27 11:14:04 +01:00
Daniel Rainer
a93c24b084 refactor: improve widestring conversion utils
- Don't use `WString::from_str` for `str`s which are available at
  compile-time. Use `L!(input).to_owned()` instead. The reason for this
  is that `WString::from_str` can cause problems if the input contains
  PUA bytes which we use for our custom encoding scheme. In such cases,
  `bytes2wcstring` should be used, to avoid problems when decoding the
  `WString`. Removing harmless usages of `WString::from_str` allows us
  to focus on the potentially dangerous ones which don't convert
  `str`'s that are compiled into the binary.
- Make `cstr2wcstring` actually take `CStr` as its input. The former
  version was only used in one place, and the conversion to `CStr`
  should happen there, where it can be checked that the conversion makes
  sense and is safe. The new version is used in
  `src/env/environmant.rs`, to avoid `to_bytes()` calls cluttering the
  code there.
- Add `osstr2wcstring` function. This function also works for `Path`.
  Now, these types can be converted to widestrings with much less
  syntactic clutter.
2026-01-27 11:14:04 +01:00
Johannes Altmanninger
6a2f531f9b try_apply_edit_to_autosuggestion: update icase matched codepoint counter
This function mutates the autosuggestion's search_string_range without
updating the number of matched codepoints accordingly, fix that.
Fixes 78f4541116 (reader: fix try_apply_edit_to_autosuggestion false
positive, 2026-01-22).

Fixes #12377
2026-01-26 02:22:48 +11:00
Johannes Altmanninger
eda1694581 try_apply_edit_to_autosuggestion: new test 2026-01-26 02:22:48 +11:00
Johannes Altmanninger
1854d03b95 wildcard: remove unneeded lock for local variable 2026-01-26 02:22:48 +11:00
xtqqczze
2180777f73 use nix::sys::signal::SigSet
Closes #12335
2026-01-25 03:40:12 +01:00
xtqqczze
f2fc779c94 Update feature(let_chains) TODO
Closes #12318
2026-01-25 03:40:12 +01:00
xtqqczze
3a024b6d8f Inline LazyLock helpers
Closes #12333
2026-01-25 03:40:12 +01:00
Next Alone
33d9957bcb completions: add claude command completions
Add tab completion support for claude CLI tool, including:
  - Top-level commands (doctor, install, mcp, plugin, setup-token, update)
  - Global options for model, agent, system prompt configuration
  - Tool and permission management options
  - MCP server configuration
  - IDE and Chrome integration settings
  - Output format and session management options
  - Sub-command specific help

Closes #12361
2026-01-25 03:40:12 +01:00
Daniel Rainer
28c0a8bc81 path: de-duplicate getter logic
Also remove comments which were already obsolete before these changes.

Closes #12365
2026-01-25 03:40:12 +01:00
Daniel Rainer
77471c500e path: use std::io::Error instead of raw ints
The functions we use already give us errors from `std`, so we might as
well use them, instead of converting them to raw libc errors.

Part of #12365
2026-01-25 03:40:12 +01:00
Johannes Altmanninger
98eaef2778 reader: remove obsolete workaround
We no longer use libc's locale-aware tolower etc.
2026-01-25 03:40:12 +01:00
Johannes Altmanninger
78f4541116 reader: fix try_apply_edit_to_autosuggestion false positive
Given command line ": i" and suggestion ": İnstall" whose lowercase
mapping is ": i\u{307}nstall", most of our code assumes that typing
"n" invalidates the autosuggestion.

This doesn't happen because try_apply_edit_to_autosuggestion thinks
that "i" has fully matched the suggestion's "İ".

Fix this inconsistency by recording the exact number of lowercase
characters already matched in the suggestion; then we only need to
compare the rest.

This allows us to restore an important invariant; this reverts
1d2a5997cc (Remove broken assert, 2026-01-21).
2026-01-25 03:40:12 +01:00
Johannes Altmanninger
2a3fe73a6d reader: unit-test try_apply_edit_to_autosuggestion 2026-01-25 03:38:11 +01:00
Johannes Altmanninger
9c3cb154d3 Revert "reader: Remove two more case-insensitive asserts"
See following commits.
This reverts commit 0778919e7f.
2026-01-25 03:38:11 +01:00
Johannes Altmanninger
4e68a36141 terminal: name some enum fields 2026-01-25 03:19:22 +01:00
Daniel Rainer
b62fa06753 asan: remove redundant handling
The special exit handling when running with address sanitization no
longer seems necessary. Our tests all pass without it.

Similarly, the leak sanitizer suppression is no longer needed, since we
don't get any warnings when running our checks without it.

Because our Rust code no longer has any ASAN-specific behavior, we don't
need the `asan` feature anymore.

Closes #12366
2026-01-25 03:19:22 +01:00
xtqqczze
17129f64db assertions: use assert_matches!
Closes #12348
2026-01-25 03:19:22 +01:00
Johannes Altmanninger
524c73d8b7 history search: remove unused "match everything" search type
The "match everything" search type is weird because it implicitly
overrules SearchFlags::IGNORE_CASE and the search string.

Remove it.
2026-01-25 03:19:22 +01:00
Johannes Altmanninger
78e91e6bc4 history search: prune call graph 2026-01-25 03:15:33 +01:00
Johannes Altmanninger
9d260cac0b reader autosuggestion: doc comments 2026-01-25 03:14:43 +01:00
Johannes Altmanninger
01d91dd65c history: unexport test-only constructors 2026-01-25 03:14:43 +01:00
xtqqczze
69d96e1e66 build.rs: inline fn canonicalize 2026-01-24 16:05:07 -08:00
Peter Ammon
1ab12dadac Remove "parse_util" prefix from functions in that module
This was a naming holdover from C++
2026-01-24 14:35:46 -08:00
Peter Ammon
a7dc701f26 Make ParseTreeFlags an ordinary struct instead of bitflags
Simplifies some code.
2026-01-24 14:05:34 -08:00
Peter Ammon
590ad9cd93 Rename var_err_len into VAR_ERR_LEN 2026-01-24 14:05:34 -08:00
Peter Ammon
cbca5177ea Adopt get_or_insert_with_default()
Minor cleanup of path.rs
2026-01-24 12:21:03 -08:00
Peter Ammon
e3105bee39 Fix out-of-tree builds
This fixes cmake builds outside of the fish-shell source tree.
2026-01-24 12:05:14 -08:00
Fabian Boehm
0778919e7f reader: Remove two more case-insensitive asserts
See #12326. Turns out there wasn't just one assert, it was three.

These can be triggered by entering (interactively) "flatpak in"
after having "flatpak İnstall" in your history so it's autosuggested.

Removing the asserts it generally *works* okay, and there's absolutely
no good reason for turning this into a crash.
2026-01-24 13:41:46 +01:00
Fabian Boehm
e36684786f completions/systemctl: List disabled units for start as well
I'm pretty sure this used to list "dead", now it shows "disabled".

Fixes #12368
2026-01-22 06:52:22 +01:00
Fabian Boehm
8fcd6524db Remove unused variable 2026-01-21 17:47:43 +01:00
Daniel Rainer
23fb01f921 cmake: don't build fish_test_helper
Our test driver (`tests/test_driver.py`) already builds this
unconditionally on each run, so there is no point in having CMake build
the binary as well. If we want to reduce the effort of rebuilding the
test helper on each invocation of the test driver, we could consider
some other caching approach, but it should work for non-CMake builds as
well. I consider this a low priority, since building the executable only
takes a few 10s of milliseconds on relatively modern hardware.

Closes #12364
2026-01-21 17:43:26 +01:00
Daniel Rainer
14915108d1 xtask: add man-pages task
Use the new xtask in CMake builds.

Closes #12292
2026-01-21 17:43:26 +01:00
Daniel Rainer
20cc07c5cd xtask: add html-docs task
This task is a bit annoying to implement because `sphinx-build` depends
on `fish_indent`, so that needs to be built, and the binary location
added to `PATH`.

Building `fish_indent` can be avoided by setting the `--fish-indent`
argument to the path to an existing `fish_indent` executable.

Use the new xtask in CMake builds. To do so without having to add
configuration options about where to put the docs, or having to copy
them from the default location to `build/user_doc`, we instead get rid of
the `user_doc` directory and change the code which accesses the docs to
read them from the non-configurable default output location in Cargo's
target directory.

Part of #12292
2026-01-21 17:43:26 +01:00
Daniel Rainer
2f74785620 xtask: add initial setup
This is an initial implementation of the cargo xtask approach
https://github.com/matklad/cargo-xtask

For now, the only xtask is "check", which can be triggered by running
`cargo xtask check`. It is a thin wrapper around `build_tools/check.sh`.

Part of #12292
2026-01-21 17:43:26 +01:00
Daniel Rainer
03894fea3c cmake: remove unnecessary dir nesting
The `cargo` directory in the CMake build directory is only used to store
Cargo's build output, as would be done by `target` when building without
CMake. But instead of putting the build output directly into the `cargo`
directory, a nested `build` directory was used. There is no point in
this nesting, so remove it.

Closes #12352
2026-01-21 17:43:26 +01:00
Daniel Rainer
f407ca18a4 docs: fix doc dir computation
`FISH_CMAKE_BINARY_DIR` is the top-level CMake output directory, not its
subdirectory used as the target directory by Cargo. So far, this has not
caused issues because CMake builds explicitly call `sphinx-build` to
build the man pages, instead of using the Rust crate for embedding them.

Closes #12354
2026-01-21 17:43:26 +01:00
Daniel Rainer
07394a1621 style.fish: canonicalize workspace root
Use a canonicalized absolute path for the workspace root to make errors
containing paths easier to read.

Closes #12359
2026-01-21 17:43:26 +01:00
Fabian Boehm
8bf416cd64 completions/flatpak: Fix broken cache usage
This can't work because __fish_cached calls out to /bin/sh for fairly dubious reasons,
and it tries to get it to run a function.

So just run the *command* that the function runs and do the added filtering outside.
2026-01-21 17:31:20 +01:00
Fabian Boehm
1d2a5997cc Remove broken assert
See #12326

I have been able to trigger this pretty reliably, and the simplest fix is
to... just not assert out when we would return anyway.

It doesn't reproduce with `commandline` because it needs the
suggestion to exist, it'll happen when you enter the "n" of "install"
if the suggestion is "İnstall" (i.e. uppercase turkish dotted i)

In general asserts in the reader make for a terrible experience.
2026-01-21 17:28:14 +01:00
Daniel Rainer
53e6758cc3 cmake: use variable for sphinx output dir
This clarifies the usage of the directory, simplifies usages, and makes
it easier to move the directory.

Closes #12353
2026-01-20 16:24:56 +00:00
Fabian Boehm
2df1fa90f1 completions/cargo: Uncouple from rustup completions
We could technically extract this into a function, but it's a trivial
one-liner.

This allows rustup completions to be independently overridden.

Fixes #12357
2026-01-20 16:43:54 +01:00
neglu
a454d53c28 realpath: allow multiple arguments
Closes #12344
2026-01-18 13:25:00 +01:00
xtqqczze
6d5948d814 update sphinx-doc url
Closes #12346
2026-01-18 13:25:00 +01:00
xtqqczze
18061ad177 refactor list_available_languages
remove the unnecessary temporary HashSet

Closes #12343
2026-01-18 13:25:00 +01:00
xtqqczze
8eb59bc500 clippy: fix stable_sort_primitive lint
https://rust-lang.github.io/rust-clippy/master/index.html#stable_sort_primitive

Part of #12343
2026-01-18 13:25:00 +01:00
xtqqczze
ddb3046ccd clippy: fix clippy::manual_assert lint
https://rust-lang.github.io/rust-clippy/master/index.html#manual_assert

Closes #12341
2026-01-18 13:25:00 +01:00
xtqqczze
5e3bc86268 clippy: fix explicit_into_iter_loop lint
https://rust-lang.github.io/rust-clippy/master/index.html#explicit_into_iter_loop

Closes #12340
2026-01-18 13:25:00 +01:00
xtqqczze
9dfb5705c5 Remove unnecessary qualification from size_of
Closes #12339
2026-01-18 13:25:00 +01:00
xtqqczze
66ea0f78be Use inline const expressions
Inline const expressions were stablised in Rust 1.79

Part of #12339
2026-01-18 13:25:00 +01:00
xtqqczze
c99c84558f clippy: fix format_push_string lint
https://rust-lang.github.io/rust-clippy/master/index.html#format_push_string

Closes #12338
2026-01-18 13:25:00 +01:00
Daniel Rainer
d35edcf5fa assertions: use assert_ne! where possible
Closes #12336
2026-01-18 13:25:00 +01:00
Daniel Rainer
8718d62b11 assertions: use assert_eq! where possible
Using `assert_eq!` instead of `assert!` has the advantage that when the
assertion fails, the debug representation of both sides will be shown,
which can provide more information about the failure than only seeing
that the assertion failed.

Part of #12336
2026-01-18 13:25:00 +01:00
Fabian Boehm
939fa25a5b Disable fossil prompt by default
Apparently `fossil changes --differ` is slow.

Fixes #12342
2026-01-17 15:53:41 +01:00
Daniel Rainer
93eb9ee4d8 wgetopt: extract into new crate
Move `src/wgetopt.rs` into a new dedicated crate.

Closes #12317
2026-01-16 16:22:34 +01:00
Daniel Rainer
154c095e66 wgetopt: remove dependencies on main lib
Only items from `fish_widestring`'s prelude are used, so depend on that
directly, to prepare for extraction.

Part of #12317
2026-01-16 16:22:33 +01:00
Johannes Altmanninger
50a97856dc Update rust-embed 2026-01-16 16:09:13 +01:00
Daniel Rainer
02cb93311a docs: use shared output dir for all docs
Prepare for having HTML docs in the build output as well as man pages.
To avoid cluttering the top-level build dir, introduce a new `fish-docs`
directory, and put directories for the different types of docs in it.

The doctrees (cache files for sphinx) will be put parallel to the output
directories, to have a clear separation between desired output and cache
files. Note that we use separate cache directories for the different
builders, since sphinx does not handle shared caches well.

Part of #12292
2026-01-16 11:40:47 +01:00
xtqqczze
49b3721b75 clippy: fix unnecessary_semicolon lint
https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_semicolon

Closes #12328
2026-01-16 11:40:47 +01:00
xtqqczze
db18515aed clippy: fix range_plus_one lint
https://rust-lang.github.io/rust-clippy/master/index.html#range_plus_one

Closes #12329
2026-01-16 11:40:44 +01:00
xtqqczze
2708191d3c clippy: fix ref_option lint
https://rust-lang.github.io/rust-clippy/master/index.html#ref_option

Closes #12327
2026-01-16 11:39:22 +01:00
xtqqczze
16612c6e49 Use Rust new_uninit feature
new_uninit was stabilised in Rust 1.82

Closes #12323
2026-01-16 11:39:22 +01:00
xtqqczze
40d45ee21e clippy: fix ptr_offset_by_literal lint
https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_by_literal

Closes #12322
2026-01-16 11:39:22 +01:00
xtqqczze
3df3b52b18 clippy: fix mut_mut lint
https://rust-lang.github.io/rust-clippy/master/index.html#mut_mut

Closes #12321
2026-01-16 11:39:22 +01:00
xtqqczze
efbf8b0203 Inline have_proc_stat
Closes #12319
2026-01-16 11:39:22 +01:00
Johannes Altmanninger
c84c006f42 util: remove code clone
Not in the right module yet but it's a start.
2026-01-16 11:39:22 +01:00
Daniel Rainer
97e0eda477 util: extract into new crate
Move `src/util.rs` into a new dedicated crate.

Closes #12316
2026-01-15 17:26:29 +01:00
Daniel Rainer
f1d78103e4 util: remove dependencies on main crate
Only items from `fish_widestring`'s prelude are used, so depend on that
directly, to prepare for extraction.

Part of #12316
2026-01-15 17:22:08 +01:00
Daniel Rainer
7072eec225 wcstringutil: extract into new crate
This moves the code from `src/wcstringutil.rs` into a new dedicated
crate.

Closes #12315
2026-01-15 17:20:07 +01:00
Daniel Rainer
9b1cda9025 wcstringutil: remove dependencies on main lib
This is done in preparation for extraction into its own crate.

Part of #12315
2026-01-15 17:19:00 +01:00
Daniel Rainer
2c06731a14 color: extract into new crate
This moves the code from `src/color.rs` into a new dedicated crate.

Closes #12311
2026-01-15 17:17:40 +01:00
Daniel Rainer
b14692cb95 color: be explicit about widestring usage
This eliminates the dependency on the main library crate, preparing
`src/color.rs` for extraction into a dedicated crate.

Part of #12311
2026-01-15 17:17:40 +01:00
Daniel Rainer
253f6726c0 widestring: rename wchar -> widestring
This is a more descriptive name for the crate.

https://github.com/fish-shell/fish-shell/pull/12311#discussion_r2681191208

Closes #12313
2026-01-15 17:17:40 +01:00
Daniel Rainer
36db3b7f3f wchar: remove dependency on fish_common
Now, the `fish_wchar` crate does not have any local dependencies, making
it easy to depend on it in other crates without worrying about cyclic
dependencies.

Additionally, remove the (non-fish) `widestring` crate as a direct
dependency of the main crate.
Now, only the `fish_wchar` and `fish_printf` crates directly depend on
`widestring`. `fish_printf` could also depend on `fish_wchar`, but I
left that as is since `fish_printf` was published, so depending on a
crate which is not published to crates.io does not seem like a good
idea.

Part of #12313
2026-01-15 17:17:20 +01:00
Daniel Rainer
385cdef89b wchar: don't wrap utf32str macro
There is no need to wrap this macro. We can just introduce `L` as an
alias.

https://github.com/fish-shell/fish-shell/pull/12311#discussion_r2681174391

Closes #12312
2026-01-15 17:07:13 +01:00
Johannes Altmanninger
72870d8331 forward-char: fix buffer overflow
Fixes 701c5da823 (forward-char: respect fish_cursor_end_mode again,
2026-01-12).

Fixes #12325
2026-01-14 18:28:04 +01:00
Johannes Altmanninger
081c469f6f tarball: include .cargo/config.toml again
The problem worked around by commit e4674cd7b5 (.cargo/config.toml:
exclude from tarball, 2025-01-12) is as follows:
our OBS packages are built by doing something like

	tar xf $tarball && tar xf $vendor_tarball

except that the tool apparently break when a file is present in
both tarballs.

Our workaround is to not include .cargo/config.toml in the tarball.

The workaround seems too broad. It need not affect all tarballs
but only the ones used by OBS. We want to add xtask aliases to
.cargo/config.toml. They will be used by CMake targets (sphinx-doc),
so they should be available to tarball consumers.

Restrict the scope of the workaround: add back .cargo/config.toml
to the export, and allow opting in to this behavioer by passing a
negative pathspec

	build_tools/make_tarball.sh :/!.cargo/config.toml
2026-01-14 18:28:04 +01:00
phanium
1affa7a16e bind: nextd-or-forward-word/prevd-or-backward-word don't emit nextd/prevd
Fixes bbb2f0de8d (feat(vi-mode): make word movements
vi-compliant,2026-01-10)

Closes #12320
2026-01-13 11:59:48 +01:00
Johannes Altmanninger
701c5da823 forward-char: respect fish_cursor_end_mode again
Fixes bbb2f0de8d (feat(vi-mode): make word movements vi-compliant,
2026-01-10).

When setting cursor pos, we need to make sure to call update_buff_pos,
which knows whether the one-past-last character ought to be selectable.
2026-01-13 11:59:48 +01:00
Daniel Rainer
860f75ee97 tarballs: append to cargo config
This allows putting other configuration into the config file without it
being deleted for tarballs.

https://github.com/fish-shell/fish-shell/pull/12292#discussion_r2678697643
2026-01-12 19:49:32 +01:00
Daniel Rainer
334710ebf7 cargo: remove obsolete config
The settings we had in `.cargo/config.toml` correspond to the defaults
in Rust 2024, so there is no point in setting them explicitly.

https://github.com/fish-shell/fish-shell/pull/12292#discussion_r2678697643
2026-01-12 19:49:32 +01:00
phanium
b15da3e118 bind: forward-word to go to end of line again
Fixes bbb2f0de8d (feat(vi-mode): make word movements vi-compliant,
2026-01-10)

Closes #12314
2026-01-12 19:40:45 +01:00
David Adam
f1a9b9bf43 CHANGELOG: editing for clarity and formatting 2026-01-12 23:10:01 +08:00
David Adam
abffe983f8 Debian packaging: correct sphinx dependency name 2026-01-12 22:19:42 +08:00
Johannes Altmanninger
b363e4afe7 tests/checks/version: support shallow clones 2026-01-12 13:04:56 +01:00
Johannes Altmanninger
b60582ff75 build.rs: remove code duplication in version computation
get_version() in build.rs duplicates some logic in
build_tools/git_version_gen.sh. There are some differences

1. When computing the Git hash, get_version() falls back to reading
  .git/HEAD directly if "git describe" fails
1.1. Git is not installed
     Not sure if this is a good strong reason. If you don't have
     Git installed, how would you have created ".git"? If the exact
     Git SHA is important, maybe we should use something like gitoxide
     for this rather than implementing our own.
1.2. there is a permission problem
     The case mentiond in 0083192fcb (Read git SHA ourselves if it
     is unavailable, 2024-12-09) doesn't seem to happen with current
     versions of Git: "sudo git describe" works fine.  Something like
     "sudo -u postgres git describe" doesn't. We could support that
     but let's wait until we know of a use case.
1.3 there are no tags
    (when doing "cargo install --git", as mentioned in 0dfc490721
    (build.rs: Use Cargo_PKG_VERSION if no version could be found,
    2024-06-10)).
    Missing tags are no longer a problem because we read the version
    from Cargo.toml now. Tweak the script to make sure that the
    version is 4.3.3-g${git_sha} instead of just ${git_sha}.

2. get_version() falls back to jj too.
   That was added for jj workspaces that don't have a Git worktree;
   but those should be one their way out; when using jj's Git backend,
   all workspaces will get an associated worktre.
2026-01-12 12:17:48 +01:00
Johannes Altmanninger
92dae88f62 tarball: remove redundant "version" file
Use the version in Cargo.toml instead.

Print a warning if the Cargo.toml version is not a prefix of the Git
version.  This can happen legit scenarios, see 0dfc490721 (build.rs:
Use Cargo_PKG_VERSION if no version could be found, 2024-06-10)
but the next commit will fix that.

Also remove stale comments in git_version_gen.sh.
2026-01-12 12:17:48 +01:00
Johannes Altmanninger
f7d9c92820 git_version_gen: don't silence stderr
This should never fail, and error output doesn't hurt here.
2026-01-12 12:17:48 +01:00
Daniel Rainer
860bba759d git_version_gen: always output to stdout
Now that the script no longer writes to files, we can remove the
`--stdout` flag and instead output to stdout by default.

Closes #12307
2026-01-12 12:17:27 +01:00
Daniel Rainer
564ef66665 git_version_gen: remove obsolete code
The `git_version_gen.sh` script is no longer used to write any files, so
remove the logic for it.

This code included handling for permission problems when running `git
describe`. It was introduced by
15f1b5f368, but unfortunately without
mentioning which CVE caused the change in git. I found CVE-2022-24765,
which was published not long before the commit was made, and its
description looks like it's fitting. On a recent version of git
(2.52.0), I had no problems running `make && sudo make install`, so it
seems like this issue might no longer be relevant. One suboptimal thing
to note is that `sudo make install` currently builds `fish_indent` even
if it was built via `make` before, which is not great, but unrelated to
these changes.

Part of #12307
2026-01-12 12:17:27 +01:00
Daniel Rainer
c8642efeb0 cmake: remove version file handling
This version file handling is no longer in use. Version strings are
generated on-demand using either `build_tools/git_version_gen.sh` or the
Rust implementation in `build.rs`. This makes the CMake code for version
handling obsolete.

Note that the current handling for version strings in Rust builds is
imperfect. If none of the build inputs change, the Rust code will not be
rebuilt, meaning the version strings in the executables are not updated.
This has been the case for a while and is not caused by this patch
series. This trade-off has been deemed worthwhile, because it simplifies
the implementation and eliminates the need for rebuilds when only the
version string changed. Because any changes to the actual input files
will trigger rebuilds, the version string will reference a commit which
is close enough to the actual version that it should not cause problems.

Part of #12307
2026-01-12 12:17:27 +01:00
Daniel Rainer
309bb778af cmake: use script for setting version in fish.pc
The `build_tools/git_version_gen.sh` script can be used to determine the
appropriate version string. With this change, the convoluted version
file generation logic in CMake is no longer used and can subsequently be
removed.

Part of #12307
2026-01-12 12:17:27 +01:00
Daniel Rainer
36c340b40f cmake: remove obsolete version env var
The `FISH_BUILD_VERSION_FILE` variable was only read in
`doc_src/conf.py`. There, it can be replaced by the
`build_tools/git_version_gen.sh` script, which takes the version from a
file called `version` at the workspace root if one exists, and otherwise
from git. This should cover all cases where the docs are built, so there
is no need to keep using the `FISH_BUILD_VERSION_FILE` variable.

Part of #12307
2026-01-12 12:17:27 +01:00
Johannes Altmanninger
a79c54be66 shell_modes: clear the FLUSHO flag
On macOS, pressing ctrl-o (VDISCARD) before starting fish will discard
all terminal output, from shell or its child processes. This breaks
querying and seems like something we don't want to support, so maybe
disable it?

Not sure if term_fix_external_modes needs it too, add it I guess.

Fixes #12304
2026-01-12 12:17:27 +01:00
Johannes Altmanninger
143c8c4ffd termios: slim down reference graph 2026-01-12 09:44:42 +01:00
Daniel Rainer
116bcdac28 common: extract more code into separate crate
This extracts the remaining code from `src/common.rs` which does not
depend on other parts of the main library crate. No functional changes.

Closes #12310
2026-01-12 09:44:42 +01:00
Daniel Rainer
4762d6a0a7 common: extract constants into crate
Part of #12310
2026-01-12 07:37:23 +01:00
Daniel Rainer
6e00deffd0 common: remove unused constant
There was only a single usage of `EMPTY_STRING`, and there it was
immediately dereferenced, so use an empty static `&wstr` instead and
remove the `WString` constant.

Closes #12309
2026-01-12 07:34:23 +01:00
Johannes Altmanninger
34f3e5ef23 __fish_change_key_bindings: remove dead code
We embed share/functions/*.fish now, so we should be able to assume
that "set --no-event" works.
2026-01-11 21:12:40 +01:00
Johannes Altmanninger
b9dfbcee13 Fix spurious status=1 from calling binding function from config
A command like "fish -C fish_default_key_bindings" shows a exit status
of 1 in the default prompt. Fix that.
2026-01-11 21:12:40 +01:00
Johannes Altmanninger
de2ac37c92 Extract typedef for AtomicU64 2026-01-11 21:12:40 +01:00
Daniel Rainer
a194a557c5 cmake: remove obsolete doc setup
The `conf.py` file that was copied is not used for building. It seems
that it was used as a mechanism for triggering rebuilds on changes to
the original file, but in the current setup, `sphinx-build` is called
unconditionally when the relevant targets are built, so there is no
point in keeping on copying the `conf.py` file.

Closes #12303
2026-01-11 21:12:40 +01:00
iksuddle
8e34dc4cdb bind: show all modes by default
Ensure `bind` builtin lists binds for all modes if `--mode` is not
given.

- The `get` function in `src/input.rs` now takes an optional bind
  mode and returns a list of input mappings (binds).
- The `list_one` function in `src/builtins/bind.rs` lists binds in
  the results returned by `get`.
- Creating the output string for a bind has been extracted to its
  own function: `BuiltinBind::generate_output_string`.
- The `bind_mode_given` option has been removed.

Fixes #12214

Closes #12285
2026-01-11 21:12:40 +01:00
SharzyL
bbb2f0de8d feat(vi-mode): make word movements vi-compliant
- The behavior of `{,d}{w,W}`, `{,d}{,g}{e,E}` bindings in vi-mode is
  now more compatible with vim, except that the underscore is not a
  keyword (which can be achieved by setting `set iskeyword-=_` in vim).

- Add commands `{forward,kill}-{word,bigword}-vi`,
  `{forward,backward,kill,backward-kill}-{word,bigword}-end` and
  `kill-{a,inner}-{word,bigword}` corresponding to above-mentioned
  bindings.

- Closes #10393.

Closes #12269

Co-authored-by: Johannes Altmanninger <aclopte@gmail.com>
2026-01-11 21:12:40 +01:00
SharzyL
4c3fcc7b16 feat(wchar): add word_char module for vi-mode character classification
Part of #12269
2026-01-11 21:12:40 +01:00
Johannes Altmanninger
f33fef3ca3 word_motion: rewrite state machine logic
The state machine uses polymorphic state stored as a raw u8.  This is
not very idiomatic Rust.

Define proper enum types. This helps the upcoming behavior change.

Ref: https://github.com/fish-shell/fish-shell/pull/12269#discussion_r2679005387

Co-authored-by: SharzyL <me@sharzy.in>
2026-01-11 21:12:40 +01:00
Johannes Altmanninger
10537df82d word_motion: remove unused function 2026-01-11 21:12:40 +01:00
SharzyL
8af6b07d07 word_motion: tighten test assertions 2026-01-11 21:12:40 +01:00
SharzyL
c014c95e1b word_motion: deduplicate type
Co-authored-by: Johannes Altmanninger <aclopte@gmail.com>
2026-01-11 21:12:40 +01:00
Johannes Altmanninger
bd86f53b9f Extract MoveWordStateMachine to a reader submodule
This has a very small dependency on the tokenizer.
2026-01-11 21:12:40 +01:00
SharzyL
042117ee30 refactor(tokenizer): use unqualified names in word motion tests
Add `use Direction::*` and `use MoveWordStyle::*` in tests to reduce
verbosity. Reformat tests to one-line style and reorder by test type.
No behavior change.

Part of #12269
2026-01-11 18:37:14 +01:00
Heitor Augusto
38e633d49b fish_vi_key_bindings: add support for count
Closes #12170
2026-01-11 18:37:14 +01:00
Peter Ammon
ce286010a8 Remove a stale comment 2026-01-10 09:52:18 -08:00
Wang Bing-hua
ef18b6684b history: fix highlighting for inline timestamps
Highlighting the entire record caused custom prefixes to be
parsed as command syntax. For example, using:
`history --show-time="[%Y-%m-%d %H:%M:%S] "`
resulted in the timestamp being colorized as shell code.

Move highlighting inside format_history_record to process the
command string before the timestamp is prepended.

Closes #12300
2026-01-10 13:46:46 +01:00
Ilya Grigoriev
ab984f98ab completions: add completions for ijq
https://codeberg.org/gpanders/ijq
https://github.com/gpanders/ijq

For comparison purposes, here's the output of `ijq --help`
as of ijq 1.2.0:

```
ijq - interactive jq

Usage: ijq [-cnsrRMSV] [-f file] [filter] [files ...]

Options:
  -C	force colorized JSON, even if writing to a pipe or file
  -H string
    	set path to history file. Set to '' to disable history. (default "/Users/ilyagr/Library/Application Support/ijq/history")
  -M	monochrome (don't colorize JSON)
  -R	read raw strings, not JSON texts
  -S	sort keys of objects on output
  -V	print version and exit
  -c	compact instead of pretty-printed output
  -f filename
    	read initial filter from filename
  -hide-input-pane
    	hide input (left) viewing pane
  -jqbin string
    	name of or path to jq binary to use (default "jq")
  -n	use `null` as the single input value
  -r	output raw strings, not JSON texts
  -s	read (slurp) all inputs into an array; apply filter to it
```

Closes #12297
2026-01-10 13:46:46 +01:00
Johannes Altmanninger
cfadb2de36 Temporary hack to restore historical behavior of "read --prompt-str ''"
As mentioned in commit 289057f981 (reset_abandoning_line: actually
clear line on first prompt, 2025-11-11), we want to eventually allow
builtin read with a starting cursor with x>0.  Until then, add a hack
to restore historical behavior in the case that users observed.

See #12296
2026-01-10 13:46:46 +01:00
Johannes Altmanninger
3d0b378c40 test_wwrite_to_fd: remove redundant assertion
Also should have been -1, not 0.
Ref: https://github.com/fish-shell/fish-shell/pull/12199#discussion_r2677040787
2026-01-10 13:46:46 +01:00
Daniel Rainer
aa56359834 gettext: use wgettext_fmt for formatting
Using `wgettext_fmt` instead of `wgettext` + `sprintf` in these cases
allows for proper localization of the colons.
2026-01-10 13:46:46 +01:00
Johannes Altmanninger
a0a60c2d29 completions/git: cover up some plumbing subcommands
Also hide show-branch, it doesn't seem very useful?

See 400d5281f4 (r174249792)
2026-01-10 13:46:46 +01:00
Johannes Altmanninger
324223ddff history: assume pager supports color sequences
Git does the same, try: git -c core.pager='cat -v' show

Closes #12298
2026-01-10 13:46:46 +01:00
Johannes Altmanninger
58e7a50de8 Fix line-wise autosuggestion false positive when line doesn't start command
To reduce the likelihood of false positive line-wise history
autosuggestions, we only them when the cursor's line starts a new
process ("parse_util_process_extent").

There are still false positives. Given

	$ true &&
          somecommand
	$ echo "
	someothercommand
	"

typing "some" suggests "someothercommand" from history even though
that was not actually used as command.

Fix this by using similar rules for suggestion candidates.

Might help #12290
2026-01-10 13:46:46 +01:00
Johannes Altmanninger
739b82c34d Fix line-wise autosuggestion false positive when command doesn't exist
If my history has

	git clean -dxf &&
	./autogen.sh &&
	./configure --prefix=...

then autosuggestions for "./conf" will show the third line, even if
./configure does not exist.

This is because even for line-wise autosuggestions, we only check
validity of the first command ("git"). Fix that by checking
the command from the line that's actually suggested.

The next commit will fix the issue that line-wise autosuggestions
may not actually be commands.

See also #12290
2026-01-10 13:46:46 +01:00
Johannes Altmanninger
b5bf9d17e3 OSC 7: also escape hostname
I think gethostname() is not guaranteed to return only URL-safe
characters, so better safe than sorry.
2026-01-10 13:46:46 +01:00
Johannes Altmanninger
917fb024ea end-of-buffer: accept autosuggestion if already at ned 2026-01-09 10:29:10 +01:00
Johannes Altmanninger
7a05ea0f93 Reapply "cmake: rename WITH_GETTEXT to WITH_MESSAGE_LOCALIZATION"
This reverts commit 94fdb36f6b.
2026-01-07 08:56:03 +01:00
Johannes Altmanninger
5d75c47fcc start new cycle
Created by ./build_tools/release.sh 4.3.3
2026-01-07 08:52:39 +01:00
Johannes Altmanninger
c98fd886fd Release 4.3.3
Created by ./build_tools/release.sh 4.3.3
2026-01-07 08:34:20 +01:00
Johannes Altmanninger
94fdb36f6b Revert "cmake: rename WITH_GETTEXT to WITH_MESSAGE_LOCALIZATION"
This reverts commit 77e1aead40 for the
patch release.
2026-01-07 08:32:33 +01:00
Johannes Altmanninger
d1a40ace7d changelog: fix RST syntax 2026-01-07 08:32:20 +01:00
Johannes Altmanninger
dd4d69a288 cirrus: fix FreeBSD pkg install failure
Multiple PRs fail with

	pkg: Repository FreeBSD-ports cannot be opened. 'pkg update' required
	Updating database digests format: . done
	pkg: No packages available to install matching 'cmake-core' have been found in the repositories
2026-01-07 08:01:21 +01:00
Daniel Rainer
e16ea8df11 sync: once_cell::sync::OnceCell -> std::sync::OnceLock
Rust 1.70 stabilized `std::sync::OnceLock`, which replaces
`once_cell::sync::OnceCell`.

With this, we only have a single remaining direct dependency on
`once_cell`: `VAR_DISPATCH_TABLE` in `src/env_dispatch.rs`, where we use
`Lazy::get`. This can be replaced with `LazyLock::get` once our MSRV
reaches 1.94, where the function is stabilized.

At the moment, `serial_test` depends on `once_cell`, so even if we
eliminate it as a direct dependency, it will remain a transitive
dependency.

Closes #12289
2026-01-07 07:59:24 +01:00
Daniel Rainer
80e1942980 sync: once_cell::sync::Lazy -> std::sync::LazyLock
Rust 1.80 stabilized `std::sync::LazyLock`, which replaces
`once_cell::sync::Lazy`. There is one exception in
`src/env_dispatch.rs`, which still uses the `once_cell` variant, since
the code there relies on `Lazy::get`, which also exists for `LazyLock`,
but will only be stabilized in Rust 1.94, so we can't use it yet.

Part of #12289
2026-01-07 07:59:24 +01:00
Johannes Altmanninger
99109278a6 Enable color theme reporting again on tmux >= 3.7
Color theme reporting has race conditions, so we might want to disable
it until we have fixed those. Not sure.

At least the tmux-specific issue hsa been fixed,
so treat new tmux like other terminals.
See https://github.com/tmux/tmux/issues/4787#issuecomment-3716135010

See #12261
2026-01-07 07:59:24 +01:00
Johannes Altmanninger
f924a880c8 Update changelog 2026-01-07 07:59:23 +01:00
Johannes Altmanninger
5683d26d24 github: update pull request template
Repeat here that 'Fixes #' should go into commit message, and remove
redundant PR description.
2026-01-07 07:35:30 +01:00
Lumynous
740aef06df l10n(zh-TW): Complete untranslated strings
Closes #12288
2026-01-07 07:35:30 +01:00
Daniel Rainer
557f6d1743 check: allow overriding default Rust toolchain
This is useful for running the checks with a toolchain which is
different from the default toolchain, for example to check if everything
works with our MSRV, or on beta/nightly toolchains. Additionally,
providing a way to run using the nightly toolchain allows writing
wrappers around `check.sh` which make use of nightly-only features.

The toolchain could be changed using `rustup toolchain default`, but if
the toolchain should only be used for a specific run, this is
inconvenient, and it does not allow for concurrent builds using
different toolchains.

Closes #12281
2026-01-06 17:54:56 +00:00
Johannes Altmanninger
8d257f5c57 completions/fastboot: one item per line 2026-01-06 14:29:32 +01:00
Johannes Altmanninger
d880a14b1a changelog: add sections 2026-01-06 14:29:32 +01:00
Next Alone
d4fcc00821 completions(fastboot): sync partitions from Xiaomi images
Signed-off-by: Next Alone <12210746+NextAlone@users.noreply.github.com>

Closes #12283
2026-01-06 14:29:32 +01:00
Johannes Altmanninger
6d8bb292ec fish_config theme choose: overwrite color-aware theme's vars also if called from config
Webconfig persists themes to ~/.config/fish/conf.d/fish_frozen_theme.fish
(the name is due to historical reasons).

That file's color variables have no "--theme=foo" annotations, which
means that fish_config can't distinguish them from other "user-set"
values.  We can change this in future, but that doesn't affect the
following fix.

A "fish_config theme choose foo" command is supposed to
overwrite all variables that are defined in "foo.theme".
If the theme is color-theme-aware *and* this command runs before
$fish_terminal_color_theme is initialized, we delay loading of the
theme until that initialization happens.  But the --on-variable
invocation won't have the override bit set, thus it will not touch
variables that don't have "--theme=*" value.  Fix this by clearing
immediately the variables mentioned in the theme.

Fixes #12278

While at it, tweak the error message for this command because it's
not an internal error:

	fish -c 'echo yes | fish_config theme save tomorrow'
2026-01-06 14:29:32 +01:00
Lennard Hofmann
c638401469 Speedup syntax highlighting of redirection targets
Instead of checking twice whether the redirection target is a valid file,
use the return value from test_redirection_target().

Closes #12276
2026-01-06 10:39:58 +01:00
Fabian Boehm
5930574d8a README: Mention cargo
A bit pedantic, we're also not mentioning that you need a linker, but
oh well.

Fixes #12277
2026-01-05 17:16:33 +01:00
Daniel Rainer
fdef7c8689 l10n: add initialize_localization function
This replaces `initialize_gettext`. It is only defined when the
`localize-messages` feature is enabled, to avoid giving the impression
that it does anything useful when the feature is disabled.

With this change, Fluent will be initialized as well once it is added,
without requiring any additional code for initialization.

Closes #12190
2026-01-05 15:12:34 +00:00
Daniel Rainer
5c36a1be1b l10n: create gettext submodule
Put the gettext-specific code into `localization/gettext`.

Part of #12190
2026-01-05 15:12:34 +00:00
Daniel Rainer
14f747019b l10n: create localization/settings
Extract the language selection code from the gettext crate, and to a
lesser extent from `src/localization/mod.rs` and put it into
`src/localization/settings.rs`. No functional changes are intended.

Aside from better separation of concerns, this refactoring makes it
feasible to reuse the language selection logic for Fluent later on.

Part of #12190
2026-01-05 15:12:34 +00:00
Johannes Altmanninger
d7d5d2a9be completions/make: fix on OpenBSD/FreeBSD
Tested with the POSIX Makefile from https://github.com/mawww/kakoune

Closes #12272
2026-01-05 12:52:00 +01:00
Johannes Altmanninger
750955171a __fish_migrate: don't leak standard file descriptors
The __fish_migrate.fish function spawns a "sh -c 'sleep 7' &" child
process that inherits stdin/stdout/stderr file descriptors fish.

This means that if the app running "fish
tests/checks/__fish_migrate.fish" actually waits for fish to close its
standard file descriptors, it will appear to hang for 7 seconds. Fix
that by closing the file descriptors in the background job when
creating it.

Closes #12271
2026-01-05 12:52:00 +01:00
Denys Zhak
36fd93215b fish_indent: Keep braces on same line in if/while conditions
Closes #12270
2026-01-05 12:50:19 +01:00
Lennard Hofmann
6e7353170a Highlight valid paths in redirection targets
Closes #12260
2026-01-05 12:50:19 +01:00
Peter Ammon
62cc117c12 Minor refactoring of add_to_history
Preparation for other refactoring in the future.
2026-01-04 12:33:53 -08:00
Peter Ammon
af00695383 Clean up replace_home_directory_with_tilde
Fix a stale comment and add a test.
2026-01-04 11:08:21 -08:00
Johannes Altmanninger
85ac91eb2b fish_config theme choose: fix Tomorrow always using light version
The backward compat hack canonicalization caused us to always treat
"tomorrow" light theme.

Restrict this hack to the legacy name (Tomorrow); don't do it when
the new canonical name (tomorrow) is used.  The same issue does not
affect other themes because their legacy names always have a "light"
or 'dark' suffix, which means that the canonical name is different,
so the legacy hacks don't affect the canonical name.

Fixes #12266
2026-01-04 13:08:26 +01:00
Johannes Altmanninger
d1ed582919 fish_config theme choose: apply backwards compat hacks only to sample themes
This logic exists to not break user configurations as we renamed
themes.  But user-sourced themes haven't been renamed.

(It's also questionable whether we should really have these compat
hacks; they might cause confusion in the long run).
2026-01-04 13:08:26 +01:00
xtqqczze
06a14c4a76 clippy: fix assigning_clones lint
https://rust-lang.github.io/rust-clippy/master/index.html#assigning_clones

Closes #12267
2026-01-04 13:08:26 +01:00
takeokunn
400d5281f4 feat(git-completion): add missing options and completions for commands
- Add missing options and completions for fetch, show-branch, am,
  checkout, archive, grep, pull, push, revert, rm, config, clean, and
  other commands
- Replace TODO comments with actual option completions for improved
  usability
- Ensure all new options have appropriate descriptions and argument
  handling for fish shell completion

Closes #12263
2026-01-04 13:08:26 +01:00
Johannes Altmanninger
50778670fb Disable color theme reporting in tmux for now
Due to the way tmux implements it, color theme reporting
causes issues when typing commands really quickly (such as
when synthesizing keys).  We're working on fixing this, see
https://github.com/tmux/tmux/issues/4787#issuecomment-3707866550
Disable it for now. AFAIK other terminals are not affected.

Closes #12261
2026-01-04 13:08:26 +01:00
WitherZuo
9037cd779d Optimize functions page style of fish_config.
- Fix the background color of .function-body in dark mode to improve readability.
- Switch to Tomorrow Night Bright color theme for better contrast and readability in dark mode.
- Format all stylesheets of fish_config.

Closes #12257
2026-01-04 13:08:26 +01:00
phanium
c23a4cbd9f Add --color option for some builtins
Fixes #9716

Closes #12252
2026-01-04 13:08:26 +01:00
Johannes Altmanninger
5d8f7801f7 builtin fish_indent/fish_key_reader: call help from existing fish process
Something like

	PATH=mypath builtin fish_indent --help

runs "fish -c '__fish_print_help fish_indent'" internally.  Since we
don't call setenv(), the PATH update doesn't reach the child shell.
Fix this by using what other builtins use if we are one (i.e. if we
have a Parser in context).

Fixes #12229
Maybe also #12085
2026-01-04 13:08:26 +01:00
Johannes Altmanninger
756134cf2b test/tmux-complete3: fail more reliably 2026-01-04 13:08:26 +01:00
Johannes Altmanninger
c16677fd6f tty_handoff: use Drop consistently
We sometimes use explicit reclaim() and sometimes rely on the drop
implementation. This adds an unnecesary step to reading all uses of
this code.  Make this consistent. Use drop everywhere though we could
use explicit reclaim too.
2026-01-04 13:08:26 +01:00
Johannes Altmanninger
13bc514aa6 __fish_complete_directories: remove use of empty variable
Closes #12248
2026-01-04 09:42:25 +01:00
Johannes Altmanninger
1c3403825c completions/signify: consistent style
Also, replace use of "ls" with globbing.
2026-01-04 09:42:25 +01:00
LunarEclipse
6f1ac7c949 Prioritize files with matching extensions for flag arguments in signify completions
Closes #12243
2026-01-04 09:42:25 +01:00
LunarEclipse
f5d3fd8a82 Full completions for openbsd signify
Part of #12243
2026-01-04 09:42:25 +01:00
Johannes Altmanninger
0a23a78523 Soft-wrapped autosuggestion to hide right prompt for now
Prior to f417cbc981 (Show soft-wrapped portions in autosuggestions,
2025-12-11), we'd truncate autosuggestions before the right prompt.
We no longer do that for autosuggestions that soft-wrap, which means
we try to draw both right prompt and suggestion in the same space.

Make suggestion paint over right prompt for now, since this seems to
be a simple and robust solution.  We can revisit this later.

Fixes #12255
2026-01-03 15:54:04 +01:00
xtqqczze
725cf33f1a fix: remove never read collection from parse_cmd_opts
Closes #12251
2026-01-03 15:54:04 +01:00
xtqqczze
2d6db3f980 clippy: fix implicit_clone lint
https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone

Closes #12245
2026-01-03 15:54:04 +01:00
xtqqczze
41b9584bb3 clippy: fix cloned_instead_of_copied lint
https://rust-lang.github.io/rust-clippy/master/index.html#cloned_instead_of_copied

Closes #12244
2026-01-03 15:54:04 +01:00
Tin Lai
c915435417 respect canonical config for untracked files
Signed-off-by: Tin Lai <tin@tinyiu.com>

Closes #11709
2026-01-03 15:54:04 +01:00
Johannes Altmanninger
afcde1222b Update cargo dependencies
cargo update && cargo +nightly -Zunstable-options update --breaking
2026-01-03 15:54:04 +01:00
Benjamin A. Beasley
a3cb512628 Update phf from 0.12 to 0.13
Closes #12222
2026-01-03 15:54:04 +01:00
Johannes Altmanninger
fc71ba07da share: fix typo 2026-01-03 15:54:04 +01:00
Johannes Altmanninger
9c867225ee reader handle_completions(): remove code duplication
We fail to flash the command line if we filter out completions due
to !reader_can_replace. Fix that and de-duplicate the logic
2026-01-03 15:54:04 +01:00
Johannes Altmanninger
972355e2fc reader handle_completions(): remove stale comment
See 656b39a0b3 (Also show case-insensitive prefix matches in completion pager, 2025-11-23).
2026-01-03 15:54:04 +01:00
Johannes Altmanninger
8f4c80699f reader handle_completions(): don't allocate a second completion list 2026-01-03 15:54:04 +01:00
Johannes Altmanninger
e79b00d9d1 reader handle_completions(): also truncate common prefix when replacing
I don't know why we don't apply the common-prefix truncation logic
when all completions are replacing.
Let's do that.
2026-01-03 15:54:04 +01:00
Johannes Altmanninger
2f6b1eaaf9 reader handle_completions(): don't consider odd replacing completions for common prefix
If "will_replace_token" is set, we generally only consider
appending completions.  This changed in commit 656b39a0b3 (Also show
case-insensitive prefix matches in completion pager, 2025-11-23) which
also allowed icase completions as long as they are also prefix matches.

Such replacing completions might cause the common prefix to be empty,
which breaks the appending completions.

Fix this by not considering these replacing completions for the
common-prefix computation. The pager already doesn't show the prefix
for these completions specifically.

Fixes #12249
2026-01-03 15:54:04 +01:00
Johannes Altmanninger
3546ffa3ef reader handle_completions(): remove dead filtering code
We skip completions where "will_replace_token != c.replaces_token()".
This means that
- if will_replace_token, we filter out non-replacing completions.
  But those do not exist because, by definition, will_replace_token
  is true iff there are no non-replacing completions.
- if !will_replace_token, we filter out replacing completions.
  From the definition of will_replace_token follows that there is
  some non-replacing completion, which must be a prefix or exact match.
  Since we've filtered by rank, any replacing ones must have the same rank.
  So the replacement bit must be due to smartcase.  Smartcase
  completions are already passed through explicitly here since
  656b39a0b3 (Also show case-insensitive prefix matches in completion
  pager, 2025-11-23).

So the cases where we 'continue' here can never happen.
Remove this redundant check.
2026-01-03 15:54:04 +01:00
Johannes Altmanninger
30f96860a7 reader handle_completions(): closed form for pager prefix bool 2026-01-03 15:54:04 +01:00
Johannes Altmanninger
41d50f1a71 reader handle_completions(): don't duplicate pager prefix allocation
While at it, use Cow I guess?
2026-01-03 15:54:04 +01:00
Johannes Altmanninger
1e9c80f34c reader handle_completions(): don't allocate common prefix 2026-01-03 15:54:04 +01:00
Johannes Altmanninger
b88d2ed812 reader handle_completions(): don't clone surviving completions 2026-01-03 15:54:04 +01:00
Johannes Altmanninger
92dd37d3c7 reader handle_completions(): remove dead code for skipping to add prefix
The tuple (will_replace_token, all_matches_exact_or_prefix) can never
be (false, false).

Proof by contraction:
1. Goal: show unsatisfiability of: !will_replace_token && !all_matches_exact_or_prefix
2. Substitute defintions: !all(replaces) && !all(is_exact_or_prefix)
3. wlog, !replaces(c1) && !is_exact_or_prefix(c2)
4. since c1 and c2 have same rank we know that !is_exact_or_prefix(c1)
5. !is_exact_or_prefix() implies requires_full_replacement()
6. all callers that create a Completion from StringFuzzyMatch::try_create(),
   set CompleteFlags::REPLACE_TOKEN if requires_full_replacement(),
   so requires_full_replacement() implies replaces()
7. From 4-6 follows: !is_exact_or_prefix(c1) implies replaces(c1), which is a contradiction
2026-01-03 15:54:04 +01:00
Johannes Altmanninger
f24cc6a8fc reader handle_completions(): remove code clone
While at it,
1. add assertions to tighten some screws
2. migrate to closed form / inline computation.
2026-01-03 15:54:04 +01:00
Johannes Altmanninger
3117a488ec complete: reuse replaces_token() 2026-01-03 15:54:04 +01:00
Johannes Altmanninger
185b91de13 reader rls: remove redundant initial value
This initial value is weird and None works the same way so use that.
2026-01-03 15:54:04 +01:00
Johannes Altmanninger
e20024f0f0 reader rls: minimize state for tracking the completion pager 2026-01-03 15:54:04 +01:00
Johannes Altmanninger
501ec1905e Test completion pager invalidation behavior 2026-01-03 15:54:04 +01:00
Johannes Altmanninger
7ebd2011ff update-dependencies.sh: fix uv lock --check command 2026-01-03 15:54:04 +01:00
Daniel Rainer
8004f354aa changelog: put new changes into upcoming release
The update to `WITH_GETTEXT` was not released in 4.3.2, so remove it
from there and put it into the section for the upcoming release.

Closes #12254
2026-01-02 00:11:36 +00:00
Daniel Rainer
77e1aead40 cmake: rename WITH_GETTEXT to WITH_MESSAGE_LOCALIZATION
This change is made to make the option name appropriate for Fluent
localization.

While at it, add a feature summary for this feature.

Closes #12208
2026-01-01 23:46:07 +00:00
Peter Ammon
e48a88a4b3 Minor refactoring of history item deletion
Clean this up.
2026-01-01 12:00:18 -08:00
Peter Ammon
1154d9f663 Correct error reporting when rewriting history files
A recent change attempted this:

    let result: std::io::Result<()> = { code()? }

However this doesn't initialize the Result on error - instead it
returns from the function, meaning that the error would be silently
dropped.

Fix that by reporting the error at the call site instead.
2025-12-31 10:20:31 -08:00
Johannes Altmanninger
810a707069 Fix PROMPT_SP hack regression
Commit fbad0ab50a (reset_abandoning_line: remove redundant
allocations, 2025-11-13) uses byte count of ⏎ (3) instead of char
count (1), thus overestimating the number of spaces this symbol takes.

Fixes #12246
2025-12-31 07:46:50 +01:00
Peter Ammon
7fa9e9bfb9 History: use Rust's buffered writing instead of our own
Simplify some code.
2025-12-30 20:26:07 -08:00
Alan Somers
48b0e7e695 Fix installation of prompts and theme files after 4.3.0
Installation of these files was accidentally broken by d8f1a2a.

Fixes #12241
2025-12-31 11:10:34 +08:00
Peter Ammon
848fa57144 Introduce and adopt BorrowedFdFile
Rust has this annoying design where all of the syscall conveniences on
File assume that it owns its fd; in particular this means that we can't
easily construct File from stdin, a raw file descriptor, etc.

The usual workarounds are to construct a File and then mem::forget it
(this is apparently idiomatic Rust!). But this has problems of its own:
for example it can't easily be used in Drop.

Introduce BorrowedFdFile which wraps File with ManuallyDrop and then
never drops the file (i.e. it's always forgotten). Replace some raw FDs
with BorrowedFdFile.
2025-12-30 14:07:39 -08:00
Peter Ammon
4101e831af Make fish_indent stop panicing on closed stdin
Prior to this commit, this code:

    fish_indent <&-

would panic as we would construct a File with a negative fd.
Check for a closed fd as other builtins do.
2025-12-30 14:07:39 -08:00
Peter Ammon
eb803ba6a7 Minor cleanup of shared::Arguments 2025-12-30 14:07:39 -08:00
Fabian Boehm
248a8e7c54 Fix doc test 2025-12-30 20:40:55 +01:00
Peter Ammon
2fa8c8cd7f Allow ctrl-C to work in fish_indent builtin
Since fish_indent became a builtin, it cannot be canceled with control-C,
because Rust's `read_to_end` retries on EINTR. Add our own function which
propagates EINTR and use it.

Fixes #12238
2025-12-30 10:39:19 -08:00
Johannes Altmanninger
8d5f5586dc start new cycle
Created by ./build_tools/release.sh 4.3.2
2025-12-30 17:43:15 +01:00
Johannes Altmanninger
c5bc7bd5f9 Release 4.3.2
Created by ./build_tools/release.sh 4.3.2
2025-12-30 17:21:04 +01:00
Johannes Altmanninger
2b3bd29588 Fix infinite repaint when setting magic variables in prompt
Commit 7996637db5 (Make fish immediately show color changes again,
2025-12-01) repaints unnecessarily when a local unexported color
variable changes.  Also, it repaints when the change comes from
fish_prompt, causing an easy infinite loop.  Same when changing TERM,
COLORTERM and others.

This feature is relevant when using a color-theme aware theme, so
try to keep it. Repaint only on global/universal changes.
Also ignore changes if already repainting fish prompt.

This change may be at odds with concurrent execution (parser should
not care about whether we are repainting) but that's intentional
because of 1. time constraints and 2. I'm not sure what the solution
will look like; we could use the event infrastructure.  But a lot of
existing variable listeners don't use that.

Extract a context object we pass whenever we mutate the environment; While
at it, use it to pass EnvMode::USER, to reduce EnvMode responsibilities.

Fixes #12233
2025-12-30 17:20:42 +01:00
Johannes Altmanninger
0be3f9e57e Fix some non_upper_case_globals warnings 2025-12-30 17:20:42 +01:00
Johannes Altmanninger
2524ece2cc builtin function: error when trying to inherit read-only variable
Also, deduplicate error checks and do them as early as possible since
we always return on error.
2025-12-30 17:20:42 +01:00
Johannes Altmanninger
b975472828 builtin function: improve option parsing structure 2025-12-30 17:20:42 +01:00
Johannes Altmanninger
20427ff1f6 env: check cheaper condition first 2025-12-30 17:20:42 +01:00
Johannes Altmanninger
5b3b825ab2 env: dispatch variable changes again if global was modified explicitly
We set "global_modified" to true if the global exist, or if the
default scope is global but not if EnvMode::GLOBAL.

This is an accident from 77aeb6a2a8 (Port execution, 2023-10-08).
Restore it. Tested in a following commit.
2025-12-30 17:20:42 +01:00
Johannes Altmanninger
ccd3348eed env_init: early return 2025-12-30 17:20:42 +01:00
Johannes Altmanninger
845b9be1f5 builtin set: remove unused argument
The "user" bit is only for getting errors when trying to set read-only
variables.  It's not relevant for reading from variables.
2025-12-30 17:20:42 +01:00
Johannes Altmanninger
400f2b130a set --erase: simplify erasing from multiple scopes in one go
We have pretty weird behavior:

	   $ set --path somepath 1 2 3
	     set --erase --unpath somepath[2]
	[1]$ set --path somepath 1 2 3
	     set --erase --unpath somepath
	   $

The first command fails to erase from the variable, because the
--path/--unpath mismatch prevents us from accessing the variable.
The second succeeds at erasing because we ignore --path/--unpath.

We should probably fix this; for now only simplify the unrelated
change added by fed64999bc (Allow erasing in multiple scopes in one
go, 2022-10-15):
we implement "set --erase --global --path" as

	try_erase(scope="--global")
	try_erase(scope="--path")

Do this instead, which is closer to historical behavior.

	try_erase(scope="--global --path")

This also allows us to express more obviously the behavior if no scope
(out of -lfgU) was specified.
2025-12-30 17:20:42 +01:00
Johannes Altmanninger
362f7cedf6 builtin set: fix inconsistent name
The --path and --export flags are not scopes, so use "mode" name
as elsewhere.
2025-12-30 17:20:42 +01:00
Johannes Altmanninger
2c959469f0 env mode: extract constant for scope bits 2025-12-30 17:20:42 +01:00
Johannes Altmanninger
6c34bcf8f6 parser: reuse set_var() 2025-12-30 17:20:42 +01:00
Johannes Altmanninger
f510b62b7f Don't schedule redundant repaints as autosuggestions are toggled
Tweak 86b8cc2097 (Allow turning off autosuggestions, 2021-10-21)
to avoid redundantly executing the prompt and repainting.
2025-12-30 17:20:42 +01:00
Fabian Boehm
b31387416d Optimize fish_config theme choose
Just following basic shellscript optimization:

- Remove a useless use of cat (`status get-file` takes microseconds,
`status get-file | cat` is on the order of a millisecond - slower with
bigger $PATH)
- Pipe, don't run in a loop
- Filter early

This reduces the time taken from 12ms to 6ms on one of my systems, and
6.5ms to 4.5ms on another.

This is paid on every single shell startup, including
non-interactively, so it's worth it.

There's more to investigate, but this is a good first pass.
2025-12-29 17:26:55 +01:00
Johannes Altmanninger
941a6cb434 changelog for 4.3.2 2025-12-29 16:25:23 +01:00
Johannes Altmanninger
931072f5d1 macos packages: don't add redundant hardlinks to fat binary
Commit 7b4802091a installs fish_indent and fish_key_reader as
hardlinks to fish.  When we create our fat binary for macOS, we add
3 of these X86 binaries to the fattened one,
resulting in a corrupted Mach-O binary. Fix that.

Fixes #12224
2025-12-29 16:19:48 +01:00
Johannes Altmanninger
f4f9db73da Add a CMake option to work around broken cross-compilation builds
Commit 135fc73191 (Remove man/HTML docs from tarball, require Sphinx
instead, 2025-11-20) broke cross compilation of tarballs.

Add an option to allow users to pick any fish_indent (such as
"target/debug/fish_indent" as created by "cargo build"), to allow
cross compilation.

In future, we should remove this option in favor of doing all of this
transparently at build type (in build.rs).

Ref: https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$psPcu-ogWK5q9IkgvfdvBGTdJ2XGhNq5z_Ug0iTCx2Q
2025-12-29 16:19:48 +01:00
Johannes Altmanninger
9ef3f30c56 Revert "Re-enable focus reporting on non-tmux"
When I ssh to a macOS system, typing ctrl-p ctrl-j in quick succession
sometimes causes ^[[I (focus in) to be echoed.  Looks like we fail to
disable terminal-echo in time. Possible race condition?  Revert until
we find out more.

This reverts commit 7dd2004da7.

Closes #12232
2025-12-29 16:19:48 +01:00
Johannes Altmanninger
d19c927760 status get-file: simplify wrapper
The __fish_data_with_file wrapper was born out of a desire to simplify
handling of file paths that may or may not be embedded into the
fish binary.

Since 95aeb16ca2 (Remove embed-data feature flag, 2025-11-20) this is
no longer needed since almost everything is embedded unconditionally.
The exception is man pages (see a1baf97f54 (Do not embed man pages
in CMake builds, 2025-11-20)), but they use __fish_data_with_directory.
2025-12-29 16:19:48 +01:00
Misty De Meo
22e5b21f10 changelog: fix minor typo
Closes #12227
2025-12-29 16:19:48 +01:00
Johannes Altmanninger
f0d2444769 docs: removed dead code around FISH_BUILD_VERSION
Man pages used to be built by "build.rs" but now are built by a
dependent "crates/build-man-pages/build.rs". This means that changing
the environment of build.rs is ineffective.

In future, "fn get_version" should probably be a part of
"crates/build-helper/", so Cargo builds only need to compute the
version once.

Lack of this dependency means that "build-man-pages" does not
pass FISH_BUILD_VERSION, which means that Sphinx will fall back to
build_tools/git_version_gen.sh.  This acceptable for now given that
"build-man-pages" is not used in CMake builds.
2025-12-29 16:19:48 +01:00
Johannes Altmanninger
7975060e4a docs: consistently use FISH_BUILD_VERSION_FILE
Commit 2343a6b1f1 passed the FISH_BUILD_VERSION_FILE to
sphinx-manpages to remove the fish_indent dependency.

For sphinx-docs this has been solved in another way in e895f96f8a
(Do not rely on `fish_indent` for version in Sphinx, 2025-08-19).

This is a needless inconsistency.

Remove it. Use FISH_BUILD_VERSION_FILE whenever possible, since that
means that a full build process only needs to call git_version_gen.sh
once.

Keep the fallback to git_version_gen.sh, in case someone calls
sphinx-build directly.
2025-12-29 16:19:47 +01:00
Johannes Altmanninger
354dc3d272 docs: use correct version file for HTML docs from tarball
Prior to commit 135fc73191 (Remove man/HTML docs from tarball, require
Sphinx instead, 2025-11-20), HTML docs were built from a Git worktree.

Now they are built in the tarball.  We call
build_tools/git_version_gen.sh from doc_src so it fails to find the
version file. Fix that.

Fixes #12228
2025-12-29 16:19:47 +01:00
Johannes Altmanninger
7640e95bd7 Create user config file/directories only on first startup again
Not being able to delete these for good (if unused) seems to be
a nuisance.  Let's go back to storing universal __fish_initialized
also on fresh installations, which I guess is a small price to to
avoid recreating these files.

Closes #12230
2025-12-29 16:19:47 +01:00
Johannes Altmanninger
767115a93d build_tools/make_macos_pkg.sh: fix when no CMake option is passed 2025-12-29 16:19:47 +01:00
David Adam
f0c8788a52 exec: add custom message for EBADMACHO error on Apple platforms
Otherwise the error is 'unknown error number 88'.
2025-12-29 22:46:47 +08:00
Fabian Boehm
a3cbb01b27 source __fish_build_paths directly
This didn't work because the cheesy helper function added an extra
scope block.

Just skip it.

Fixes #12226
2025-12-28 19:57:08 +01:00
Johannes Altmanninger
d630b4ae8a start new cycle
Created by ./build_tools/release.sh 4.3.1
2025-12-28 17:16:50 +01:00
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
Johannes Altmanninger
db6a7d26cd update_translations.sh: add header to new files too
Fixes #11855
2025-10-01 18:30:38 +02:00
Johannes Altmanninger
6be03d7cc4 update_translations.sh: fix test invocation when passed a file in non-extant directory
Need to make sure test arguments are not empty lists.
2025-10-01 18:30:38 +02:00
Daniel Rainer
617a6edb13 Extract messages without building default features
Default features are not needed for message extraction, so there is no
need to spend any resources on them.

If a PO files contains a syntax error, extraction would fail if the
`localize-messages` feature is active. This is undesirable, because it
results in an unnecessary failure with worse error messages than if the
`msgmerge` invocation of the `update_translations.fish` script fails.

Closes #11849
2025-10-01 08:05:37 +02:00
王宇逸
31c85723e8 zh_CN: don't translate set command
Closes #11852
2025-10-01 08:02:38 +02:00
王宇逸
d22c905d9f zh_CN: fix typo
Part of #11852
2025-10-01 08:02:38 +02:00
Daniel Rainer
216dc2d473 Remove redundant variable declaration
Closes #11851
2025-10-01 08:00:21 +02:00
Daniel Rainer
918e7abe6b Hide output of msgfmt -h
This command is only used to determine availability of `msgfmt`. Without
these changes, the entire help output shows up if the code panics later
on, which adds useless bloat to the output, making it harder to analyze
what went wrong.

Closes #11848
2025-10-01 07:59:46 +02:00
Daniel Rainer
c145ee6df3 Check exit status of msgfmt
Prior to this, when `msgfmt` failed, this would be detected indirectly
by the parser, which would then panic due to it input being empty.

Explicit checking allows us to properly display `msgfmt`'s error
message.

Closes #11847
2025-10-01 07:59:21 +02:00
Johannes Altmanninger
62543b36a4 release.sh: sunset release announcement email
I'm not sure if our peer projects do this or if it's useful to have
on top of github releases (especially as most releases are patch
releases mainly).

We could certainly use "sphinx-build -b text" in
build_tools/release-notes.sh to extract a nice plaintext changelog
and send that, but that doesn't support links.  Not sure about HTML
email either.
2025-10-01 07:26:50 +02:00
Daniel Rainer
751aad5302 Refactor PO section marking
Use msgids to mark sections. In the PO format, comments are associated
with specific messages, which does not match the semantics for section
markers.
Furthermore, comments are not preserved by `msgmerge`, which required
quite convoluted handling to copy them over from the template.
By using msgids to mark sections, this problem is avoided.

This convoluted handling was also used for header comments. Header
comments are now handled in a simpler way. There is a fixed prefix,
identifying these comments, as well as a list variable containing the
lines which should be put into the header. When a PO file is generated,
all existing lines starting with the prefix are deleted, the and the
current version of the lines is prepended to the file.

Closes #11845
2025-09-30 19:45:31 +02:00
Daniel Rainer
efabab492a Remove useless comments
Most of them have been added automatically for no good reason.

Also remove outdated comments referring to source locations in pt_BR.po.

Closes #11844
2025-09-30 19:44:36 +02:00
Daniel Rainer
c7cdbe60cd Put general comments on top of empty msgid
These should not be comments on an actual message, since they apply
throughout the entire file, so the sensible location is as comments on
the empty msgid.

Closes #11843
2025-09-30 19:44:15 +02:00
Johannes Altmanninger
412149a5de Changelog update for 4.1.1 2025-09-30 19:22:41 +02:00
Johannes Altmanninger
abd23d2a1b Increase escape sequence timeout while waiting for query response
Running "fish -d reader" inside SSH inside Windows terminal sometimes
results in hangs on startup (or whenever we run "scrollback-push"),
because not all of the Primary DA response is available for reading
at once:

	reader: Incomplete escape sequence: \e\[?61\;4\;6\;7\;14\;21\;22\;23\;24\;28\;32

Work around this by increasing the read timeout while we're waiting
for query responses.

We should try to find a better (more comprehensive?) fix in future,
but for the patch release, this small change will do.

Fixes #11841
2025-09-30 19:00:40 +02:00
Johannes Altmanninger
b774c54a6f Changelog for translation fixes from #11833 2025-09-30 19:00:40 +02:00
王宇逸
e4b797405b zh_CN: fix tier 1 translations
Closes #11833
2025-09-30 18:41:44 +02:00
Johannes Altmanninger
81a89a5dec release-notes.sh: fix sphinx warning for patch release notes
Integration_4.1.1 fails to generate release notes with

	CHANGELOG.rst:9: WARNING: Bullet list ends without a blank
	line; unexpected unindent. [docutils].
2025-09-30 18:00:09 +02:00
Johannes Altmanninger
0da12a6b55 Primary Device Attribute is a proper noun
We don't care about any specific attributes but we do very much care
about the specific query and response format associated with VT100's
primary device attribute query. Use a proper noun to emphasize that
we want that one and no other.

Ref: https://github.com/fish-shell/fish-shell/pull/11833#discussion_r2385659040
2025-09-30 12:06:08 +02:00
Johannes Altmanninger
86ec8994e6 build.rs: fix MSRV (1.70) clippy 2025-09-30 12:06:08 +02:00
Johannes Altmanninger
caf426ddb2 po/de.po: copy-edit German translations
Go through all existing translations except for tier3.
2025-09-30 11:50:43 +02:00
Johannes Altmanninger
508ae410a6 builtin commandline: fix completion description 2025-09-30 11:47:26 +02:00
Johannes Altmanninger
993b977c9b builtin function: remove dead code 2025-09-30 11:47:26 +02:00
Johannes Altmanninger
a7f0138fc7 builtin function: fix a misleading error message
Issue introduced in 7914c92824 (replaced the functions '--rename'
option with '--copy'., 2010-09-09).
2025-09-30 11:47:26 +02:00
Johannes Altmanninger
ab3c932903 builtin set: fix regression in error message description 2025-09-30 11:47:26 +02:00
Johannes Altmanninger
ae0fdadcff Remove translations for some error messages that basically never happen
Executable path is empty only in contrived circumstances.

The regex error happens only when the user explicitly turns off a
feature flag.

The orphaned process error seems very unlikely, not worth translating.
2025-09-30 11:47:26 +02:00
Johannes Altmanninger
e3974989d8 Fix short description for builtin wait 2025-09-30 11:47:26 +02:00
Johannes Altmanninger
080b1e0e4f Translation update implied by parent commit
Part of #11833
2025-09-30 11:47:26 +02:00
Johannes Altmanninger
a5db91dd85 po: add section markers to indicate translation priority
Part of #11833
2025-09-30 11:47:26 +02:00
Johannes Altmanninger
b62f54631b Translation update implied by parent commit
Part of #11833
2025-09-30 11:47:26 +02:00
Johannes Altmanninger
d835c5252a Prepare to not localize private function descriptions
The overwhelming majority of localizable messages comes from
completions:

	$ ls share/completions/ | wc -l
	$ 1048

OTOH functions also contribute a small amount, mostly via their
descriptions (so usually just one per file).

	$ ls share/functions/ | wc -l
	$ 237

Most of these are private and almost never shown to the user, so it's
not worth bothering translators with them. So:

- Skip private (see the parent commit) and deprecated functions.
- Skip wrapper functions like grep (where the translation seems to
  be provided by apropos), and even the English description is not
  helpful.
  - Assume that most real systems have "seq", "realpath" etc.,
    so it's no use providing our own translations for our fallbacks.
- Mark fish's own functions as tier1, and some barely-used functiosn
  and completions as tier3, so we can order them that way in
  po/*.po. Most translators should only look at tier1 and tier2.
  In future we could disable localization for tier3.

See the explanation at the bottom of
tests/checks/message-localization-tier-is-declared.fish

Part of #11833
2025-09-30 11:47:26 +02:00
Johannes Altmanninger
a53db72564 Mark private functions that don't need localization
See the next commit.

Part of #11833
2025-09-30 11:47:26 +02:00
Johannes Altmanninger
61b0368dac functions/realpath: remove weird wrapping
Wrapping the same thing is redundant and wrapping grealpath is kinda
pointless since we only provide completions for realpath.
2025-09-30 11:47:26 +02:00
Integral
568b4a22f9 completions/help: correct the spelling of "redirection"
Closes #11839
2025-09-30 11:47:26 +02:00
Jiangqiu Shen
8abba8a089 Re-add translations for share/completions/cjpm.fish
As removed in the parent commit.
Cherry-picked from e4c55131c7 (Update translation, 2025-07-04)
2025-09-30 11:47:26 +02:00
王宇逸
b3b789cd68 zh_CN: bad translations are worse than none
Part of #11833
2025-09-30 11:47:26 +02:00
Johannes Altmanninger
425a166111 functions/seq: use early return 2025-09-30 10:37:11 +02:00
Johannes Altmanninger
1dcc290e29 tests/checks/check-all-fish-files.fish: follow naming convention 2025-09-30 10:37:11 +02:00
Johannes Altmanninger
863204dbfa build.rs: remove dead code 2025-09-30 10:37:11 +02:00
Sebastian Fleer
4b21e7c9c7 webconfig: Replace str.stripprefix with str.removeprefix
str.stripprefix doesn't exist in Python:
https://docs.python.org/3/library/stdtypes.html#str.removeprefix

Closes #11840
2025-09-30 10:37:06 +02:00
Johannes Altmanninger
df5230ff4a Reliably disable modifyOtherKeys on WezTerm
WezTerm allows applications to enable modifyOtherKeys by default.
Its implementation has issues on non-English or non-QWERTY layouts,
see https://github.com/wezterm/wezterm/issues/6087 and #11204.

fish 4.0.1 disabled modifyOtherKeys on WezTerm specifically
(7ee6d91ba0 (Work around keyboard-layout related bugs in WezTerm's
modifyOtherKeys, 2025-03-03)), fish 4.1.0 didn't, because at that
time, WezTerm would advertise support for the kitty keyboard protocol
(even if applications are not allowed to enable it) which would make
fish skip requesting the legacy modifyOtherKeys.

WezTerm no longer advertises that if config.enable_kitty_keyboard
is false.  Let's work around it in another way.
2025-09-30 10:33:03 +02:00
Johannes Altmanninger
7cd0943056 Tighten some screws for TTY-specific workarounds 2025-09-30 10:25:23 +02:00
Johannes Altmanninger
6f0532460a fish_config: fix for non-embedded builds
I only tested with embedded-builds; CMake tests were failing because
they use different code paths here.

fish_config could use some love.  Start by extracting common
functionality between "{theme,prompt} show", fixing the behavior.

Fixes 29a35a7951 (fish_config: fix "prompt/theme show" in embed-data
builds, 2025-09-28).
2025-09-28 12:29:18 +02:00
Johannes Altmanninger
29a35a7951 fish_config: fix "prompt/theme show" in embed-data builds
Fixes #11832
2025-09-28 10:59:53 +02:00
Johannes Altmanninger
dd0d45f88f fish_config prompt: remove dead code
Commit 2b74affaf0 (Add prompt selector, 2021-04-22)
intentionally added an unused code path that checks for
$__fish_data_dir/sample_prompts, see

https://github.com/fish-shell/fish-shell/pull/7958#discussion_r621320945

> (note: This was added in preparation of moving the sample_prompts directory out of web_config -
> because it no longer is web-exclusive)

Remove it.
2025-09-28 10:11:01 +02:00
Johannes Altmanninger
0ff0de7efe release workflow: install msgfmt for staticbuilds
This makes us actually embed localized messages.

Part of #11828
2025-09-28 09:56:57 +02:00
Johannes Altmanninger
092ef99551 macos CI: explicitly install gettext
We need msgfmt for embedding translations.

Part of #11828
2025-09-28 09:54:30 +02:00
Johannes Altmanninger
97ae05b69d build_tools/release.sh: actually add new docs
Not quite sure for which step this is actually needed.  While at it,
fix the errexit issue that caused this blunder.
2025-09-27 22:56:49 +02:00
Johannes Altmanninger
3d8eca178e start new cycle
Created by ./build_tools/release.sh 4.1.0
2025-09-27 22:41:54 +02:00
Johannes Altmanninger
29b80bbaf9 Release 4.1.0
Created by ./build_tools/release.sh 4.1.0
2025-09-27 22:20:11 +02:00
Johannes Altmanninger
29470358d4 make_macos_pkg: update CMake invocation for MSRV rustc+cargo
Since 205d80c75a (findrust: Simplify (#11328), 2025-03-30), we need
to set Rust_COMPILER and Rust_CARGO instead of Rust_TOOLCHAIN (which
is no longer used).  Adjust macOS builds accordingly.

When I set only one of the two, the error messages were pretty
unintelligible. But I guess few normal users need to override the
Rust version, and they can always look here.

While at it, enable localization.  AFAIK, the only reason why we didn't
do this on macOS were problems related to the gettext shared library /
dependency. We no longer need that, and it's already tested in CI.
2025-09-27 22:15:25 +02:00
Johannes Altmanninger
8fe68781be Release workflow fixups
(cherry picked from commit ce4aa7669d)
2025-09-27 22:06:26 +02:00
Johannes Altmanninger
aba4d26f95 Emphasize that "status {list-files,get-file}" are meant for internal use
I'm not aware of a lot of sensible use cases where users need to access
our files directly.  The one example we know about is zoxide overriding
exactly our version of "function cd", ignoring any user-provided cd.
I think this is already hacky. But I guess it's here to stay.

I think we should not recommend this for external use, or at least
ask users to tell us what they are using this for.

Given that we expect these to be used mainly/only internally,
get-file/list-files are fine as names.

The other issue is that one has to be careful to always do

	status list-files 2>/dev/null

to support non-embedded builds.

Closes #11555
2025-09-27 14:22:18 +02:00
Johannes Altmanninger
b964072c11 Move scrollback-push feature detection to fish script
A lot of terminals support CSI Ps S.  Currently we only allow them
to use scrollback-up if they advertise it via XTGETTCAP.  This seems
surprising; it's better to make visible in fish script  whether this
is supposed to be working.  The canonical place is in "bind ctrl-l"
output.

The downside here is that we need to expose something that's rarely
useful. But the namespace pollution is not so bad, and this gives
users a nice paper trail instead of having to look in the source code.
2025-09-27 14:22:18 +02:00
Johannes Altmanninger
06bbac8ed6 release-notes.sh: add stats, round off committer list
Instead of adding these to the Markdown directly, add it to the
fake CHANGELOG.rst source, which makes escaping easier, and allows
generating other formats than Markdown in future.
2025-09-27 14:22:18 +02:00
Johannes Altmanninger
aab22a453b Revert "Only load sphinx_markdown_builder extension if it's used"
sphinx-build fails with

	sphinx.errors.SphinxError: Builder name markdown not registered or available through entry point

Apparently this issue was hidden locally by caching, and not checked
in CI because of this error causing
tests/checks/sphinx-markdown-changelog.fish to be skipped.

	sphinx-build 7.2.6
	runner@runnervm3ublj:~/work/fish-shell/fish-shell$ python -c 'import sphinx_markdown_builder'
	Traceback (most recent call last):
	  File "<string>", line 1, in <module>
	  File "/home/runner/.local/lib/python3.12/site-packages/sphinx_markdown_builder/__init__.py", line 6, in <module>
	    from sphinx.util.typing import ExtensionMetadata
	ImportError: cannot import name 'ExtensionMetadata' from 'sphinx.util.typing' (/usr/lib/python3/dist-packages/sphinx/util/typing.py)


This reverts commit 7b495497d7.

While at it, fail the test earlier if something went wrong, because the
remaining check will likely also fail and confuse.
2025-09-27 14:22:18 +02:00
Johannes Altmanninger
4cc2d2ec30 release-notes.sh: remove line breaks from generated Markdown, for GitHub
GitHub-flavored Markdown translates line breaks to <br/>, which does
not match our intent. Work around that by joining lines when producing
Markdown output.
2025-09-27 14:22:18 +02:00
Johannes Altmanninger
6ed4e54c1e Remove some dead code and unnecessary allocations
complete --subcommand was added in a8e237f0f9 (Let `complete`
show completions for one command if just given `-c`, 2020-09-09)
but never used or documented.
2025-09-27 14:22:18 +02:00
Johannes Altmanninger
829d6bc8fb Move terminal name into status subcommand not variable
Forgot about that; less namespace pollution this way, and it's more
obvious that it's read-only.
2025-09-27 14:22:18 +02:00
Johannes Altmanninger
abae6157d9 Changelog: reduce verbosity a bit, add some more 2025-09-27 14:22:18 +02:00
Daniel Rainer
bce19e7265 Fix typos 2025-09-26 16:34:22 +02:00
Johannes Altmanninger
166b17701a Remove spurious terminal interaction from unit tests
Some of our integration tests require a reader for code execution
and testing cancellation etc., but they never actually read from the
terminal.  So they don't need to call reader_interactive_init(), and
doing so is a bit weird.  Let's stop that; this allows us to assert
that reader_push() is always called with an input file descriptor
that refers to a TTY.
2025-09-26 13:03:20 +02:00
Johannes Altmanninger
f8269be359 Move redundant instances of blocking_query into InputData
We duplicate the same member across all implementations.  Looks like
this never makes sense, so move it to the shared data bag.
2025-09-26 12:59:02 +02:00
Johannes Altmanninger
b907bc775a Use a low TTY query timeout only if first query failed
As mentioned in the comment, query timeouts can happen if either
1. the terminal doesn't support primary device attribute
2. there is extreme (network) latency

In the first case, we want to turn the timeout way down.  In the
second case, probably not, especially because the network latency
may be transient. Let's keep the high timeout in the second case.

Fixes 7ef4e7dfe7 (Time out terminal queries after a while,
2025-09-21).
2025-09-26 12:59:02 +02:00
Johannes Altmanninger
7e3fac561d Query terminal only just before reading from it
Commit 5e317497ef (Query terminal before reading config, 2025-05-17)
disabled the kitty keyboard protocol in "fish -c read".  This seems
surprising, and it's not actually necessary that we query before
reading config; we only need query results before we read from
the TTY for the first time (which is about the time we call
__fish_config_interactive). Let's do that, reverting parts of
5e317497ef.
2025-09-26 12:59:02 +02:00
Johannes Altmanninger
7713e90aeb Make query response handling more consistent 2025-09-26 12:58:10 +02:00
Johannes Altmanninger
08ad5c26ea Give scroll-forward a less confusing name
ECMA-48 calls CSI S "scroll up", so use something like that but try
to avoid ambiguity.
2025-09-26 12:52:28 +02:00
Johannes Altmanninger
310b7eca68 Only initialize kitty keyboard capability on startup
If the initial query is interrupted by ctrl-c, we leave it unset. A
later rogue "\e[?0u" reply would make us enable it, which seems
surprising. Fix that by always setting the capability if we're gonna
read from stdin.
2025-09-26 12:10:56 +02:00
Johannes Altmanninger
e9ae143bab Fix cursor position reports being ignored
When we receive a cursor position report, we only store the result;
we'll act on it only when we receive the primary DA reply.  Make sure
we don't discard the query state until then.

Fixes 06ede39ec9 (Degrade gracefully when failing to receive cursor
position report, 2025-09-23)
2025-09-26 12:10:04 +02:00
Johannes Altmanninger
74d3832610 Early return in reader_execute_readline_cmd() 2025-09-26 12:10:04 +02:00
yegorc
3c04a05ea4 Added documentation for &>>.
The `&>>` redirection was undocumented.

Closes #11824
2025-09-26 12:10:04 +02:00
Johannes Altmanninger
e6541c5c93 Enable sphinx parallelism also when building markdown release notes
We get a warning about sphinx_markdown_builder not being
parallelizable. Fix that.

Ref: https://github.com/liran-funaro/sphinx-markdown-builder/pull/38
2025-09-26 12:10:04 +02:00
Johannes Altmanninger
7b495497d7 Only load sphinx_markdown_builder extension if it's used
As is, building man pages or HTML docs while sphinx_markdown_builder
is installed, will result in unrelated warnings.  Remove those by
removing it from the extensions config.  Markdown building (only used
for changelog) seems to work without this just fine.
2025-09-26 12:08:51 +02:00
Johannes Altmanninger
6e90d9bd6f Fix markdown changelog generation test
System tests typically run outside the workspace directory, but they
still have read-only access to the workspace; fix it accordingly.
This test only works on git checkouts, not in tarballs, so skip it
if .git doesn't exist.
2025-09-26 12:08:51 +02:00
Stevie Alvarez
b8f704e3c4 fish_git_prompt: add diverged upstream char option
Currently, `__fish_git_prompt_char_upstream_diverged` can only be set to
a combination of `__fish_git_prompt_char_upstream_behind` and
`__fish_git_prompt_char_upstream_ahead`s plain-text options. Adding a
combination of the less-plain character options gives users more choice.

Closes #11817
2025-09-25 11:38:52 +02:00
Johannes Altmanninger
b37b57781b Disable sphinx-markdown-builder in tests again for now
Somehow I didn't realize this breaks the tests/checks/sphinx-* tests.
2025-09-24 16:30:21 +02:00
Fabian Boehm
e3a5725a46 Fix crash if there is no xtversion reply 2025-09-24 16:21:18 +02:00
Karel Balej
3d5a5b8740 completions: add basic completions for udevil
Add a set of basic completions for udevil, which is a program that
allows unpriviledged users to mount devices.

Each command has a corresponding long-option-like syntax variant
(sometimes even multiple ones), such as "udevil monitor" -> "udevil
--monitor", which are omitted here for simplicity.

The project unfortunately seems long abandoned and as such no attempt to
submit these completions upstream has been made.
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
22ffc31b71 release workflow: credit contributors in release notes
While at it, do a 's/^--$/^---/' to fix Markdown syntax for horizontal
line for CommonMark-based parsers.
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
127c02992d Test markdown changelog creation in CI
Extract a github action to install the same version used in the release
workflow.  In future we should probably migrate to requirements.txt
or similar.
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
765ca54d59 release workflow: resolve relative references in changelog properly
Instead of having sphinx-build only build CHANGELOG.rst, build the
entire thing, so relative references (":doc:", ":ref:") can be resolved
properly.  Replace our sed-based hacks with 'markdown_http_base'.
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
1519ea74be release workflow: extract script for generating markdown release notes 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
2895986465 tests/sphinx-man: man page building no longer requires fish_indent 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
e9e7ad24b5 Changelog: also extract changes to embed-data to its own section 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
4f8aa0a78c Show warnings from sphinx-build when building with cargo 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
f821d6dd7f Feature flag for turning off TTY querying
Experience with OSC 133 and kitty keyboard protocol enabling sequences
has shown that a lot of users are still on incompatible terminals.
It's not always easy to fix those terminals straight away. There
are probably some more environments where primary device attribute
queries are not answered.

Add a feature flag (similar to keyboard-protocols and mark-prompt)
to allow users to turn this off.

When the terminal fails to respond to primary device attribute, we
already print an error pointing to "help terminal-compatibility".
Inside that document, inside the "primary device attribute" section,
point out this new feature flag.
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
4c1da3b2d3 Parse Terminal.app version only if needed 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
a6f975a7e3 Add mark-prompt feature flag
(not sure if we should also include this in 4.1 but I guess better
safe than sorry)

So far, terminals that fail to parse OSC sequences are the only reason
for wanting to turn off OSC 133.  Let's allow to work around it by
adding a feature flag (which is implied to be temporary).

To use it, run this once, and restart fish:

    set -Ua fish_features no-mark-prompt

Tested with

    fish -i | string escape | grep 133 &&
    ! fish_features=no-mark-prompt fish -i | string escape | grep 133

Closes #11749
Also #11609

(cherry picked from commit 6900b89c82)
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
bbd7205de1 Document GNU screen incompatibily & workarounds
The problem described in 829709c9c4 (Replace synchronized update
workaround, 2025-04-25) doesn't seem too bad; let's document the
workaround.

We could probably also remove our $STY-based workaround.  I'm not
yet sure how many problems that one will cause.

Closes #11437
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
64c8d361b0 status.rst: link to feature flag documentation 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
c31e769f7d Use XTVERSION for terminal-specific workarounds
As mentioned in earlier commit
("Query terminal before reading config").

Closes #11812
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
99854c107a Set kitty keyboard capability only at startup 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
5e317497ef Query terminal before reading config
We still have terminal-specific workarounds based on TERM_PROGRAM and
others, see test/test_driver.py.  In future we should get rid of them.

They are also unreliable, potentially missing inside SSH/containers,
incorrect if a terminal was started from another terminal (#11812);
also TERM can be incorrect for many reasons.

The better criterion for terminal-specific workarounds is XTVERSION,
which has none of the above disadvantages.

Since some of the workarounds (tmux, iTerm2) need to be applied before
we draw the first prompt. This also means: before we read any config
because config may call builtin "read".

Do startup queries before reading config.

Some changes implied by this:
1. Remove a call to init_input() which is already done by env_init()
2. call initialize_tty_metadata() only after queries have returned
3. Since we call initialize_tty_metadata() before the first
   call to tty.enable_tty_protocols() in Reader::readline(),
   we can remove the redundant call from reader_interactive_init().
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
96f63159b5 Be consistent about how we handle bad stdin FD
When poll() or read() on stdin fails, fish's interactive reader
pretends it has received SIGHUP, and subsequently exits.

I don't know if this is the right thing to do, or how to reproduce
this in a realistic scenario.

Unlike fish, fish_key_reader seems to ignore these failures, meaning
it will retry poll()/read() immediately.  This seems less correct,
so use fish's behavior for now.
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
fadb2fac44 Fix some import conventions 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
1b01ac87fa Improve a tcsetpgrp error message 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
4abd390c84 test_driver.py: extend the list of terminal-specific workarounds 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
712bbf00ec fish_key_reader: remove things that don't belong in the builtin
While at it, remove a redundant call to initialize_tty_metadata();
that's done by initial_query().
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
76d1e8d4da fish_key_reader: reuse isatty helper 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
2d457adfec builtin read: use a better type 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
6fdce59572 Extract function for setting shell modes
We do the same thing in several places, with lots of small differences.
Extract the most reasonable behavior and use it everywhere.  Note that
we had an explictly-motivated ENOTTY check; the motivating issues
doesn't seem to reproduce anymore here though I did not bisect yet.
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
21150726d3 Remove confused redundant mutex lock 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
37a0919fee Also check isatty(0) before querying
A process like "fish -i <somefile ..."  probably shouldn't query
because it's not gonna work.

In future we could enable this by sending/receiving queries to/from
/dev/tty rather than stdout/stdin.
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
7a14dd0b7f Be more consistent about when to query the TTY
We are more conservative with querying on startup than we are with
querying for cursor position.

Part of this is oversight (if startup querying is not done, we
basically never get into a position where we query for cursor position,
outside extreme edge cases).

Also, some specific scenarios where we query for cursor position
inside, say, Midnight Commander, are not actually broken, because that
only happens when Midnight Commander gives us control.  But let's
favor consistency for now; the Midnight Commander issue should be
fixed soon anyway.

Use the same logic in both cases.
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
fb0e17d6ea tty_handoff: extract Midnight Commander workaround
A following commit wants to run the full initialize_tty_metadata()
only after querying XTVERSION.

But MC_TMPDIR needs to be checked before querying for XTVERSION.

Remove this cyclic dependency by extracting the MC_TMPDIR check.
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
a6a38b78d6 Don't initialize interactive reader redundantly
Commands like

	fish -C 'read'

create two top-level readers one after the other.  The second one is
the fish REPL.

Both run some initialization of globals and parser variables.  This is
weird; it should not be necessary.

Let's call reader_interactive_init() only once.
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
f5420b1110 Remove stale comment 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
90124c7889 Remove workaround for dvtm/abduco
dvtm and abduco are two terminal session managers with the same
original.

Among other issues, they fail to reply to primary device
attribute.  We have added a workaround for that based on
TERM=dvtm-256color (unreliable). A patch has been submitted for dvtm
https://lists.suckless.org/hackers/2502/19264.html

I don't know of a maintained fork (the original ones have had no
commit in 5 years) and there are better alternatives available
(shpool, tmux).  They have other VT100 compatibility issues as well
(accidental DECRST; something like "ls" Tab Tab Tab causes spurious
bold and underline markup).

Also, as of the parent commit, failure to respond to primary DA is
no longer catastrophic. So let's remove the workaround.  This means
that fish inside dvtm/abduco will pause for 2 seconds on startup and
print a warning (unless interrupted by ctrl-c).
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
7ef4e7dfe7 Time out terminal queries after a while
Add a timeout of 2 seconds queries; if any query takes longer, warn
about that and reduce the timeout  so we stop blocking the UI.  This 2
second delay could also happen when network latency is momentarily
really high, so we might want relax this in future.

Note that this timeout is only triggered by a single uninterrupted
poll() (and measured from the start of poll(), which should happen
shortly after sending the query). Any polls interrupted by signals
or uvars/IO port before the timeout would be hit do not matter.
We could change this in future.

Closes #11108
Closes #11117
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
06ede39ec9 Degrade gracefully when failing to receive cursor position report
Follow up the cursor position report query with a primary device
attribute one.  When that one arrives, any cursor position response
must have arrived too. This allows us to prevent a hang on terminals
that only support primary device attribute.
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
1612576d1c Restructure query response handling logic
Instead of switching only on the response type, switch on the
combination of that and the expected response.  This helps the
following commits, which add more combinations (due to following up
cursor position report with a primary DA, and adding a timeout). No
behavior change here.
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
2260465ed7 Rename enum variants to remove a name clash 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
3bd296ae3d Reuse variable in next_input_event() 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
064a45635c Document inter-dependencies between optional terminal features
- document that we currently require "cursor position report" if
  either of both click_events or XTGETTCAP+indn is implemented.
  One of the following patches will remove this requirement.
- document properly that scrollback-push currently only works
  when XTGETTCAP+indn is implemented. There are still a few terminals
  that don't support SCROLL UP, for example the Linux Console,
  and there is no better way to find out if it's supported.
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
6f01c7b707 Changelog: minor edits 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
6f2a701f81 README: recommend latest release in embedded builds section 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
f79377e4b0 Revert "Temporary workaround for BSD WEXITSTATUS libc bug"
This reverts commit c1b460525c.

We have libc commit 7a7fe4683 (Apply modulo 256 to BSD WEXITSTATUS,
2024-12-19) now.
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
c3626a3031 builtin read: --tokenize-raw option
Users have tried to get a list of all tokens -- including operators
-- using "commandline --tokens-raw".  That one has been deprecated
by cc2ca60baa (commandline.rst: deprecate --tokens-raw option,
2025-05-05).  Part of the reason is that the above command is broken
for multi-line tokens.

Let's support this use case in a way that's less ambiguous.

Closes #11084
2025-09-24 15:51:32 +02:00
Johannes Altmanninger
f3b27e8d11 Changelog: link to command docs 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
5d71609ff7 Changelog: fix rst syntax for man page output 2025-09-24 15:51:32 +02:00
Johannes Altmanninger
dbd79285cb Contributing: fix rst external link syntax 2025-09-24 15:51:32 +02:00
David Adam
dca571ac4c fixup! fish.spec: also drop %find stanza for lang files 2025-09-23 08:01:04 +08:00
Daniel Rainer
c8f31ceedb Fix release workflow syntax
The previous version results in an immediate workflow failure due to a
syntax error in the YAML. `workflow_dispatch` should be a dictionary
key, with its value being another dictionary (whose only key is `inputs`
at the moment).
2025-09-22 20:25:45 +02:00
Johannes Altmanninger
b1d1ef1b6e github release workflow: fix structure 2025-09-22 18:19:36 +02:00
Johannes Altmanninger
01361b9217 github release workflow: only run on explicit dispatch
Release automation can be tested on any GitHub fork, using

	build_tools/release.sh $version $repository_owner $git_remote

which should work perfectly except for macOS packages (which fail
unless provided GitHub secrets).

People might push tags to their forks, both non-release tags (which
would trigger an early failure in "is-release-tag") or replicas of
our actual release tags (which would create a draft release etc. and
only fail when building macOS packages).

Run on explicit workflow dispatch to make sure it's not triggered by
accident like that.

This means that we'll use the .github/workflows/release.yml from
the default branch (i.e. master), so try to make sure it matches the
version in the release, to prevent accidents.

Closes #11816
2025-09-22 18:15:21 +02:00
Johannes Altmanninger
dab8df1a18 github release workflow: use github context only if needed 2025-09-22 18:15:21 +02:00
Johannes Altmanninger
c771ff06d4 build_tools/make_macos_pkg.sh: fix inconsistent version computation
make_tarball.sh and others do it differently.
2025-09-22 18:15:21 +02:00
David Adam
e5cb1689c5 fish.spec: also drop %find stanza for lang files 2025-09-21 18:45:20 +08:00
David Adam
fa96df3a90 fish.spec: drop find_lang macro
All translations are now handled internally.
2025-09-21 18:11:01 +08:00
Karel Balej
67a9d08778 completions/mpc: conditionally enable file completion for add and insert
When connecting to MPD via a Unix socket, mpc add and insert accept
absolute paths to local files. Offer these in the completion if the
completed token starts with a slash after expansion.
2025-09-20 15:20:19 +02:00
Johannes Altmanninger
5ece9bec6c __fish_print_help: use man as-is
Since 0fea1dae8c (__fish_print_help: Make formatting more man-like,
2024-10-03), there is barely any difference left between "man abbr"
and "abbr -h".

The main difference is that it looks almost like man but is actually
nroff/mandoc and less.  This means it doesn't support environment
variables like MANWIDTH and possibly others.

Let's use full "man" for now.
This matches what "git foo --help" does so it's widely accepted.

Keep around a fallback for a while, in case users/packagers fail to
install the new "man" dependency.

In future, "abbr -h" (as opposed to "abbr --help") could show a more
concise version, not sure.

Closes #11786
2025-09-20 13:56:23 +02:00
Johannes Altmanninger
d422ad603e __fish_print_help: remove error message
__fish_print_help supports printing an error message above the
documentation.

This is currently only used by extremely rare edge cases, namely:

	eval "break"
	eval "continue --unknown"
	fish -c 'sleep 10&; bg %1'

Let's remove this feature to enable us to use man directly (#11786).
2025-09-20 13:56:23 +02:00
Johannes Altmanninger
26116b477e Fix crash on "bg" of non-job-controlled job
fish -c 'sleep 1 & bg %1' is supposed to fail because the job is not
under job control.

When we try to print the failure, we accidentally still
hold a borrow of the job list.  This blows up because we use
"builtin_print_help_error()" to print the failure message; that
function runs "job_reap()" which wants an exclusive borrow of the
job list. Let's drop our job list earlier.
2025-09-20 13:56:23 +02:00
Johannes Altmanninger
87c73b7fbf builtin break/continue: support -h/--help argument
These are not generic builtins because we check whether they're inside
a loop. There's no reason to not support "break -h" when we support
"if -h" etc.; do that.
2025-09-20 13:56:23 +02:00
Johannes Altmanninger
c77255aabc tests: consolidate __fish_print_help overrides 2025-09-20 13:56:23 +02:00
Johannes Altmanninger
0063992195 functions/man: consistent switch-case ordering
Match __fish_print_help
2025-09-20 13:56:23 +02:00
Johannes Altmanninger
1fdf37cc4a __fish_echo: fully overwrite lines
With upcoming multi-line autosuggestions, when I run

	$ function foo
	    true
	  end

and type "function", then I'll get a suggestion for the above command.
Now if press "alt-w", it will echo "function - create a function"
and rewdraw the prompt below.  But the previous autosuggestion is
not cleared, so it will look weird like:

	johannes@abc ~/g/fish-shell> function foo
	function - create a function     true

Let's erase these lines before writing them.

There's an issue remaining: the first line of the autosuggestion
(i.e. "foo") is not erased.  Fortunately this is less annoying,
but it shows that __fish_echo needs more support from core.
2025-09-20 13:56:23 +02:00
Johannes Altmanninger
c0c7b364fc builtin status: rename buildinfo to build-info
See: https://github.com/fish-shell/fish-shell/pull/11726#discussion_r2347389523
2025-09-20 13:56:23 +02:00
Johannes Altmanninger
64bbd41f81 build_tools/release.sh: approve macos-codesign github environment 2025-09-20 13:56:23 +02:00
Johannes Altmanninger
955345dd5b completions/sudo-rs: wrap sudo for now, closes #11800 2025-09-20 13:56:23 +02:00
Johannes Altmanninger
012b507128 Workaround for embed-data debug builds on Cygwin
When running a debug build, rust-embed always sources files from disk.
This is currently broken with on Cygwin.

As a temporary workaround, use the "debug-embed" feature to actually
embed the files into the binary, like we do for release builds.

We can probably fix the rust-embed issue fairly easily.
I haven't checked.  For now, I think this hack is preferrable to
not having an easy way to make debug builds on Cygwin.  (CMake
files would need some changes, and I also hit some problems with
installation). At least this would have helped with investigating
https://github.com/msys2/msys2-runtime/issues/308
2025-09-20 13:56:23 +02:00
Johannes Altmanninger
142cec3a96 github release workflow: use a consistent order for static builds 2025-09-20 13:56:23 +02:00
Johannes Altmanninger
cdc57b97a3 Changelog updates 2025-09-20 13:56:23 +02:00
Johannes Altmanninger
bb916f8d73 Fix regression breaking self-insert of kitty shifted codepoint
Commit 50a6e486a5 (Allow explicit shift modifier for non-ASCII
letters, fix capslock behavior, 2025-03-30) delayed handling of kitty
keyboard protocol's shifted codepoints.  It does handle shifted
codepoints when matching keys to mappings; but it fails to handle
them in the self-insert code paths where we want to insert the text
represented by CharEvent::Key.
Fix it by resolving the shifted key.

Fixes #11813
2025-09-20 13:56:23 +02:00
Johannes Altmanninger
8d12dfe065 Move key codepoint computation to key event
For the next commit.
2025-09-20 13:56:23 +02:00
Johannes Altmanninger
9bf58abcae Changelog: move gettext and argparse changes to dedicated sections
By giving them dedicated headlines, they should be easier for users to skip
over if not interested.
2025-09-20 13:56:23 +02:00
Johannes Altmanninger
b325ff6992 Changelog: syntax fixes and rewording 2025-09-20 13:56:23 +02:00
Daniel Rainer
397969ddcc Add message localization tests
These tests require building with the `localize-messages` feature.

If certain translations are updated, this test might fail, either
because a message was changed in the source, or because a translation of
a message was changed, or because a translation was added in a language
which previously did not have a translation for a particular message,
and we rely on that in the test. If any of these happen, the tests need
to be updated accordingly.

Closes #11726
2025-09-20 13:56:23 +02:00
Daniel Rainer
bee1e122f9 Remove unused locale path code
The locale path was used to tell GNU gettext where to look for MO files
at runtime. Since we now embed the message catalog data into the
executable, we no longer need a locale path.

Part of #11726
2025-09-20 13:56:23 +02:00
Daniel Rainer
ad323d03b6 Switch to builtin gettext implementation
This completely removes our runtime dependency on gettext. As a
replacement, we have our own code for runtime localization in
`src/wutil/gettext.rs`. It considers the relevant locale variables to
decide which message catalogs to take localizations from. The use of
locale variables is mostly the same as in gettext, with the notable
exception that we do not support "default dialects". If `LANGUAGE=ll` is
set and we don't have a `ll` catalog but a `ll_CC` catalog, we will use
the catalog with the country code suffix. If multiple such catalogs
exist, we use an arbitrary one. (At the moment we have at most one
catalog per language, so this is not particularly relevant.)

By using an `EnvStack` to pass variables to gettext at runtime, we now
respect locale variables which are not exported.
For early output, we don't have an `EnvStack` to pass, so we add an
initialization function which constructs an `EnvStack` containing the
relevant locale variables from the corresponding Environment variables.
Treat `LANGUAGE` as path variable. This add automatic colon-splitting.

The sourcing of catalogs is completely reworked. Instead of looking for
MO files at runtime, we create catalogs as Rust maps at build time, by
converting PO files into MO data, which is not stored, but immediately
parsed to extract the mappings. From the mappings, we create Rust source
code as a build artifact, which is then macro-included in the crate's
library, i.e. `crates/gettext-maps/src/lib.rs`. The code in
`src/wutil/gettext.rs` includes the message catalogs from this library,
resulting in the message catalogs being built into the executable.

The `localize-messages` feature can now be used to control whether to
build with gettext support. By default, it is enabled. If `msgfmt` is
not available at build time, and `gettext` is enabled, a warning will be
emitted and fish is built with gettext support, but without any message
catalogs, so localization will not work then.

As a performance optimization, for each language we cache a separate
Rust source file containing its catalog as a map. This allows us to
reuse parsing results if the corresponding PO files have not changed
since we cached the parsing result.

Note that this approach does not eliminate our build-time dependency on
gettext. The process for generating PO files (which uses `msguniq` and
`msgmerge`) is unchanged, and we still need `msgfmt` to translate from
PO to MO. We could parse PO files directly, but these are significantly
more complex to parse, so we use `msgfmt` to do it for us and parse the
resulting MO data.

Advantages of the new approach:
- We have no runtime dependency on gettext anymore.
- The implementation has the same behavior everywhere.
- Our implementation is significantly simpler than GNU gettext.
- We can have localization in cargo-only builds by embedding
  localizations into the code.
  Previously, localization in such builds could only work reliably as
  long as the binary was not moved from the build directory.
- We no longer have to take care of building and installing MO files in
  build systems; everything we need for localization to work happens
  automatically when building fish.
- Reduced overhead when disabling localization, both in compilation time
  and binary size.

Disadvantages of this approach:
- Our own runtime implementation of gettext needs to be maintained.
- The implementation has a more limited feature set (but I don't think
  it lacks any features which have been in use by fish).

Part of #11726
Closes #11583
Closes #11725
Closes #11683
2025-09-20 13:56:23 +02:00
Daniel Rainer
3a196c3a08 Use rsconf::warn! where appropriate
This is a more explicit variant than directly prefixing build script
output with `cargo:warning=`.

Part of #11726
2025-09-20 09:10:39 +02:00
Daniel Rainer
f34dfb8424 Allow 3-letter language codes
Some languages do not have a 2-letter code.
https://www.gnu.org/software/gettext/manual/html_node/Locale-Names.html

Part of #11726
2025-09-20 09:10:39 +02:00
Daniel Rainer
e2a9f0eb50 Make build_dir construction more readable
Part of #11726
2025-09-20 09:10:39 +02:00
Johannes Altmanninger
fb0f9842ae Update to Rust 1.90 2025-09-19 15:43:55 +02:00
Johannes Altmanninger
ff633bd744 github release workflow: make sure that last changelog entry isn't given spurious markup 2025-09-18 10:46:21 +02:00
Johannes Altmanninger
0d46c26988 github release workflow: work around trailing "---"-line in changelog
The extracted release notes trigger a sphinx warning

	/tmp/tmp.V6RGP92nc2/src/index.rst:6:Document may not end with a transition.

which we don't seem to get on the full CHANGELOG.rst.
Let's work around that for now.
2025-09-18 09:58:14 +02:00
Johannes Altmanninger
1840df96a2 build_tools/release.sh: relax assertion about changelog title
I'd like to move to a process where everything goes into master first,
and then flows downstream to any release branches (i.e. no merging
of Integration_* branches back into master).

The only thing we need to change for that is to add release notes for
patch releases eagerly on master.  That implies that we want to use
the actual version instead of ???.  (Only if something goes wrong
in the release process, we need to change this on both branches,
but that should happen too often.)
2025-09-18 09:37:44 +02:00
Johannes Altmanninger
3456b33050 build_tools/release.sh: push to the integration branch when all goes well
Also, ignore any "sendemail.to" Git config, and remove a temporary
statement in release notes.
2025-09-18 09:32:16 +02:00
Johannes Altmanninger
9a04c15894 Fix new-style bindings shadowing raw escape sequence bindings
Given

	bind up "echo user up, new notation"
	bind \e\[A "echo user up, legacy notation"

prior to b9d9e7edc6 (Match bindings with explicit shift
first, 2025-05-24), we prioritized the legacy notation because
input_mapping_insert_sorted() makes us try longer sequences first --
and "up" is only one key compared to the three-key legacy sequence.

This prioritization was broken in b9d9e7edc6, causing plugins that
update to the "bind up" notation to break users who haven't (#11803).

Even worse, it caused preset bindings to shadow user ones:

	bind --preset up "echo preset up, new notation"
	bind \e\[A "echo user up, legacy notation"

Restore backwards compatibility by treating matches against legacy
notation like exact matches again.
2025-09-18 09:28:57 +02:00
David Adam
63585a3e26 Merge branch 'Integration_4.0.6' 2025-09-17 14:38:19 +08:00
David Adam
aa1b64f955 build_tools: make tarball scripts use the build version 2025-09-17 13:56:22 +08:00
Piotr Kubaj
91ee45b0e1 path.rs: fix build on ARM / POWER
error[E0308]: mismatched types
   --> src/path.rs:749:13
    |
748 |         let remoteness = remoteness_via_statfs(
    |                          --------------------- arguments to this function are incorrect
749 |             libc::statfs,
    |             ^^^^^^^^^^^^ expected fn pointer, found fn item
    |
    = note: expected fn pointer `unsafe extern "C" fn(*const i8, _) -> _`
                  found fn item `unsafe extern "C" fn(*const u8, _) -> _ {libc::statfs}`
note: function defined here
   --> src/path.rs:712:12
    |
712 |         fn remoteness_via_statfs<StatFS, Flags>(
    |            ^^^^^^^^^^^^^^^^^^^^^
713 |             statfn: unsafe extern "C" fn(*const i8, *mut StatFS) -> libc::c_int,
    |             -------------------------------------------------------------------

error[E0308]: mismatched types
   --> src/path.rs:725:34
    |
725 |             if unsafe { (statfn)(path.as_ptr(), buf.as_mut_ptr()) } < 0 {
    |                         -------- ^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
    |                         |
    |                         arguments to this function are incorrect
    |
    = note: expected raw pointer `*const i8`
               found raw pointer `*const u8`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `fish` (lib) due to 2 previous errors
2025-09-16 20:03:40 +02:00
Johannes Altmanninger
f69c2a4d4a fish_config: silence error when compiled without embed-data 2025-09-13 15:14:13 +02:00
Johannes Altmanninger
3f7a576835 Support installing to nested subdirectory of CMAKE_BINARY_DIR
The only install directory that's not supported is
-DCMAKE_INSTALL_PREFIX=$CARGO_MANIFEST_DIR, but that's a bad idea
anyway since share/ is Git-tracked.
2025-09-13 15:12:23 +02:00
Johannes Altmanninger
75cedd8039 config_paths: extract variable 2025-09-13 15:12:23 +02:00
Johannes Altmanninger
a2c6e22d13 build.rs: don't define unused build environment variables
We set a lot of variables that are never used with
--feature=embed-data.  Remove them.  I don't think this change will
cause any problems with caching.
2025-09-13 15:12:23 +02:00
Johannes Altmanninger
aaf5ed7f11 build.rs: fix fallback PATH when embed-data is enabled
On a system where _CS_PATH is not defined (tested by removing that
code path), we get:

	$ cargo b && env -u PATH HOME=$PWD target/debug/fish -c 'set -S PATH'
	$PATH[1]: |.local//bin|
	$PATH[2]: |/usr/bin|
	$PATH[3]: |/bin|

The relative $PATH[1] makes no sense; probably it's an
accident. Restore the traditional $PATH[1]=/usr/local/bin.
2025-09-13 15:12:23 +02:00
Johannes Altmanninger
35d791ed49 config_paths: get rid of global variable, initialize locale predictably
Commit bf65b9e3a7 (Change `gettext` paths to be relocatable (#11195),
2025-03-30) made the locale directory (/usr/local/share/locale)
relocatable as well, so that "mv /usr/local /usr/local2" would not
break translations.

But this introduces a weird circular dependency, which was probably
the reason why the locale directory hadn't been relocatable:
1. option parsing might fail and print error messages, which should
   be localized, hence require detection of config paths
2. detection of config paths calls `FLOG`, which depends on options
   parsing (e.g. "-d config -o /tmp/log")

Since commit bf65b9e3a7, fish initializes the config paths
lazily, as soon as needed by translations.

When initializing config paths, we produce logs.  The logs are off by
default so its' fine in practical cases, but technically we should only
log things after we have handled things like FISH_DEBUG_OUTPUT.

Here's an example where the config directory initialization sneakily
injected by an error message's "wgettext_fmt!" causes logs to be
printed to the wrong file spuriously:

	$ FISH_DEBUG='*' FISH_DEBUG_OUTPUT=/tmp/log build/fish --unknown-arg
	config: exec_path: "./build/fish", argv[0]: "./build/fish"
	config: paths.sysconf: ./etc
	config: paths.bin: ./build
	config: paths.data: ./share
	config: paths.doc: ./user_doc/html
	config: paths.locale: ./share/locale
	fish: --unknown-arg: unknown option

Now we could handle "-d config", "-o", and FISH_DEBUG later, but
that would mean that in this example we don't get any logs at all,
which doesn't seem correct either.

Break the circular dependency by determining config paths earlier,
while making sure to log the config path locations only after parsing
options, because options might affect whether we want to log the
"config" category.

The global variable is only needed for locale, so use explicit argument
passing for everything else, as before.

While at it, make other binaries (fish_key_reader, fish_indent) use
the same localization logic as fish. This means that we need to tweak
the «ends_with("bin/fish")» check.

Closes #11785
2025-09-13 15:12:23 +02:00
Johannes Altmanninger
a7f8e294ba config_paths: remove rogue use of std::env::args() 2025-09-13 15:12:23 +02:00
Johannes Altmanninger
01ae00c653 config_paths: remove weird and redundant path handling
This duplicates work already done in get_executable_path().  No idea
why this was added.
2025-09-13 15:12:23 +02:00
Johannes Altmanninger
ee8a88a101 config_paths: rework logging a little
The executable path is used for embedded builds too, so let's log
it always.
2025-09-13 15:12:23 +02:00
Johannes Altmanninger
b4697231d7 config_paths: remove a comment
I'm not sure if setting PROGRAM_NAME based on argv[0] is a good idea.
2025-09-13 15:12:23 +02:00
Johannes Altmanninger
6cddceb37a config_paths: use immutable/SSA style for determining config paths
This logic is extremely confusing because it creates a ConfigPaths
object only to throw it away later. Fix that.
2025-09-13 15:12:23 +02:00
Johannes Altmanninger
8640ce8148 config_paths: embed-data has no doc dir
This makes no sense:

	$ target/debug/fish -d config
	config: paths.doc: .local/share/doc/fish

so remove it.

While at it, group config paths by whether they can be embedded.
2025-09-13 15:12:23 +02:00
Johannes Altmanninger
f7a2d56046 config_paths: model embed-data dichotomy better
Rather than having every single config path be an Option<Path>,
clarify that we define either all or nothing.

If we want to decide this at runtime, we'd use an enum; but it's all
known at compile time, so we can give the reader even more information.

Unfortunately this means that compile errors in non-embed-data
code paths might go unnoticed for a while, and rust-analyzer often
doesn't work in those code paths. But that's a general problem with
the compile-time feature, it seems orthodox to ifdef away as much
as possible.

There are some odd data paths that don't follow the "all or nothing",
the next commits will fix this.

Note that this breaks localization for target/debug/fish built with
embed-data. But as soon as fish was moved out of the repo, that was
already broken.
2025-09-13 15:12:23 +02:00
Johannes Altmanninger
cacb9f50b8 config_paths: use early return 2025-09-13 15:12:23 +02:00
Johannes Altmanninger
cef60fe585 config_paths: remove obsolete installable vars
Same reason as the grandparent commit.
2025-09-13 15:12:23 +02:00
Johannes Altmanninger
04a2398c90 config_paths: separate ifdef'd path logic into functions
No functional change, only reduce the number of times we check for
presence of the embed-data feature.

While at it, move ConfigPaths?
2025-09-13 15:12:23 +02:00
Johannes Altmanninger
f05ad46980 config_paths: remove vestiges of installable builds
Commit 3dc49d9d93 (Allow installable builds to be installed into a
specific path (#10923), 2024-12-22) added some ifdefs to use installed
config paths for installable builds that have already been installed.

The "installable" feature has been superseded by "embed-data"
which no longer uses config paths to retrieve files,
so remove those code paths. Further cleanup to follow.
2025-09-13 15:12:23 +02:00
Johannes Altmanninger
e9595d4817 config_paths: remove dead code trying to handle in-tree CMake builds
Assuming every in-tree build uses CMake, the source tree must
also be a valid build directory, so we already return in the
env!("FISH_BUILD_DIR") code path above.
2025-09-13 15:12:23 +02:00
Johannes Altmanninger
deabcf5478 config_paths: fix comment 2025-09-13 15:12:23 +02:00
Johannes Altmanninger
e73243b879 Reuse workspace_root() helper from fish-build-helper 2025-09-13 15:12:23 +02:00
Johannes Altmanninger
632b6582c5 builds.rs: canonicalize workspace root and build dir only when necessary
This means we can remove the unwrap() calls from fish-build-helper,
which paves the way for reusing it in the config_paths module.
2025-09-13 15:12:23 +02:00
Johannes Altmanninger
27db0e5fed Rename repo_root to workspace_root
This seems like a slightly better term
because I think it also applies to tarball.
Ref: https://github.com/fish-shell/fish-shell/pull/11785#discussion_r2335280389
2025-09-13 15:12:23 +02:00
Johannes Altmanninger
33735f507a Fix regression causing build/fish to use wrong config paths
Commit 8b102f2571 (Stop using Cargo's OUT_DIR,
2025-06-22) accidentally removed canonicalization of
FISH_BUILD_DIR=${CMAKE_BINARY_DIR}.  This means that if the path to
${CMAKE_BINARY_DIR} includes a symlink, ${CMAKE_BINARY_DIR}/fish will
wrongly use /usr/share/fish instead of ${CARGO_MANIFEST_DIR}/share.
Fix this and reintroduce the comment.
2025-09-13 15:12:23 +02:00
Johannes Altmanninger
bde8a5aa40 path: fix inconsistency in default PATH
path_get_path does not use "getconf PATH", for no apparent reason.
Fix that.
2025-09-13 15:12:23 +02:00
Johannes Altmanninger
e0cd9e2e0a bin/fish.rs: remove dead argv fallback
I think argv[0] is guaranteed to be non-null.
2025-09-13 15:12:23 +02:00
Johannes Altmanninger
7e1123fb42 bin/fish.rs: remove needless clone 2025-09-13 15:12:23 +02:00
Johannes Altmanninger
f7648757f1 autoload: simplify conditional compilation 2025-09-13 15:12:23 +02:00
Johannes Altmanninger
78d46f4b47 fish_indent.rst: remove missing debug options 2025-09-13 15:11:35 +02:00
Johannes Altmanninger
443956b8e3 ci: run clippy without --features=embed-data too
That configuration is already tested, but not clippy-checked yet.
This sometimes causes things like unused imports linger on master.
Let's at least enable clippy for stable Rust.

Also do the same build_tools/check.sh; since that script already runs
"cargo test --no-default-features", this shouldn't add much work,
though I didn't check that.
2025-09-13 15:10:24 +02:00
Johannes Altmanninger
a58cd12c4d Merge pull request #11779 2025-09-13 15:10:24 +02:00
Johannes Altmanninger
89883b791d checks/po-files-up-to-date.fish: mention how to update translations
As pointed out in
https://github.com/fish-shell/fish-shell/issues/11610#issuecomment-3240489072
2025-09-13 15:10:24 +02:00
Johannes Altmanninger
7706ce2e82 Merge pull request #11794 2025-09-13 15:10:24 +02:00
Daniel Rainer
027ea88477 Use deterministic timestamps for embedded data
We do not need timestamps of embedded files, so setting them to 0
reduces the potential for unwanted changes to the binary, allowing for
better build reproducibility.
2025-09-12 16:43:55 +02:00
Daniel Rainer
6cbd655b3d Update to rust-embed 8.7.2
This is the most recent version, which allows using the
`deterministic-timestamps` feature.
2025-09-12 16:43:03 +02:00
Johannes Altmanninger
529f722d2f build_tools/release.sh: fixes for updating fish-site
Also check that "cd fish-site && make && make new-release" doesn't
leave behind untracked files we're not aware of.  This implies that
this script ought to refuse to run if there are untracked files,
at least in fish-site.
2025-09-12 12:49:29 +02:00
Johannes Altmanninger
7619fa316c Release 4.0.6
Created by ./build_tools/release.sh 4.0.6
2025-09-12 11:47:41 +02:00
Johannes Altmanninger
e2005c64b3 Backport release-script related changes from master
Will commit these to master momentarily (#10449).
2025-09-12 11:47:01 +02:00
Johannes Altmanninger
f9dbb4d419 github workflows: actually include the tarballs in the release 2025-09-12 11:46:24 +02:00
Johannes Altmanninger
5e658bf4e9 Release automation script
Things that are not currently happening in this workflow:
- No GPG-signature on the Git tag
- No *.asc signature file for the tarball (or for any other release assets)
- No GPG-signed Debian and other OBS packages

To-do:
- remove the corresponding entries from
  https://github.com/fish-shell/fish-shell/wiki/Release-checklist
  and link to this workflow.
- Maybe add some testing (for the Linux packages)?.
- Let's hope that this doesn't cause security issues.

Usage:
1. run "build_tools/release.sh $version"; this will create and push
   a tag, which kicks off .github/workflows/release.yml
2. wait for the draft release to be created at
   https://github.com/fish-shell/fish-shell/releases/tags/$version
3. publish the draft (manually, for now). This should unblock the
   last part of the workflow (website updates).

Closes #10449

Incremental usage example:

	version=4.0.3
	repository_owner=fish-shell
	remote=origin
	cd ../fish-shell-secondary-worktree
	git tag -d $version ||:
	git push $remote :$version ||:
	git reset --hard origin/Integration_$version
	for d in .github build_tools; do {
		rm -rf $d
		cp -r ../fish-shell/$d .
		git add $d
	} done
	git commit -m 'Backport CI/CD'
	echo "See https://github.com/$repository_owner/fish-shell/actions"
	echo "See the draft release at https://github.com/$repository_owner/fish-shell/releases/$version"
	../fish-shell/build_tools/release.sh $version $repository_owner $remote
2025-09-12 11:42:59 +02:00
Johannes Altmanninger
9ada3e6c16 Group changelog entries 2025-09-12 11:14:52 +02:00
Johannes Altmanninger
0c7e7e3fd9 Add sphinx-markdown-builder for generating release notes
Without this, Sphinx refuses to use the "-b markdown" builder (see next commit).
2025-09-12 10:48:21 +02:00
Johannes Altmanninger
ebcb2eac68 github workflows staticbuild: use stable Rust on Linux
We use the MSRV for CI checks, and for deploying to old macOS.
But for static Linux builds , there should be no reason to use an
old Rust version.  Let's track stable.
2025-09-12 10:48:21 +02:00
Johannes Altmanninger
a7d50c1a62 CHANGELOG: minor updates 2025-09-12 10:48:21 +02:00
Johannes Altmanninger
6056b54ddb Rename build_tools/make_pkg.sh
pkg is a pretty subtle name?
2025-09-11 14:17:40 +02:00
Johannes Altmanninger
bdba2c227d CHANGELOG: update 2025-09-11 13:55:30 +02:00
Johannes Altmanninger
2563adfee1 github workflows: mac_codesign: clean up 2025-09-10 12:41:51 +02:00
Johannes Altmanninger
acad6e6a92 github workflows autolabel: remove stale milestone code
We look for a milestone that no longer exists.
Remove this until we find a solution.
2025-09-10 12:41:51 +02:00
Johannes Altmanninger
9faf78d269 github actions: fix warning about unexpected inputs
CI runs show warnings like

	ubuntu-32bit-static-pcre2
	Unexpected input(s) 'targets', valid inputs are ['']

This is about the rust-toolchain action, which is a composite action, see
https://docs.github.com/en/actions/tutorials/create-actions/create-a-composite-action
not a full workflow
https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows

Looks like composite actions specify inputs at top level.
Also they should not need «on: ["workflow_call"]».

The unexpected inputs are still forwared, so it happens to work.
Fix the warnings.
2025-09-10 12:41:51 +02:00
Johannes Altmanninger
201882e72a CHANGELOG: fix inline literal RST syntax 2025-09-09 07:46:31 +02:00
The0x539
b0565edf85 reader: add case-insensitive history autosuggest
Resolves issue #3126

To match what I've been able to figure out about the existing design
philosophy, case-sensitive matches still always take priority,
but case-insensitive history suggestions precede case-insensitive
completion suggestions.
2025-09-08 22:26:02 -05:00
Johannes Altmanninger
80fff4439f Merge pull request #11784 2025-09-08 11:11:21 +02:00
Johannes Altmanninger
54c48e20d3 completions/ansible: update translations 2025-09-08 11:11:21 +02:00
Johannes Altmanninger
c1af3f2a8f Merge pull request #11783 2025-09-08 11:11:21 +02:00
Johannes Altmanninger
01d7f93917 Merge pull request #11782 2025-09-08 11:08:31 +02:00
Johannes Altmanninger
a9be7b0298 Merge pull request #11781 2025-09-08 11:07:56 +02:00
ookami
5d66e02412 create_manpage_completions.py: Fix options_parts_regex
Escape the dot before "RE".

Fix matching options containing "RE", e.g. ADDRESS.
2025-09-08 10:14:21 +08:00
Vincent Rischmann
18ed4f5f10 Add completion for become-password-file option 2025-09-07 00:51:36 +02:00
Lucas Garron
0f609e7054 build_tools/update_translations.fish --no-mo 2025-09-05 21:07:13 -07:00
Lucas Garron
b77ea98ee0 npm install completions: add --save-peer flag
It's unclear if there is a short flag, since `npm install --help` does not list all short flags.
2025-09-05 18:46:53 -07:00
Johannes Altmanninger
1db0ff9f77 Allow overriding __fish_update_cwd_osc to work around terminal bugs
See #11777

While at it, pull in the TERM=dumb check from master.

(cherry picked from commit 898cc3242b)
2025-09-05 09:39:57 +02:00
Johannes Altmanninger
898cc3242b Allow overriding __fish_update_cwd_osc to work around terminal bugs
See #11777
2025-09-05 09:38:25 +02:00
Nathan Chancellor
66940e8369 completions/systemctl: Handle --boot-loader-entry and --boot-loader-menu
systemd 242 added two new options to halt, poweroff, and reboot:

  --boot-loader-entry: Reboot to a specific boot loader entry
  --boot-loader-menu: Reboot into boot loader menu with specified
                      timeout

Add these to the systemctl completion so that it is easy to
interactively select available entries.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2025-09-04 19:25:56 -07:00
Johannes Altmanninger
f98bf3d520 functions/man: use "command man", skipping functions
As reported in
https://github.com/fish-shell/fish-shell/issues/11767#issuecomment-3240198608,
the new "man" function uses "rm" which is sometimes overidden to do
"rm -i".

Same as d3dd9400e3 (Make sure the rm command and not a wrapper
function that could change its behaviour is used. 2006-12-12)

While at it, make sure that all users of __fish_mktemp_relative
1. return if mktemp fails
2. actually clean up their temporary directory -- except for help.fish
   which spawns an asynchronous browser window.
2025-08-31 17:33:24 +02:00
Johannes Altmanninger
90862c5c57 edit_command_buffer: remove dead code 2025-08-31 17:29:07 +02:00
Johannes Altmanninger
4abdc8716b share/functions/__fish_mktemp_relative: adopt argparse -u 2025-08-29 22:23:53 +02:00
Johannes Altmanninger
4ba070645d Merge pull request #11763 2025-08-29 22:23:53 +02:00
Johannes Altmanninger
4a12d57711 Merge pull request #11698 2025-08-29 22:23:52 +02:00
Johannes Altmanninger
8741e201de Install fish-terminal-compatibility man page
Not sure about whether "man fish-terminal-compatibility"; it's not
really meant for end-users, but it also doesn't hurt raise awareness
of the existence of this doc.

Either way, we should be consistent with embedded builds, where this
works since the parent commit.
2025-08-29 22:23:52 +02:00
Johannes Altmanninger
c3c3a9518c functions/man: fix for embedded fish-* man pages
"man abbr" works in embed-data builds,
but "man fish-faq" doesn't.

This is because it delegates to

	__fish_print_help fish-faq

which skips all lines until the NAME section:

	contains -- $name NAME; and set have_name 1

but the NAME section doesn't exist for this man pages, it only exists
for docs from doc_src/cmds/*.rst.

Let's use the "man" utility instead; this is also what the user
asked for.  Unfortunately we can't use "status get-file | man -l -"
because that's not supported on BSD man.  Note that man displays the
basename of the file, so make sure it looks good.
2025-08-29 22:23:52 +02:00
Johannes Altmanninger
0ebd41eb9f Extract function for calling mktemp
BSD mktemp doesn't support GNU mktemp's -t or --tmpdir option, so when
we want a named temporary file, we need to compute ${TMPDIR:-/tmp}
ourselves, see 5accc7c6c5 (Fix funced's tmpfile generation on OSX,
2016-05-23).

While at it, use template like "fish.XXXXXX"; seems like a good idea?

Take care to have edit_command_buffer use a pretty filename.
2025-08-29 22:23:27 +02:00
Johannes Altmanninger
35733a0f8d functions/man: allow "man !"
Analogous to the "! -h" code path.
2025-08-29 22:00:25 +02:00
Johannes Altmanninger
c1f6e0c03e CONTRIBUTING: mention sourcehut mailing list 2025-08-29 21:11:24 +02:00
Johannes Altmanninger
c36e7967e2 CONTRIBUTING: recommend build_tools/check.sh 2025-08-29 20:32:58 +02:00
Johannes Altmanninger
7f91e029fb CONTRIBUTING: remove mention of Coverity
Seems stale?
2025-08-29 20:32:58 +02:00
Johannes Altmanninger
ca131f7440 README: mention Python version also in build dependencies 2025-08-29 20:32:58 +02:00
Johannes Altmanninger
df3fc48a21 README: mention /bin/sh dependency
As reported in
https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$39FQId4CHJ6yT8B4S4smD4MDbxp4pT8Eio-cGP0KoEU
we currently require "sh -c" for some background tasks.  Document this.
2025-08-29 20:32:58 +02:00
Johannes Altmanninger
9258275fe6 config_paths: fix compiled-in locale dir for installed, non-embed builds
Commit bf65b9e3a7 (Change `gettext` paths to be relocatable (#11195),
2025-03-30) broke the locale path.

Commit c3740b85be (config_paths: fix compiled-in locale dir,
2025-06-12) fixed what it calls "case 4", but "case 2" is also
affected; fix that. Before/after:

	$ ~/.local/opt/fish/bin/fish -d config
	paths.locale: /home/johannes/.local/opt/fish/share/fish/locale
	$ ~/.local/opt/fish/bin/fish -d config
	paths.locale: /home/johannes/.local/opt/fish/share/locale

See https://github.com/fish-shell/fish-shell/issues/11683#issuecomment-3218190662

(cherry picked from commit 21a07f08a3)
2025-08-29 19:29:03 +02:00
Isaac Oscar Gariano
6149ac4e40 Added a -C/--center option to string pad.
The --center option does exactly what you'd expect. When a
perfectly centred result is not possible, this adds extra padding to
the left. If the --right option is also given, the extra padding is
added to the right.
2025-08-30 02:57:01 +10:00
Isaac Oscar Gariano
d82442991b Fix argparse documentation to make it clear that -n takes an argument. 2025-08-30 01:55:56 +10:00
Isaac Oscar Gariano
944cfd181e Added a -v/--validate option to fish_opt
This new flag causes fish_opt to generrate an option spec with !
(e.g. "fish_opt -s s -rv some code" will output "s=!some code").

Such validation scripts are not particular useful (they are highly limited as
they cannot access the values for other options, and must be quoted
appropriately so they can be passed to argparse). I merely added the option to
fish_opt so that it can now generate any valid option spec.
2025-08-30 01:55:56 +10:00
Isaac Oscar Gariano
007edac145 Make argparse reject supplying a validator for boolean flags
Specifically, this commit simply makes argparse issue an error if you use the !
syntax to define a validation script on an option that does not take any
arguments. For example, "argparse foo!exit -- --foo" is now an error. This was
previously accepted, despite that fact that the code after ! would never be
executed (the ! code is only executed when an option is given a value).

Alternatively, ! validation scripts could be made to execute even when no value
was provided, but this break existing code that uses them with flags that take
optional values.
2025-08-30 01:55:56 +10:00
Isaac Oscar Gariano
c403822fac Modified argparse to support one character long only options.
This fixes an issue noticed in the previous commit (the made the -s/--short
option optional to fish_opt): it was impossible to define a single character
long flag, unless you also provided a single-character short flag equivalent.

This commit works by allowing an option spec to start with a '/', treating the
subsequent alpha-numeric characters as a long flag name.

In detail, consider the following:
- s defines a -s short flag
- ss defines an --ss long flag
- /ss (new) also defines a --ss long flag
- s/s defines a -s short flag and an --s long flag
- s-s defines a --s long flag (if there's already an -s short flag, you'd have
    to change the first s, e.g. S-s)
- /s (new) defines a --s long flag
- s/ is an error (a long flag name must follow the /)

Note that without using --strict-longopts, a long flag --s can always be
abbreviated as -s, provided that -s isn't defined as a separate short flag.

This 'issue' fixed by this commit is relatively trivial, however it does allow
simplifying the documentation for fish_opt (since it no longer needs to mention
the restriction). In particular, this commit makes the --long-only flag to
fish_opt completely unnecessary (but it is kept for backwards compatibility).
2025-08-30 01:55:56 +10:00
Isaac Oscar Gariano
663430a925 Added support to fish_opt for defining a long flag with no short flag.
Specifically, this now makes the -s/--short option to fish_opt optional when the
-l/--long option is given. This commit does not modify argparse, as it already
supports defining long flags without a corresponding short flag, however
fish_opt would never take advantage of this feature.

Note that due to a limitation in argparse, fish_opt will give an error if you
try to define a one-character --long flag without also providing a --short
option.

For backwards compatibility, the --long-only flag is still included with
fish_opt, and when used with -s/--short, will behave as before (the short flag
is still defined, but argparse will fail if it is actually used by the parsed
arguments, moreover the _flag_ option variables will not be defined). This can
however be used to define a one character long flag.
2025-08-30 01:55:56 +10:00
Isaac Oscar Gariano
4db61ee117 Added argparse support for arguments with multiple optional values.
This commit fixes #8432 by adding put =* in an option spec to indicate that the
option takes an optional value, where subsequent uses of the option accumulate
the value (so the parsing behaviour is like =?, but the _flag_ variables are
appended to like =+). If the option didn't have a value, it appends an empty
string. As an example,. long=* -- --long=1 --long will execute
set -l _flag_long 1 '' (i.e. count $_flag_long is 2), whereas with =? instead,
you'd get set -l _flag_long (i.e. count $_flag_long is 0).

As a use case, I'm aware of git clone which has a
--recurse-submodules=[<pathspec>]: if you use it without a value, it operates on
all submodules, with a value, it operates on the given submodule.

The fish_opt function will generate an =* option spec when given both the
--optional-val and --multiple-vals options (previously, doing so was an error).
fish_opt now also accepts -m as an abbreviation for --multiple-vals, to go with
the pre-existing -o and -r abbreviations for --optional-val and --required-val.
2025-08-30 01:55:56 +10:00
Isaac Oscar Gariano
9d56cdbcbc Added a -U/--unknown-arguments option to argparse
The new -U/--unknown-arguments option takes either 'optional', 'required', or
'none', indicating how many arguments unknown options are assumed to take.
The default is optional, the same behaviour as before this commit, despite
most options in practice taking not taking any arguments. Using
--unknown-arguments=required and --unknown-arguments=none (but not
--unknown-arguments=optional) can give you parse errors if, respectively,
an unknown option has no argument (because it the option is at the end of the
argument list), or is given an argument (with the `--flag=<value> syntax).
See doc_src/cmds/argparse.rst for more details (specifically, the descritpion
of the --unknown-arguments flag and the example at the end
of the examples section).

As a convenience, -U/--unknown-arguments implies -u/--move-unknown.
However you can use it the deprecated -i/--ignore-unknown if you really want to.
2025-08-30 01:55:56 +10:00
Isaac Oscar Gariano
8ae685cf27 Refactored argparse code by removing ArgCardinality type.
This just uses an ArgType and 'accumulate_args' bool in place of the old
ArgCardinality. Curently only one of the three kinds of an ArgType can
have both a true and false accumulate_args. But this will be extended to
two of three in a future commit.
2025-08-30 01:55:56 +10:00
Isaac Oscar Gariano
24eeed65a2 Added an -S/--strict-longopts option to argparse.
This flag disables a very surprising and confusing feature I found in the code
of wgetopt.rs: the ability to abbreviate the names of long options and the
ability to parse long options with a single "-". This commit addresses #7341,
but unlike pull request #11220, it does so in a backwards compatible way: one
must use the new -S/--strict-longotps flag to disable the old legacy behaviour.

Unlike pull request #11220 however, this flag only applies to ``argparse``,
and not to any builtins used by fish.

Note that forcing the flag -S/--strict-longotps on (i.e. in  src/wgetopt.rs,
replacing both uses of `self.strict_long_opts` with `true`), does not cause any
of the current test cases to fail. However, third-party fish scripts may be
depending on the current behaviour.
2025-08-30 01:55:56 +10:00
Isaac Oscar Gariano
70dca1e136 Give a more helpful error when a boolean option has an argument.
This fixes an issue very similar to #6483,
For example, fish --login=root used to print this:
    fish: --login=root: unknown option
But `--login` is a valid option to fish.
So the above now prints:
    fish: --login=root: option does not take an argument

This is done by modifying WGetOpter so that it returns a ';' if it encountered
an option with an argument, but the option was not declared as taking an option
(this is only possible with the --long=value or legacy -long=value syntax).
All uses of WGetOpter (except echo, fish_indent, and some tests) are modified to
then print an appropriate error message when ';' is returned.
echo doesn't have any long options, so it will panic if gets a ';'.
fish_indent doesn't print any error messages for invalid options anyway, and I
wasn't sure if this was intentional or not.

Moreover, WGetOpter now always returns a ':' for options that are missing an
argument. And you can no longer prefix a your option spec with a ':' to enable
this (since every use of WGetOpter was doing this anyway, except
wgetopt::test_exchange and tests::wgetopt::test_wgetopt).
2025-08-30 01:55:56 +10:00
Isaac Oscar Gariano
c94eddaf4b Replaced all uses of argparse -i with argparse -u
This removes the functions/completions that were using the deprecated
--ignore-unknown option and replaces it with the new --move-unknown.

Although some of the code is now more verbose, it has improved the
functionality of two completions:
    the iwctl completion will now skip over options when detecting
        what subcommand is being used
    the ninja completion wil now handle -- correctly: if the completion
        internally invokes ninja, it will correctly interpret the users
        arguments as being arguments if they start with a - and occur
        after the --.
2025-08-30 01:10:03 +10:00
Isaac Oscar Gariano
51d16f017d Added a -u/--move-unknown option to argparse.
--move-unknown is like --ignore-unknown, but unknown options are instead moved
from $argv to $argv_opts, just like known ones. This allows unambiguously
parsing non-option arguments to other commands. For example if $argv contains
`--opt -- --file`, and we execute `argparse --move-unknown -- $argv`, we can
then call `cmd $argv_opts -- --another-file $argv`, which will correctly
interpret `--opt` as an option, but `--file` and `--some-file` as an argument.
This makes `--move-unknown` a better alternative to `--ignore-unknown`, so the
latter has been marked as deprecated, but kept for backwards compatibility.
2025-08-29 23:10:02 +10:00
Isaac Oscar Gariano
5a7e5dc743 Make argparse separate known and unknown options that occur in a group together.
For example, argparse --ignore-unknown h -- -ho will now set set $argv to -o and
$argv_opts to -h (i.e. -ho is split into -h and -o). Previously, it would set
$argv to -ho, and $argv_opts to empty. With this change, the "Limitations"
section of argparse's man page has been removed, and the examples merged into
the description of the -i/--ignore-unknown option. (Note: there was another
'limitation' mentioned in the 'limitations' section: that everything occuring
after an unknown option in a group was considered an argument to an option; the
documentation has been reworded to make it clear that this is intended
behaviour, as unknown options are always treated as taking optional arguments,
and modifying that behaviour would be a breaking change and not a bug fix).
2025-08-29 23:10:02 +10:00
Isaac Oscar Gariano
f780b01ac9 Added way to tell argparse to delete an option from $argv_opts.
The intention is that if you want to parse some of your options verbatim to
another command, but you want to modfy other options (e.g. change their value,
convert them to other options, or delete them entirely), you mark the options
you want to modify with an &, and argparse will not add them to argv_opts. You
can then call the other command with argv_opts together with any new/modified
options, ensuring that the other command doesn't set the pre-modified options.
As with other known options, & options will be removed from $argv, and have
their $_flag_ variables set.

The `&` goes at the end of the option spec, or if the option spec contains a
validation script, immediately before the `!`. There is also now a -d/--delete
flag to fish_opt that will generate such an option spec.

See the changes in doc_src/cmds/argparse.rst for more details and an example use
case.
2025-08-29 23:10:02 +10:00
Isaac Oscar Gariano
ddcb1813a7 Clarified & fixed documentation for fish_opt options.
The previous fish_opt synopsis was hard to parse, and was incorrect:
- it indicated that -s is optional
- it indicated that only one option could be provided
- it indicated that every option took a value
2025-08-29 23:10:02 +10:00
Isaac Oscar Gariano
e62abc460d Make argparse save parsed options in $argv_opts. (Fixes #6466)
Specifically, every argument (other than the first --, if any) that argparse
doesn't add to $argv is now added to a new local variable $argv_opts. This
allows you to make wrapper commands that modify non-option arguments, and then
forwards all arguments to another command. See the new example at the end of
doc_src/cmds/argparse.rst for a use case for this new variable.
2025-08-29 23:10:02 +10:00
Isaac Oscar Gariano
e6b4f0a696 Stopped argparse tests from leaking local variables.
By wrapping the various argparse tests in begin ... end blocs, it makes it much
easier to debug test failures and add new tests. In particular, each block is
independent, and shouldn't affect any subsequent tests. There's also now a check
at the end of the test file to ensure that the tests are no longer leaking local
variables.
2025-08-29 23:10:02 +10:00
Johannes Altmanninger
c0c9245d99 completions/java_home: fix version completion due to change of osascript default output
Apparently the last expression outputs to stdout.

Closes #11743
2025-08-27 10:01:51 +02:00
Isaac Oscar Gariano
f843d5bd34 Disable editor hard wrapping for .rst and .md files.
The .md and .rst files allready present do not hard wrap lines (the
style seems to be one line per paragraph, which could be a few hundred
characters long). So this makes those files have no line length limit,
instead of 100.
2025-08-27 10:01:51 +02:00
Johannes Altmanninger
6900b89c82 Add mark-prompt feature flag
So far, terminals that fail to parse OSC sequences are the only reason
for wanting to turn off OSC 133.  Let's allow to work around it by
adding a feature flag (which is implied to be temporary).

To use it, run this once, and restart fish:

    set -Ua fish_features no-mark-prompt

Tested with

    fish -i | string escape | grep 133 &&
    ! fish_features=no-mark-prompt fish -i | string escape | grep 133

See #11749
Also #11609
2025-08-27 09:17:35 +02:00
Johannes Altmanninger
4a9fd1bbbb completions/loginctl: accept alphabetic session names
systemd's session_id_valid accepts [a-zA-Z0-9], so allowing only
numbers is wrong.

Fixes #11754

While at it, correct the description; instead of
showing the leader PID, show the seat, which is probably
2025-08-27 08:34:16 +02:00
Daniel Rainer
7b8efe3105 Remove Optional annotation
The is inconsistent with the type annotation of `TestPass.duration_ms`.
The function is only called with `duration_ms` as an int, so there is no
need to declare it `Optional`.
2025-08-26 20:54:02 +08:00
Daniel Rainer
425d487de9 Remove redundant clones 2025-08-25 10:24:03 +02:00
Johannes Altmanninger
21a07f08a3 config_paths: fix compiled-in locale dir for installed, non-embed builds
Commit bf65b9e3a7 (Change `gettext` paths to be relocatable (#11195),
2025-03-30) broke the locale path.

Commit c3740b85be (config_paths: fix compiled-in locale dir,
2025-06-12) fixed what it calls "case 4", but "case 2" is also
affected; fix that. Before/after:

	$ ~/.local/opt/fish/bin/fish -d config
	paths.locale: /home/johannes/.local/opt/fish/share/fish/locale
	$ ~/.local/opt/fish/bin/fish -d config
	paths.locale: /home/johannes/.local/opt/fish/share/locale

Fixes https://github.com/fish-shell/fish-shell/issues/11683#issuecomment-3218190662
2025-08-25 10:11:01 +02:00
David Adam
67e8657109 debian packaging: don't remove Cargo.toml.orig files
Newer versions of cargo include the Cargo.toml.orig file when vendoring,
but dh_clean removes those by default. Try to disable this to fix the
package builds again.
2025-08-23 19:40:53 +08:00
Daniel Rainer
e96300b08e Build man pages in separate crate
Building man pages takes significant time due to Sphinx running for several
seconds, even when no updates are required. Previously, we added custom logic to
avoid calling `sphinx-build` if the inputs to `sphinx-build` had not changed
since a cached timestamp.

By moving this into its own crate, we can tell cargo to rebuild when the input
files changed and unrelated changes will have no effect on this crate. This
allows us to get rid of the custom code for tracking whether to recompile, while
keeping the effect of only calling `sphinx-build` when appropriate.

In order to avoid code duplication, a new `build-helper` crate is added,
which contains some functionality for use in `build.rs`.

Closes #11737
2025-08-22 09:14:56 +02:00
Daniel Rainer
32e5fa0c03 Stop depending on fish_indent for man pages
This allows building man pages without having `fish_indent` available, which is
useful because building man pages can happen during compilation of the fish
binaries, including `fish_indent`, resulting in an annoying cyclic dependency.

This change does not affect the generated man pages, at least with the current
config.
2025-08-22 09:12:10 +02:00
Daniel Rainer
e895f96f8a Do not rely on fish_indent for version in Sphinx
Depending on `fish_indent` when building docs is problematic because the docs
might get built before `fish_indent` is available. Furthermore, a version of
`fish_indent` which does not correspond to the current build might be used,
which would result in incorrect version information.

Use the `git_version_gen.sh` script instead to ensure up-to-date version
information without depending on build output.
2025-08-22 09:12:10 +02:00
Johannes Altmanninger
92f7063acb Use version=0.0.0 for unpublished crates
As discussed in #11737
2025-08-22 09:12:10 +02:00
Daniel Rainer
cd71801360 Use workspace dependencies exclusively
This allows us to track all dependencies in a single place and
automatically avoids using different versions of the same dependency in
different crates.

Sort dependencies alphabetically.

Closes #11751
2025-08-22 09:12:10 +02:00
Daniel Rainer
24898c61af Sync dependency versions of crates
This is done to allow merging all dependencies into workspace
dependencies.
2025-08-21 21:39:35 +02:00
Johannes Altmanninger
62b7c81052 Merge pull request #11742 2025-08-21 20:40:33 +02:00
Daniel Rainer
d32ce89889 Remove unnecessary rebuild paths
Cargo tracks normal Rust dependencies and automatically figures out if changes
to Rust source files, `Cargo.{toml,lock}`, and `build.rs` necessitate a rebuild,
and if so of what. In some cases these checks are smarter than just comparing
file modification times, so not specifying such paths explicitly can reduce the
amount of rebuilding which happens, without skipping necessary rebuilding.

ja: this reverts b2aaf1db52 (Rebuild if src changed, 2025-03-28) and
460b93a (Rebuild on changes relevant to build artifacts, 2025-03-30)
which tried to fix #11332 ("moving Git HEAD does not invalidate cargo
build results").  But that expectation is overbearing.  It's better
to only rebuild if something else of relevance to the build output
has changed.

Closes #11736
2025-08-21 20:40:33 +02:00
Henrik Hørlück Berg
16119377c3 Document --allow-empty, specify -r is only useful w/ -m
As noted in #11744
2025-08-21 00:06:24 +02:00
Kevin F. Konrad
5a45fec730 add completions for stackit CLI 2025-08-20 11:54:57 +02:00
Johannes Altmanninger
d26fd90efd Merge pull request #11741, closes #11741 2025-08-20 10:16:19 +02:00
Daniel Rainer
1c654f23af Put local dependencies in crates directory
With an increasing number of local dependencies, the repo root is getting
somewhat bloated. This commit moves the two current local dependencies into the
newly created `crates` directory, with the intention of using it for all future
local dependencies as well.

Some dependencies which are introduced by currently in-progress pull requests
will need modifications in order for relative paths to work correctly.
2025-08-20 10:16:19 +02:00
Johannes Altmanninger
b828822385 Merge pull request #11695 2025-08-20 10:14:34 +02:00
Johannes Altmanninger
e795ed4061 Merge pull request #11738 2025-08-20 10:14:27 +02:00
Johannes Altmanninger
3363d55ec4 staticbuild.yml: break up long line 2025-08-20 10:14:08 +02:00
Johannes Altmanninger
f8bfb7cb6b editorconfig: commit message line length is 72, not 80
This is more standard. Not sure how many people use editorconfig though.
2025-08-20 10:14:08 +02:00
Daniel Rainer
ce7733c75f Remove unnecessary parentheses
This was spotted by a lint on nightly Rust.
2025-08-19 00:26:21 +02:00
Johannes Altmanninger
feaec20de6 Run update_translations.fish 2025-08-18 14:10:46 +02:00
Daniel Rainer
514d34cc52 Add cargo feature for enabling gettext extraction
This allows having the proc macro crate as an optional dependency and speeds up
compilation in situations where `FISH_GETTEXT_EXTRACTION_FILE` changes, such as
the `build_tools/check.sh` script. Because we don't need to recompile on changes
to the environment variable when the feature is disabled, cargo can reuse
earlier compilation results instead of recompiling everything.
This speeds up the compilation work in `build_tools/check.sh` when no changes
were made which necessitate recompilation.
For such runs of `build_tools/check.sh`, these changes reduce the runtime on my
system by about 10 seconds, from 70 to 60, approximately.
The difference comes from the following two commands recompiling code without
the changes in this commit, but not with them:
- `cargo test --doc --workspace`
- `cargo doc --workspace`
2025-08-18 10:37:59 +02:00
Daniel Rainer
367696b346 Remove unnecessary into_iter call
Starting with Rust 1.90, this `into_iter` call triggers the
`clippy::useless_conversion` lint.
2025-08-17 20:20:09 -07:00
Daniel Rainer
70a9327858 Do not unwrap after checking with is_err
Doing so results in the `clippy::unnecessary_unwrap` lint starting with Rust
1.90 (in beta at the moment).
2025-08-17 20:20:09 -07:00
idealseal
a766c44a18 feat(comp): update networkctl completions 2025-08-17 20:17:00 -07:00
Peter Ammon
13d9aa0002 Changelog PR 11729 2025-08-16 11:22:45 -07:00
Bryce Berger
9273f352a0 allow psub --fifo --suffix ... 2025-08-15 15:02:44 -04:00
Johannes Altmanninger
79135c6c82 Merge pull request #11713, closes #11713 2025-08-15 18:11:07 +02:00
Daniel Rainer
5de43a4e86 Call fsync after appending to history file
This is an attempt to eliminate history file corruption as described in
https://github.com/fish-shell/fish-shell/issues/10300.
In particular, issues raised in
https://github.com/fish-shell/fish-shell/issues/10300#issuecomment-2567063654
can benefit from such synchronization.
2025-08-15 18:10:20 +02:00
Daniel Rainer
188282a27b Don't redundantly unlink() temporary file after renaming
There is an unlikely issue if two shells are concurrently rewriting the
history file:
- fish A runs rename("fish_history.DEADBEEF") (rewriting a history file with)
- fish B starts rewriting the history file; since "fish_history.DEADBEEF" no longer exists, it can in theory use that filename
- fish A runs wunlink("fish_history.DEADBEEF"), destroying fish B's work

Fix this by not calling wunlink() iff we successfully rename it.

[ja: add commit message and fix "!do_save" case]
2025-08-15 17:50:04 +02:00
Johannes Altmanninger
f59e5884bf Merge pull request #11714
Closes #11714
2025-08-15 17:37:34 +02:00
Johannes Altmanninger
51dcadf7c6 completions/makepkg: remove stale --pkg option
Closes #11724
2025-08-15 17:24:18 +02:00
Daniel Rainer
ba2500211b Call fsync and close tmpfile before rename
This is another attempt at eliminating file corruption, primarily in connection
to the history file, as observed in
https://github.com/fish-shell/fish-shell/issues/10300.

Calling `fsync` and closing the tmpfile should ensure that when the renaming
happens, the file content and metadata are already in persistent storage.

Some background can be found in the following links, which were pointed out in
https://github.com/fish-shell/fish-shell/issues/10300#issuecomment-2567063654:
https://www.comp.nus.edu.sg/~lijl/papers/ferrite-asplos16.pdf
https://archive.kernel.org/oldwiki/btrfs.wiki.kernel.org/index.php/FAQ.html#What_are_the_crash_guarantees_of_overwrite-by-rename.3F
2025-08-15 17:24:02 +02:00
Johannes Altmanninger
491ffb356b Merge pull request #11727 2025-08-15 16:48:34 +02:00
Daniel Rainer
b0ae11e769 Write only once when appending items
Building a buffer in advance and writing it once all items are serialized into
the buffer makes for simpler code, makes it easier to ensure that
`self.first_unwritten_new_item_index` is only updated if writing succeeded, and
it actually matches the previous behavior of the code in most realistic cases,
since previously there was only more than one `write_all` call if the serialized
items took up more than `HISTORY_OUTPUT_BUFFER_SIZE` bytes (64 * 1024), which
seems unlikely to occur during normal use, where mostly just a single item will
be appended.
2025-08-15 16:26:52 +02:00
Daniel Rainer
20e268a75c Clear file state earlier
This should not result in behavioral changes in the code, but it eliminates some
redundant variables and is a step in refactoring the function such that early
returns via `?` become sound.

Remove the `drop` since the lock will be dropped at this point anyway, there is
no need to be explicit about it.
2025-08-15 16:26:03 +02:00
Daniel Rainer
9c4c28da9d Use updated file id
This restores behavior from before f438e80f9b.
The file id changes when data is written to the file, so it needs to be updated
with data obtained after the updates to the file are completed.
2025-08-15 16:26:03 +02:00
Johannes Altmanninger
8219dd8af6 Merge pull request #11715 2025-08-15 16:19:03 +02:00
Johannes Altmanninger
781791c00c Revert "Add rust-toolchain.toml"
By default, we make every rustup user use our pinned version.  This might
not be ideal at this point, for a few reasons:
1. we don't have automatic Rust updates yet (see the parent commit),
   so this might unnecessarily install an old version. As a contributor,
   this feels irritating (newer versions are usually strictly better).
2. it will use more bandwidth and perhaps other resources during "git-bisect"
   scenarios
3. somehow rustup will download things redundantly; it will download "1.89.0"
   and "stable" even if they are identical. The user will need to clean
   those up at some point, even if they didn't add them explicitly.

See also
https://github.com/fish-shell/fish-shell/pull/11712#issuecomment-3165388330

Part of the motivation for rust-toolchain.toml is probably the regular
(every 6 weeks) failures due to the update check, but that failure has been
removed in the parent commit.

The other motivation ("fix the issue of local compiles running into lint
warnings from newer compilers") is a fair point but I think we should rather
fix warnings quickly.

Let's remove rust-toolchain.toml again until we have more agreement on what
we should do.

This reverts commits
* f806d35af8 (Ignore rust-toolchain.toml in CI, 2025-08-07)
* 9714b98262 (Explicitly use fully qualified rust version numbers, 2025-08-07)
* 921aaa0786 (Add rust-toolchain.toml, 2025-08-07)

Closes #11718
2025-08-15 16:10:18 +02:00
Johannes Altmanninger
d93fc5eded Revert "build_tools/check.sh: check that stable rust is up-to-date"
As reported in #11711 and #11712, the update-checks make check.sh automatically
fail every 6 weeks, so it pressures people into updating Rust, and (what's
worse), updating fish's pinned Rust version, even when that's not relevant
to their intent (which is to run `clippy -Dwarnings` and all other checks).

The update-checks were added as a "temporary" solution to make sure that
our pinned version doesn't lag too far behind stable, which gives us an
opportunity to fix new warnings before most contributors see them.

As suggested in #11584, reasonable solutions might be either of:
1. stop pinning stable Rust and rely on beta-nightlies to fix CI failures early
2. use renovatebot or similar to automate Rust updates

Until then, remove the update check to reduce friction.
I'll still run it on my machine.

This reverts commit 6d061daa91.
2025-08-15 15:08:48 +02:00
Daniel Rainer
b2dfb3fd6e Add completions for single-letter cargo aliases 2025-08-15 03:09:28 +02:00
Daniel Rainer
55122b127c Wrap renaming code in function
These changes are not intended to change any behavior. They are done to
facilitate closing the tmpfile before renaming, which is required for
correctness on some filesystems (at least btrfs). Using a `ScopeGuard` which
unlinks when the file is closed/dropped does not work in this context, so the
relevant code is wrapped in a function and the tmpfile is unlinked after the
function returns.
2025-08-12 19:50:53 +02:00
brennenputh
0adcbfa2ac Resolve review comments 2025-08-11 20:32:16 -04:00
Johannes Altmanninger
51fd00c98f Merge pull request #11717 2025-08-10 18:59:30 +02:00
Johannes Altmanninger
c123c4e866 Merge pull request #11691 2025-08-10 18:40:01 +02:00
Johannes Altmanninger
9003835452 Merge pull request #11701 2025-08-10 17:12:50 +02:00
Trevor Bender
cf044038e0 fix typo in completions.rst 2025-08-10 07:49:10 -04:00
brennenputh
6561a1d6ba Add distrobox completion script 2025-08-08 20:48:20 -04:00
Xiretza
894d4ecc53 Update to Rust 1.89, address newly added lints 2025-08-07 21:48:17 +00:00
Xiretza
f806d35af8 Ignore rust-toolchain.toml in CI
We set a specific default toolchain with dtolnay/rust-toolchain, we don't want
it to be overridden by the config intended for devs.
2025-08-07 21:47:36 +00:00
Xiretza
9714b98262 Explicitly use fully qualified rust version numbers
The action expands these internally, but then rust-toolchain.toml is interpreted
literally, and 1.88 is technically a different toolchain from 1.88.0.
2025-08-07 21:28:34 +00:00
Xiretza
921aaa0786 Add rust-toolchain.toml
This ensures that, by default, developers use the toolchain that is also tested
in CI, avoiding spurious warnings from lints added in new compiler versions.
2025-08-07 21:13:32 +00:00
Saeed M Rad
45bb8f535b funced: pretend copied functions are defined interactively
After #9542, the format for `functions -Dv` was changed for copied
functions.

```diff
-stdin
-n/a
+[path to copy location]
+[path to original definition]
 [and a few more lines]
```

Some components were (and perhaps are) still expecting the old format,
however. After a search, it looks like `funced` and `fish_config` are
the only two functions using `functions -D` and `functions -Dv` in this
repo (none are using `type -p`).

As noted in issue #11614, `funced` currently edits the file which
copies the given copied function. Another option was to make `funced`
edit the file which originally defined the function. Since the copied
function would not have been updated either way, I modified `funced` so
it would pretend that the copied function was defined interactively,
like it was before.

I did not modify `fish_config`, since it was only used for preset
prompts in the web config, none of which used `functions --copy`.
(Moreover, I believe it would have behaved correctly, since the preset
would not have had to define the function, only copy it.)

Fixes issue #11614
2025-08-07 10:19:42 +00:00
Bacal Mesfin
fa68770c16 Fix missed bottom right artifact 2025-08-04 13:01:19 -04:00
Bacal Mesfin
4b736fd92b Fix fish.png artifacts
The fish.png doc image has grey pixel artifacts in the
top-left, top-right, and bottom-right corners.

This patch takes the original image from 3a5b096
removes the artifacts, and compresses it with squoosh
to a similar file size.
2025-08-03 07:06:42 -04:00
Johannes Altmanninger
54e8ad7e90 Merge pull request #11623 2025-08-03 08:00:18 +02:00
Kid
944da7dba9 Fix copy paste error 2025-08-02 19:39:54 +08:00
Kid
c9945f3439 Use __fish_cache_sourced_completions 2025-08-02 18:05:46 +08:00
Kid
e8b2767dcc Add completion for pnpm 2025-08-02 18:00:23 +08:00
Johannes Altmanninger
5c216f48a3 Attempt to fix Opensuse Leap 15.6 nightlies
This has been failing because it uses Python 3.6.  Until we have figured
out when we can roll platform off (#11679), let's try to fix this.  Untested.
2025-08-02 11:07:22 +02:00
Johannes Altmanninger
320b8235ed Update README to reflect regained Cygwin/Msys2 support 2025-08-02 11:07:22 +02:00
Johannes Altmanninger
9c0086b7af Backport default alt-delete binding
This is standard on macOS and in chrome/firefox.

On master, this was sneakily added in
2bb5cbc959 (Default bindings for token movements v2, 2025-03-04)
and before that in
6af96a81a8 (Default bindings for token movement commands, 2024-10-05)

Ref: https://lobste.rs/s/ndlwoh/wizard_his_shell#c_qvhnvd
2025-08-02 09:53:22 +02:00
Johannes Altmanninger
f218cf2f38 Merge pull request #11686 2025-08-02 09:19:48 +02:00
Johannes Altmanninger
8158c227c3 Merge pull request #11672 2025-08-02 09:19:48 +02:00
Johannes Altmanninger
2549334bae Merge pull request #11693 2025-08-02 09:19:48 +02:00
ndrew222
ec60bf1898 added completions for glow 2025-07-30 13:25:12 +08:00
JJ
17e0f3d96f Add example of string manipulation to prompt_pwd 2025-07-28 19:55:18 -07:00
Branch Vincent
b4b0fc08da completions: add container 2025-07-26 12:13:05 -07:00
Johannes Altmanninger
e200abe39c __fish_seen_subcommand_from: fix regression causing false negatives given multiple arguments
Fixes 2bfa7db7bc (Restructure __fish_seen_subcommand_from, 2024-07-07)
Fixes #11685

(cherry picked from commit 4412164fd4)
2025-07-26 20:36:53 +02:00
Johannes Altmanninger
6d061daa91 build_tools/check.sh: check that stable rust is up-to-date
As suggested in
https://github.com/fish-shell/fish-shell/discussions/11584#discussioncomment-13674983
In future, we should probably make updates automatic again.
2025-07-26 20:36:03 +02:00
Johannes Altmanninger
4412164fd4 __fish_seen_subcommand_from: fix regression causing false negatives given multiple arguments
Fixes 2bfa7db7bc (Restructure __fish_seen_subcommand_from, 2024-07-07)
Fixes #11685
2025-07-26 17:08:15 +02:00
Johannes Altmanninger
0c8f1f4220 Fix async-signal safety in SIGTERM handler
Cherry-picked from
- 941701da3d (Restore some async-signal discipline to SIGTERM, 2025-06-15)
- 81d45caa76e (Restore terminal state on SIGTERM again, 2025-06-21)

Also, be more careful in terminal_protocols_disable_ifn about accessing
reader_current_data(), as pointed out in 65a4cb5245 (Revert "Restore terminal
state on SIGTERM again", 2025-07-19).

See #11597
2025-07-26 13:09:18 +02:00
Johannes Altmanninger
e593da1c2e Increase timeout when reading escape sequences inside paste/kitty kbd
Historically, fish has treated input bytes [0x1b, 'b'] as alt-b (rather than
"escape,b") if the second byte arrives within 30ms of the first.

Since we made builtin bind match key events instead of raw byte sequences,
we have another place where we do similar disambiguation: when we read keys
such as alt-left ("\e[1;3D"), we only consider bytes to be part of this
sequence if stdin is immediately readable (actually "readable after a 1ms
timeout" since e1be842 (Work around torn byte sequences in qemu kbd input
with 1ms timeout, 2025-03-04)).

This is technically wrong but has worked in practice (for Kakoune etc.).

Issue #11668 reports two issues on some Windows terminals feeding a remote
fish shell:
- the "bracketed paste finished" sequence may be split into multiple packets,
  which causes a delay of > 1ms between individual bytes being readable.
- AutoHotKey scripts simulating seven "left" keys result in sequence tearing
  as well.

Try to fix the paste case by increasing the timeout when parsing escape
sequences.

Also increase the timeout for terminals that support the kitty keyboard
protocol.  The user should only notice this new delay after pressing one of
escape,O, escape,P, escape,[, or escape,] **while the kitty keyboard protocol
is disabled** (e.g. while an external command is running).  In this case,
the fish_escape_delay_ms is also virtually increased; hopefully this edge
case is not ever relevant.

Part of #11668

(cherry picked from commit 30ff3710a0)
2025-07-25 18:29:19 +02:00
Johannes Altmanninger
30ff3710a0 Increase timeout when reading escape sequences inside paste/kitty kbd
Historically, fish has treated input bytes [0x1b, 'b'] as alt-b (rather than
"escape,b") if the second byte arrives within 30ms of the first.

Since we made builtin bind match key events instead of raw byte sequences,
we have another place where we do similar disambiguation: when we read keys
such as alt-left ("\e[1;3D"), we only consider bytes to be part of this
sequence if stdin is immediately readable (actually "readable after a 1ms
timeout" since e1be842 (Work around torn byte sequences in qemu kbd input
with 1ms timeout, 2025-03-04)).

This is technically wrong but has worked in practice (for Kakoune etc.).

Issue #11668 reports two issues on some Windows terminals feeding a remote
fish shell:
- the "bracketed paste finished" sequence may be split into multiple packets,
  which causes a delay of > 1ms between individual bytes being readable.
- AutoHotKey scripts simulating seven "left" keys result in sequence tearing
  as well.

Try to fix the paste case by increasing the timeout when parsing escape
sequences.

Also increase the timeout for terminals that support the kitty keyboard
protocol.  The user should only notice this new delay after pressing one of
escape,O, escape,P, escape,[, or escape,] **while the kitty keyboard protocol
is disabled** (e.g. while an external command is running).  In this case,
the fish_escape_delay_ms is also virtually increased; hopefully this edge
case is not ever relevant.

Part of #11668
2025-07-25 18:28:21 +02:00
Johannes Altmanninger
6666c8f1cd Block interrupts and uvar events while decoding key
readb() has only one caller that passes blocking=false: try_readb().
This function is used while decoding keys; anything but a successful read
is treated as "end of input sequence".

This means that key input sequences such as \e[1;3D
can be torn apart by
- signals (EINTR) which is more likely since e1be842 (Work around torn byte
  sequences in qemu kbd input with 1ms timeout, 2025-03-04).
- universal variable notifications (from other fish processes)

Fix this by blocking signals and not listening on the uvar fd.  We do something
similar when matching key sequences against bindings, so extract a function
and use it for key decoding too.

Ref: https://github.com/fish-shell/fish-shell/issues/11668#issuecomment-3101341081
(cherry picked from commit da96172739)
2025-07-25 18:21:27 +02:00
Johannes Altmanninger
3e61036911 Revert "Change readch() into try_readch()"
try_readch() was added to help a fuzzing harness, specifically to avoid a
call to `unreachable!()` in the NothingToRead case.  I don't know much about
that but it seems like we should find a better way to tell the fuzzer that
this can't happen.

Fortunately the next commit will get rid of readb()'s "blocking" argument,
along the NothingToRead enum variant. So we'll no longer need this.

This reverts commit b92830cb17.

(cherry picked from commit fb7ee0db74)
2025-07-25 18:21:27 +02:00
Johannes Altmanninger
f23a479b81 Reduce MaybeUninit lifetime
(cherry picked from commit 137f220225)
2025-07-25 18:21:27 +02:00
王宇逸
e274ff41d0 Use uninit instead of zeroed (src/input_common.rs)
(cherry picked from commit 7c2c7f5874)
2025-07-25 18:21:27 +02:00
Johannes Altmanninger
d2af306f3d Fix some unused-ControlFlow warnings 2025-07-25 18:11:04 +02:00
Johannes Altmanninger
da96172739 Block interrupts and uvar events while decoding key
readb() has only one caller that passes blocking=false: try_readb().
This function is used while decoding keys; anything but a successful read
is treated as "end of input sequence".

This means that key input sequences such as \e[1;3D
can be torn apart by
- signals (EINTR) which is more likely since e1be842 (Work around torn byte
  sequences in qemu kbd input with 1ms timeout, 2025-03-04).
- universal variable notifications (from other fish processes)

Fix this by blocking signals and not listening on the uvar fd.  We do something
similar when matching key sequences against bindings, so extract a function
and use it for key decoding too.

Ref: https://github.com/fish-shell/fish-shell/issues/11668#issuecomment-3101341081
2025-07-25 17:56:49 +02:00
Johannes Altmanninger
fb7ee0db74 Revert "Change readch() into try_readch()"
try_readch() was added to help a fuzzing harness, specifically to avoid a
call to `unreachable!()` in the NothingToRead case.  I don't know much about
that but it seems like we should find a better way to tell the fuzzer that
this can't happen.

Fortunately the next commit will get rid of readb()'s "blocking" argument,
along the NothingToRead enum variant. So we'll no longer need this.

This reverts commit b92830cb17.
2025-07-25 17:56:49 +02:00
Johannes Altmanninger
137f220225 Reduce MaybeUninit lifetime 2025-07-25 17:56:49 +02:00
Johannes Altmanninger
f8b9fa19e8 Merge pull request #11681 2025-07-25 17:56:39 +02:00
A2uria
4508b5b0db Handle cygwin select() returning -1 with errno 0 2025-07-25 22:45:01 +08:00
A2uria
d8e5821a3b Use \n as end of line on windows 2025-07-25 18:44:42 +08:00
A2uria
4162e0efad Fix path_remoteness on cygwin 2025-07-25 18:41:40 +08:00
Johannes Altmanninger
0e7c7f1745 Remove unused import
(cherry picked from commit 07ff4e7df0)
2025-07-25 11:57:21 +02:00
Johannes Altmanninger
07ff4e7df0 Remove unused import 2025-07-25 11:55:10 +02:00
Johannes Altmanninger
3fada80553 Fix regression causing \e[ to be interpreted as ctrl-[
Fixes 3201cb9f01 (Stop parsing invalid CSI/SS3 sequences as alt-[/alt-o,
2024-12-30).

(cherry picked from commit 43d583d991)
2025-07-25 11:49:07 +02:00
Daniel Rainer
2c11bfa532 Avoid running sphinx-build if possible
Despite the caching in `sphinx-build`, it takes several seconds to run
`sphinx-build` when no rebuilding is necessary, which slows down build times
significantly.

Add custom logic to `build.rs` to avoid calling `sphinx-build` if deemed
unnecessary based on the mtime of the source files.
This is done by writing the most recent timestamp of the source files into a
dedicated file, and only calling `sphinx-build` (and updating the timestamp)
when a cached timestamp is older than the most recent source file mtime.
2025-07-23 18:37:07 +02:00
Daniel Rainer
eae633c4af Extract SPHINX_DOC_SOURCES and handle rebuilds
The sources for Sphinx documentation builds include `CHANGELOG.rst` and
`CONTRIBUTING.rst`. Use `SPHINX_DOC_SOURCES` to clarify this and avoid
repetition.

Rebuilds should happen for debug builds as well, since rebuilding is required
for updating the man files.
2025-07-23 18:28:54 +02:00
Daniel Rainer
ecc004a122 Rebuild if gettext-extraction changed 2025-07-23 18:28:54 +02:00
Johannes Altmanninger
c7d4acbef8 Update changelog 2025-06-29 16:01:44 +02:00
Johannes Altmanninger
e204a4c126 Add ctrl-alt-h compatibility binding
Historically, ctrl-i sends the same code as tab, ctrl-h sends backspace and
ctrl-j and ctrl-m behave like enter.

Even for terminals that send unambiguous encodings (via the kitty keyboard
protocol), we have kept bindings like ctrl-h, to support existing habits.

We forgot that pressing alt-ctrl-h would behave like alt-backspace (and can
be easier to reach) so maybe we should add that as well.

Don't add ctrl-shift-i because at least on Linux, that's usually intercepted
by the terminal emulator.

Technically there are some more such as "ctrl-2" (which used to do the same as
"ctrl-space") but I don't think anyone uses that over "ctrl-space".

Closes #https://github.com/fish-shell/fish-shell/discussions/11548

(cherry picked from commit 4d67ca7c58)
2025-06-28 14:20:03 +02:00
Johannes Altmanninger
9af33802ec Use statvfs on NetBSD again to fix build
From commit ba00d721f4 (Correct statvfs call to statfs, 2025-06-19):

> This was missed in the Rust port

To elaborate:

- ec176dc07e (Port path.h, 2023-04-09) didn't change this (as before,
 `statvfs` used `ST_LOCAL` and `statfs` used `MNT_LOCAL`)
- 6877773fdd (Fix build on NetBSD (#10270), 2024-01-28) changed the `statvfs`
  call to `statfs`, presumably due to the libc-wrapper for
  `statvfs` being missing on NetBSD.  This change happens
  to work fine on NetBSD because they do [`#define ST_LOCAL
  MNT_LOCAL`](https://github.com/fish-shell/fish-shell/pull/11486#discussion_r2092408952)
  But it was wrong on others like macOS and FreeBSD, which was fixed by
  ba00d721f4 (but that broke the build on NetBSD).
- 7228cb15bf (Include sys/statvfs.h for the definition of ST_LOCAL (Rust
  port regression), 2025-05-16)
  fixed a code clone left behind by the above commit (incorrectly assuming
  that the clone had always existed.)

Fix the NetBSD build specifically by using statfs on that platform.

Note that this still doesn't make the behavior equivalent to commit LastC++11.
That one used ST_LOCAL if defined, and otherwise MNT_LOCAL if defined.

If we want perfect equivalence, we could detect both flags in `src/build.rs`.
Then we would also build on operating systems that define neither. Not sure.

Closes #11596

(cherry picked from commit 6644cc9b0e)
2025-06-28 11:46:25 +02:00
王宇逸
eecf0814a1 Use uninit instead of zeroed (cherry-pikcked only the change to src/path.rs)
(cherry picked from commit 7c2c7f5874)
2025-06-28 11:46:25 +02:00
Johannes Altmanninger
1ceebdf580 Fix some CSI commands being sent to old midnight commander
Commit 97581ed20f (Do send bracketed paste inside midnight commander,
2024-10-12) accidentally started sending CSI commands such as "CSI >5;0m",
which we intentionally didn't do for some old versions of Midnight Commander,
which fail to parse them. Fix that.

Fixes #11617
2025-06-25 13:36:03 +02:00
Johannes Altmanninger
335f91babd completions/git: fix spurious error when no subcommand is in $PATH
Systems like NixOS might not have "git-receive-pack" or any other "git-*"
executable in in $PATH -- instead they patch git to use absolute paths.
This is weird. But no reason for us to fail. Silence the error.

Fixes #11590

(cherry picked from commit 4f46d369c4)
2025-06-24 11:59:57 +08:00
Johannes Altmanninger
ec66749369 __fish_complete_list: only unescape "$(commandline -t)"
Commit cd3da62d24 (fix(completion): unescape strings for __fish_complete_list,
2024-09-17) bravely addressed an issue that exists in a lot of completions.
It did so only for __fish_complete_list. Fair enough.

Unfortunately it unescaped more than just "$(commandline -t)".

This causes the problem described at
https://github.com/fish-shell/fish-shell/issues/11508#issuecomment-2889088934
where completion descriptions containing a backslash followed by "n" are
interpreted as newlines, breaking the completion parser.  Fix that.

(cherry picked from commit 60881f1195)
2025-06-21 18:58:33 +02:00
Johannes Altmanninger
6e9e33d81d __fish_complete_list: strip "--foo=" prefix from replacing completions
Given a command line like

	foo --foo=bar=baz=qux\=argument

(the behavior is the same if '=' is substituted with ':').

fish completes arguments starting from the last unescaped separator, i.e.

	foo --foo=bar=baz=qux\=argument
			 ^
__fish_complete_list provides completions like

	printf %s\n (commandline -t)(printf %s\n choice1 choice2 ...)

This means that completions include the "--foo=bar=baz=" prefix.

This is wrong. This wasn't a problem until commit f9febba (Fix replacing
completions with a -foo prefix, 2024-12-14), because prior to that, replacing
completions would replace the entire token.
This made it too hard to writ ecompletions like

	complete -c foo -s s -l long -xa "hello-world goodbye-friend"

that would work with "foo --long fri" as well as "foo --long=frie".
Replacing the entire token would only work if the completion included that
prefix, but the above command is supposed to just work.
So f9febba made us replace only the part after the separator.

Unfortunately that caused the earlier problem.  Work around this.  The change
is not pretty, but it's a compromise until we have a better way of telling
which character fish considers to be the separator.

Fixes #11508

(cherry picked from commit 320ebb6859)
2025-06-21 18:58:17 +02:00
Peter Ammon
f3ebc68d5d Correct statvfs call to statfs
This was missed in the Rust port - C++ had statfs for MNT_LOCAL and not statvfs.
The effect of this is that fish never thought its filesystem was local on macOS
or BSDs (Linux was OK). This caused history race tests to fail, and also could
in rare cases result in history items being dropped with multiple concurrent
sessions.

This fixes the history race tests under macOS and FreeBSD - we weren't locking
because we thought the history was a remote file.

Cherry-picked from ba00d721f4
2025-06-19 15:36:19 -07:00
Johannes Altmanninger
4be17bfefb fixup! Extract config path module. NFC
Fix cargo (non-cmake) build.
2025-06-13 12:17:10 +02:00
Johannes Altmanninger
6fd0025f38 Make LOCALEDIR relocatable as well
As explained in c3740b85be (config_paths: fix compiled-in locale dir,
2025-06-12), fish is "relocatable", i.e. "mv /usr/ /usr2/" will leave
"/usr2/bin/fish" fully functional.

There is one exception: for LOCALEDIR we always use the path determined at
compile time.
This seems wrong; let's use the same relocatable-logic as for other paths.

Inspired by bf65b9e3a7 (Change `gettext` paths to be relocatable (#11195),
2025-03-30).
2025-06-13 11:52:46 +02:00
Johannes Altmanninger
052fc18db9 Extract config path module. NFC
This is the "code movement" part of bf65b9e3 ("Change `gettext` paths to be
relocatable (#11195)").

While at it, fix some warnings.
2025-06-13 11:52:46 +02:00
Integral
63a08e53e5 Replace some PathBuf with Path avoid unnecessary heap allocation (#10929)
(cherry picked from commit b19a467ea6)
2025-06-11 11:38:53 +02:00
Erick Howard
62ac23453e Code cleanup in src/bin/fish.rs to make it more idiomatic (#10975)
Code cleanup in `src/bin/fish.rs` to make it more idiomatic

(cherry picked from commit 967c4b2272)
2025-06-11 11:31:05 +02:00
Johannes Altmanninger
c052beb4dd Fix build on Rust 1.70 2025-06-10 17:56:21 +02:00
Johannes Altmanninger
e0cabacdaa kitty keyboard protocol: fall back to base layout key
On terminals that do not implement the kitty keyboard protocol "ctrl-ц" on
a Russian keyboard layout generally sends the same byte as "ctrl-w". This
is because historically there was no standard way to encode "ctrl-ц",
and the "ц" letter happens to be in the same position as "w" on the PC-101
keyboard layout.

Users have gotten used to this, probably because many of them are switching
between a Russian (or Greek etc.) and an English layout.

Vim/Emacs allow opting in to this behavior by setting the "input method"
(which probably means "keyboard layout").

Match key events that have the base layout key set against bindings for
that key.

Closes #11520

---

Alternatively, we could add the relevant preset bindings (for "ctrl-ц" etc.)
but
1. this will be wrong if there is a disagreement on the placement of "ц" between two layouts
2. there are a lot of them
3. it won't work for user bindings (for better or worse)

(cherry picked from commit 7a79728df3)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
59b9f57802 fish_key_reader: unopinionated description for bind notation variants
As explained in the parent commit, "alt-+" is usually preferred over
"alt-shift-=" but both have their moments. We communicate this via a comment
saying "# recommended notation". This is not always true and not super helpful,
especially as we add a third variant for #11520 (physical key), which is
the recommended one for users who switch between English and Cyrillic layouts.

Only explain what each variant does. Based on this the user may figure out
which one to use.

(cherry picked from commit 4cbd1b83f1)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
65fc2b539c Fix some invalid assertions parsing keys
For example the terminal sending « CSI 55296 ; 5 u » would crash fish.

(cherry picked from commit c7391d1026)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
3f1add9e21 Sanitize some inputs in CSI parser
This was copied from C++ code but we have overflow checks, which
forces us to actually handle errors.

While at it, add some basic error logging.

Fixes #11092

(cherry picked from commit 4c28a7771e)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
68d2cafa6e input: remove unnecessary check in bracketed paste code path
When "self.paste_is_buffering()" is true, "parse_escape_sequence()" explicitly
returns "None" instead of "Some(Escape)".  This is irrelevant because this
return value is never read, as long as "self.paste_is_buffering()" remains
true until "parse_escape_sequence()" returns, because the caller will return
early in that case. Paste buffering only ends if we actually read a complete
escape sequence (for ending bracketed paste).

Remove this extra branch.

(cherry picked from commit e5fdd77b09)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
b9d9e7edc6 Match bindings with explicit shift first
The new key notation canonicalizes aggressively, e.g.  these two bindings
clash:

	bind ctrl-shift-a something
	bind shift-ctrl-a something else

This means that key events generally match at most one active binding that
uses the new syntax.

The exception -- two coexisting new-syntax binds that match the same key
event -- was added by commit 50a6e486a5 (Allow explicit shift modifier for
non-ASCII letters, fix capslock behavior, 2025-03-30):

	bind ctrl-A 'echo A'
	bind ctrl-shift-a 'echo shift-a'

The precedence was determined by definition order.
This doesn't seem very useful.

A following patch wants to resolve #11520 by matching "ctrl-ц" events against
"ctrl-w" bindings. It would be surprising if a "ctrl-w" binding shadowed a
"ctrl-ц" one based on something as subtle as definition order.  Additionally,
definition order semantics (which is an unintended cause of the implementation)
is not really obvious.  Reverse definition order would make more sense.

Remove the ambiguity by always giving precedence to bindings that use
explicit shift.

Unrelated to this, as established in 50a6e486a5, explicit shift is still
recommended for bicameral letters but not typically for others -- e.g. alt-+
is typically preferred over alt-shift-= because the former also works on a
German keyboard.

See #11520

(cherry picked from commit 08c8afcb12)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
6b17ec7dae Allow explicit shift modifier for non-ASCII letters, fix capslock behavior
We canonicalize "ctrl-shift-i" to "ctrl-I".
Both when deciphering this notation (as given to builtin bind),
and when receiving it as a key event ("\e[105;73;6u")

This has problems:

A. Our bind notation canonicalization only works for 26 English letters.
   For example, "ctrl-shift-ä" is not supported -- only "ctrl-Ä" is.
   We could try to fix that but this depends on the keyboard layout.
   For example "bind alt-shift-=" and "bind alt-+" are equivalent on a "us"
   layout but not on a "de" layout.
B. While capslock is on, the key event won't include a shifted key ("73" here).
   This is due a quirk in the kitty keyboard protocol[^1].  This means that
   fish_key_reader's canonicalization doesn't work (unless we call toupper()
   ourselves).

I think we want to support both notations.

It's recommended to match all of these (in this order) when pressing
"ctrl-shift-i".

	1. bind ctrl-shift-i do-something
	2. bind ctrl-shift-I do-something
	3. bind ctrl-I do-something
	4. bind ctrl-i do-something

Support 1 and 3 for now, allowing both bindings to coexist. No priorities
for now. This solves problem A, and -- if we take care to use the explicit
shift notation -- problem B.

For keys that are not affected by capslock, problem B does not apply.  In this
case, recommend the shifted notation ("alt-+" instead of "alt-shift-=")
since that seems more intuitive.
Though if we prioritized "alt-shift-=" over "alt-+" as per the recommendation,
that's an argument against the shifted key.

Example output for some key events:

	$ fish_key_reader -cV
	# decoded from: \e\[61:43\;4u
	bind alt-+ 'do something' # recommended notation
	bind alt-shift-= 'do something'
	# decoded from: \e\[61:43\;68u
	bind alt-+ 'do something' # recommended notation
	bind alt-shift-= 'do something'

	# decoded from: \e\[105:73\;6u
	bind ctrl-I 'do something'
	bind ctrl-shift-i 'do something' # recommended notation
	# decoded from: \e\[105\;70u
	bind ctrl-shift-i 'do something'

Due to the capslock quirk, the last one has only one matching representation
since there is no shifted key.  We could decide to match ctrl-shift-i events
(that don't have a shifted key) to ctrl-I bindings (for ASCII letters), as
before this patch. But that case is very rare, it should only happen when
capslock is on, so it's probably not even a breaking change.

The other way round is supported -- we do match ctrl-I events (typically
with shifted key) to ctrl-shift-i bindings (but only for ASCII letters).
This is mainly for backwards compatibility.

Also note that, bindings without other modifiers currently need to use the
shifted key (like "Ä", not "shift-ä"), since we still get a legacy encoding,
until we request "Report all keys as escape codes".

[^1]: <https://github.com/kovidgoyal/kitty/issues/8493>

(cherry picked from commit 50a6e486a5)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
08d796890a Stop accepting "bind shift-A"
This notation doesn't make sense, use either A or shift-a.  We accept it
for ASCII letters only -- things like "bind shift-!" or "bind shift-Ä"
do not work as of today, we don't tolerate extra shift modifiers yet.
So let's remove it for consistency.

Note that the next commit will allow the shift-A notation again, but it will
not match shift-a events.

(cherry picked from commit 7f25d865a9)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
4f98ef36f6 Extract KeyEvent type
The be used in the grandchild commit.

(cherry picked from commit 855a1f702e)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
a09c78491f Extract function for creating key event with modifiers
(cherry picked from commit fabbbba037)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
02932d6b8c Extract constant for the number of function keys
Switch to fish_wcstoul because we want the constant to be unsigned.
It's u32 because most callers of function_key() want that.

(cherry picked from commit e9d1cdfe87)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
7cca98bda2 Fix regression decoding function keys
Commit 109ef88831 (Add menu and printscreen keys, 2025-01-01)
accidentally broke an assumption by inverting f1..f12.  Fix that.

Fixes #11098

(cherry picked from commit d2b2c5286a)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
b77fc28692 Add menu and printscreen keys
These aren't typically used in the terminal but they are present on
many keyboards.

Also reorganize the named key constants a bit.  Between F500 and
ENCODE_DIRECT_BASE (F600) we have space for 256 named keys.

(cherry picked from commit 109ef88831)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
3475531ef7 Also ignore invalid recursive escape sequences
We parse "\e\e[x" as alt-modified "Invalid" key.  Due to this extra
modifier, we accidentally add it to the input queue, instead of
dropping this invalid key.

We don't really want to try to extract some valid keys from this
invalid sequence, see also the parent commit.

This allows us to remove misplaced validation that was added by
e8e91c97a6 (fish_key_reader: ignore sentinel key, 2024-04-02) but
later obsoleted by 66c6e89f98 (Don't add collateral sentinel key to
input queue, 2024-04-03).

(cherry picked from commit 84f19a931d)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
8222ed891b Stop parsing invalid CSI/SS3 sequences as alt-[/alt-o
This situation can be triggered in practice inside a terminal like tmux
3.5 by running

	tmux new-session fish -C 'sleep 2' -d reader -o log-file

and typing "alt-escape x"

The log shows that we drop treat this as alt-[ and drop  the x on the floor.

	reader: Read char alt-\[ -- Key { modifiers: Modifiers { ctrl: false,
	alt: true, shift: false }, codepoint: '[' } -- [27, 91, 120]

This input ("\e[x") is ambiguous.

It looks like it could mean "alt-[,x".  However that conflicts with a
potential future CSI code, so it makes no sense to try to support this.

Returning "None" from parse_csi() causes this weird behavior of
returning "alt-[" and dropping the rest of the parsed sequence.
This is too easy; it has even crept into a bunch of places
where the input sequence is actually valid like "VT200 button released"
but where we definitely don't want to report any key.

Fix the default: report no key for all unknown sequences and
intentionally-suppressed sequences.  Treat it at "alt-[" only when
there is no input byte available, which is more or less unambiguous,
hence a strong enough signal that this is a actually "alt-[".

(cherry picked from commit 3201cb9f01)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
f787e6858c Fix tests/checks/autoload.fish
Apparently this test runs with "build/tests" as CWD when run with cmake.
2025-06-10 16:50:00 +02:00
Fabian Boehm
a014166795 completions/nmcli: Complete at runtime
This used to get all the interfaces and ssids when the completions
were loaded. That's obviously wrong, given that ssids especially can, you know, change

(cherry picked from commit 9116c61736)

cherry-picking since this easy to trigger
(seen again in https://github.com/fish-shell/fish-shell/pull/11549)
2025-06-06 11:52:17 +02:00
Johannes Altmanninger
f7e639504a completions/git: improve idempotency in case of double load
As mentioned in the previous few commits and in #11535, running
"set fish_complete_path ..."  and "complete -C 'git ...'"  may result in
"share/completions/git.fish" being loaded multiple times.

This is usually fine because fish internally erases all cached completions
whenever fish_complete_path changes.

Unfortunately there is at least global variable that grows each time git.fish
is sourced. This doesn't make a functional difference but it does slow
down completions.  Fix that by resetting the variable at load time.

(cherry picked from commit 4b5650ee4f)
2025-05-29 18:01:22 +02:00
Johannes Altmanninger
028b60cad6 Fix "set fish_complete_path" accidentally disabling autoloading
Commit 5918bca1eb (Make "complete -e" prevent completion autoloading,
2024-08-24) makes "complete -e foo" add a tombstone for "foo", meaning we
will never again load completions for "foo".

Due to an oversight, the same tombstone is added when we clear cached
completions after changing "fish_complete_path", preventing completions from
being loaded in that case.  Fix this by restoring the old behavior unless
the user actually used "complete -e".

(cherry picked from commit a7c04890c9)
2025-05-29 18:01:04 +02:00
Johannes Altmanninger
b11e22d905 Fix uvar file mtime force-update (Rust port regression)
When two fish processes rewrite the uvar file concurrent, they rely on the
uvar file's mtime (queried after taking a lock, if locking is supported) to
tell us whether their view of the uvar file is still up-to-date.  If it is,
they proceed to move it into place atomically via rename().

Since the observable mtime only updates on every OS clock tick, we call
futimens() manually to force-update that, to make sure that -- unless both
fish conincide on the same *nanosecond* -- other fish will notice that the
file changed.

Unfortunately, commit 77aeb6a2a8 (Port execution, 2023-10-08) accidentally
made us call futimens() only if clock_gettime() failed, instead of when
it succeeded. This means that we need to wait for the next clock tick to
observe a change in mtime.
Any resulting false negatives might have caused us to drop universal variable updates.

Reported in https://github.com/fish-shell/fish-shell/pull/11492#discussion_r2098948362

See #10300

(cherry picked from commit 8617964d4d)
2025-05-23 08:50:17 +02:00
Johannes Altmanninger
33f8415785 Fixup history file EINTR loop to actually loop
Fixes d84e68dd4f (Retry history file flock() on EINTR, 2025-05-20).

(cherry picked from commit 3867163193)
2025-05-20 17:19:12 +02:00
Johannes Altmanninger
5ccd155177 Retry history file flock() on EINTR
When locking the uvar file, we retry whenever flock() fails with EINTR
(e.g. due to ctrl-c).

But not when locking the history file.  This seems wrong; all other libc
functions in the "history_file" code path do retry.

Fix that. In future we should extract a function.

Note that there are other inconsistencies; flock_uvar_file() does not
shy away from remote file systems and does not respect ABANDONED_LOCKING.
This means that empirically probably neither are necessary; let's make things
consistent in future.

See https://github.com/fish-shell/fish-shell/pull/11492#discussion_r2095096200
Might help #10300

(cherry picked from commit 4d84e68dd4)
2025-05-20 15:32:56 +02:00
Johannes Altmanninger
0f8d3a5174 Revert "Temporarily enable history_file debug category by default"
Commit f906a949cf (Temporarily enable history_file debug category by default,
2024-10-09) enabled the "history_file" debug category by default to gather
more data.

Judging from
https://github.com/fish-shell/fish-shell/issues/10300#issuecomment-2876718382
the logs didn't help, or were at least not visible when logging to stderr
(due to reboot).

Let's disable "history_file" logs again to remove potential
noise if the file system is read-only, disk is full etc., see
https://github.com/fish-shell/fish-shell/pull/11492#discussion_r2094781120

See #10300

(cherry picked from commit 285a810814)
2025-05-20 15:31:57 +02:00
Johannes Altmanninger
c4a26cb2b1 builtin status: remove spurious newline from current-command (Rust port regression)
WHen "status current-command" is called outside a function it always returns
"fish". An extra newline crept in, fix that.

Fixes 77aeb6a2a8 (Port execution, 2023-10-08).
Fixes #11503

(cherry picked from commit e26b585ce5)
2025-05-20 12:33:01 +02:00
Johannes Altmanninger
7228cb15bf Include sys/statvfs.h for the definition of ST_LOCAL (Rust port regression)
See https://man.netbsd.org/statvfs.5.
According to https://github.com/NetBSD/src/blob/trunk/sys/sys/statvfs.h#L135,
NetBSD has "#define ST_LOCAL MNT_LOCAL".  So this commit likely makes no
difference on existing systems.

While at it
- comment include statements
- remove a code clone

See #11486

(cherry picked from commit d68f8bdd3b)
2025-05-16 08:21:56 +02:00
Alan Somers
d5b46d6535 Fix remote filesystem detection on FreeBSD
Need an extra include to get the definition of MNT_LOCAL

Fixes #11483

(cherry picked from commit 7f4998ad9b)
2025-05-16 08:21:25 +02:00
Johannes Altmanninger
d4b4d44f14 Fix Vi mode glitch when replacing at last character
Another regression from d51f669647 (Vi mode: avoid placing cursor beyond last
character, 2024-02-14) "Unfortunately Vi mode sometimes needs to temporarily
select past end". So do the replace_one mode bindings which were forgotten.

Fix this.

This surfaces a tricky problem: when we use something like

	bind '' self-insert some-command

When key event "x" matches this generic binding, we insert both "self-insert"
and "some-command" at the front of the queue, and do *not* consume "x",
since the binding is empty.

Since there is a command (that might call "exit"), we insert a check-exit
event too, after "self-insert some-command" but _before_ "x".

The check-exit event makes "self-insert" do nothing. I don't think there's a
good reason for this; self-insert can only be triggered by a key event that
maps to self-insert; so there must always be a real key available for it to
consume. A "commandline -f self-insert" is a nop. Skip check-exit here.

Fixes #11484

(cherry picked from commit 107e4d11de)
2025-05-13 00:31:22 +02:00
Johannes Altmanninger
b8cfd6d12b Fix typo causing wrong cursor position after Vi mode paste
Regressed in d51f669647 (Vi mode: avoid placing cursor beyond last character,
2024-02-14).

(cherry picked from commit 50500ec5b9)
2025-05-13 00:31:09 +02:00
Johannes Altmanninger
6fb22a4fd1 Fix regression causing crash indenting commandline with "$()"
Commit b00899179f (Don't indent multi-line quoted strings; do indent inside
(), 2024-04-28) changed how we compute indents for string tokens with command
substitutions:

	echo "begin
	not indented
	end $(
	begin
	    indented
	end)"(
	begin
	    indented
	end
	)

For the leading quoted part of the string, we compute indentation only for
the first character (the opening quote), see 4c43819d32 (Fix crash indenting
quoted suffix after command substitution, 2024-09-28).

The command substitutions, we do indent as usual.

To implement the above, we need to separate quoted from non-quoted
parts. This logic crashes when indent_string_part() is wrongly passed
is_double_quoted=true.

This is because, given the string "$()"$(), parse_util_locate_cmdsub calls
quote_end() at index 4 (the second quote). This is wrong because that function
should only be called at opening quotes; this is a closing quote. The opening
quote is virtual here. Hack around this.

Fixes #11444

(cherry picked from commit 48704dc612)
2025-05-12 21:41:10 +02:00
Johannes Altmanninger
35849c57dc Explicit type for "$()" hack in parse_util_locate_cmdsub
(cherry picked from commit 8abab0e2cc)
2025-05-12 21:41:10 +02:00
Johannes Altmanninger
27504658ce Remove code clone in parse_util_locate_cmdsub
(cherry picked from commit bd178c8ba8)
2025-05-12 21:41:10 +02:00
Johannes Altmanninger
db323348c7 Set transient command line in custom completions (Rust port regression)
Commit df3b0bd89f (Fix commandline state for custom completions with variable
overrides, 2022-01-26) made us push a transient command line for custom
completions based on a tautological null-pointer check ("var_assignments").

Commit 77aeb6a2a8 (Port execution, 2023-10-08) turned the null pointer into
a reference and replaced the check with "!ad.var_assignments.is_empty()".
This broke scenarios that relied on the transient commandline.  In particular
the attached test cases rely on the transient commandline implicitly placing
the cursor at the end, irrespective of the cursor in the actual commandline.

I'm not sure if there is an easy way to identify these scenarios.

Let's restore historical behavior by always pushing the transient command line.

Fixes #11423

(cherry picked from commit 97641c7bf6)
2025-05-12 21:39:42 +02:00
Johannes Altmanninger
edb1b5f333 Share alt-{b,f} with Vi mode, to work around Terminal.app/Ghostty more
Commit f4503af037 (Make alt-{b,f} move in directory history if commandline is
empty, 2025-01-06) had the intentional side effect of making alt-{left,right}
(move in directory history) work in Terminal.app and Ghostty without other,
less reliable workarounds.
That commit says "that [workaround] alone should not be the reason for
this change."; maybe this was wrong.

Extend the workaround to Vi mode.  The intention here is to provide
alt-{left,right} in Vi mode.  This also adds alt-{b,f} which is odd but
mostly harmless (?) because those don't do anything else in Vi mode.
It might be confusing when studying "bind" output but that one already has
almost 400 lines for Vi mode.

Closes #11479

(cherry picked from commit 3081d0157b)
2025-05-12 21:35:47 +02:00
Daniel Rainer
2d8d377ddc Make printf unicode-aware
Specifically, the width and precision format specifiers are interpreted as
referring to the width of the grapheme clusters rather than the byte count of
the string. Note that grapheme clusters can differ in width.

If a precision is specified for a string, meaning its "maximum number of
characters", we consider this to limit the width displayed.
If there is a grapheme cluster whose width is greater than 1,
it might not be possible to get precisely the desired width.
In such cases, this last grapheme cluster is excluded from the output.

Note that the definitions used here are not consistent with the `string length`
builtin at the moment, but this has already been the case.

(cherry picked from commit 09eae92888)
2025-05-12 21:33:40 +02:00
Peter Ammon
057dd930b4 Changelog fix for #11354 2025-05-08 18:42:57 -07:00
Cuichen Li
25b944e3e6 Revert "Work around $PATH issues under WSL (#10506)"
This reverts commit 3374692b91.
2025-05-08 18:41:02 -07:00
1086 changed files with 345971 additions and 80284 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

@@ -1,8 +1,2 @@
# This file is _not_ included in the tarballs for now
# Binary builds on Linux packaging infrastructure need to overwrite it to make `cargo vendor` work
# Releases and development builds made using OBS/Launchpad will _not_ reflect the contents of this
# file
[resolver]
# Make cargo 1.84+ respect MSRV (rust-version in Cargo.toml)
incompatible-rust-versions = "fallback"
[alias]
xtask = "run --package xtask --"

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,34 +23,14 @@ 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 lang/rust misc/py-pexpect git-lite
- pkg update
- 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
- pkg install -y llvm
# BSDs have the following behavior: root may open or access files even if

View File

@@ -9,20 +9,26 @@ trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 100
[{Makefile,*.in}]
[{Makefile,{BSD,GNU}makefile}]
indent_style = tab
[*.{md,rst}]
trim_trailing_whitespace = false
max_line_length = unset
[*.sh]
indent_size = 4
[Dockerfile]
[build_tools/release.sh]
max_line_length = 72
[Vagrantfile]
indent_size = 2
[share/{completions,functions}/**.fish]
max_line_length = unset
[{COMMIT_EDITMSG,git-revise-todo}]
max_line_length = 80
[{COMMIT_EDITMSG,git-revise-todo,*.jjdescription}]
max_line_length = 72
[*.yml]
indent_size = 2

9
.gitattributes vendored
View File

@@ -1,7 +1,5 @@
# normalize newlines
* text=auto
*.fish text
*.bat eol=crlf
* text=auto eol=lf
# let git show off diff hunk headers, help git diff -L:
# https://git-scm.com/docs/gitattributes
@@ -16,15 +14,10 @@
.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
/.builds/* export-ignore
# to make cargo vendor work correctly
/.cargo/ export-ignore
/.cargo/config.toml export-ignore
# for linguist, which drives GitHub's language statistics
alpine.js linguist-vendored

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

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

View File

@@ -1,11 +1,8 @@
## Description
Talk about your changes here.
Fixes issue #
## TODOs:
<!-- Just check off what what we know been done so far. We can help you with this stuff. -->
<!-- Check off what what has been done so far. -->
- [ ] If addressing an issue, a commit message mentions `Fixes issue #<issue-number>`
- [ ] Changes to fish usage are reflected in user documentation/manpages.
- [ ] Tests have been added for regressions fixed
- [ ] User-visible changes noted in CHANGELOG.rst <!-- Don't document changes for completions inside CHANGELOG.rst, there are lot of such edits -->
- [ ] User-visible changes noted in CHANGELOG.rst <!-- Usually skipped for changes to completions -->

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

@@ -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.93 ;; # 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

@@ -1,14 +1,12 @@
name: Oldest Supported Rust Toolchain
on:
workflow_call:
inputs:
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
inputs:
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
@@ -16,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

@@ -1,14 +1,12 @@
name: Stable Rust Toolchain
on:
workflow_call:
inputs:
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
inputs:
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
@@ -16,7 +14,8 @@ permissions:
runs:
using: "composite"
steps:
- uses: dtolnay/rust-toolchain@1.88
- uses: ./.github/actions/rust-toolchain
with:
toolchain_channel: "stable"
targets: ${{ inputs.targets }}
components: ${{ inputs.components }}

View File

@@ -8,16 +8,12 @@ jobs:
label-and-milestone:
runs-on: ubuntu-latest
steps:
# - name: Checkout repository
# uses: actions/checkout@v2
- name: Set label and milestone
id: set-label-milestone
uses: actions/github-script@v7
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8, build_tools/update-dependencies.sh
with:
script: |
const completionsLabel = 'completions';
const completionsMilestone = 'fish next-3.x';
// Get changed files in the pull request
const prNumber = context.payload.pull_request.number;
@@ -41,26 +37,4 @@ jobs:
labels: [completionsLabel],
});
console.log(`PR ${prNumber} assigned label "${completionsLabel}"`);
// Get the list of milestones
const { data: milestones } = await github.rest.issues.listMilestones({
owner: context.repo.owner,
repo: context.repo.repo,
});
// Find the milestone id
const milestone = milestones.find(milestone => milestone.title === completionsMilestone);
if (milestone) {
// Set the milestone for the PR
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
milestone: milestone.number
});
console.log(`PR ${prNumber} assigned milestone "${completionsMilestone}"`);
} else {
console.error(`Milestone "${completionsMilestone}" not found`);
}
}

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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
-
name: Login to Container registry
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0, build_tools/update-dependencies.sh
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0, build_tools/update-dependencies.sh
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.NAMESPACE }}/${{ matrix.target }}
flavor: |
latest=true
-
name: Build and push
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0, build_tools/update-dependencies.sh
with:
context: docker/context
push: true
file: docker/${{ matrix.target }}.Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@@ -0,0 +1,32 @@
name: Linux development builds
on:
push:
branches:
- buildscript
jobs:
deploy:
runs-on: ubuntu-latest
environment: linux-development
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
- uses: astral-sh/setup-uv@v7
- name: Update package database
run: sudo apt-get update
- name: Install deps
run: sudo apt install debhelper devscripts dpkg-dev
- name: Create tarball and source packages
run: |
version=$(build_tools/git_version_gen.sh --stdout 2>/dev/null)
mkdir /tmp/gpg
echo "$SIGNING_GPG_KEY" > /tmp/gpg/signing-gpg-key
mkdir /tmp/fish-built
FISH_ARTEFACT_PATH=/tmp/fish-built ./build_tools/make_tarball.sh
FISH_ARTEFACT_PATH=/tmp/fish-built DEB_SIGN_KEYFILE=/tmp/gpg/signing-gpg-key ./build_tools/make_linux_packages.sh $version
- uses: actions/upload-artifact@v6
with:
name: linux-source-packages
path: |
/tmp/fish-built
! /tmp/fish-built/fish-*/* # don't include the unpacked source directory

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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
- uses: EmbarkStudios/cargo-deny-action@44db170f6a7d12a6e90340e9e0fca1f650d34b14 # v2.0.15, build_tools/update-dependencies.sh
with:
command: check licenses
arguments: --all-features --locked --exclude-dev
rust-version: 1.93 # updatecli.d/rust.yml

71
.github/workflows/lint.yml vendored Normal file
View File

@@ -0,0 +1,71 @@
name: Lint
on: [push, pull_request]
permissions:
contents: read
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
- uses: ./.github/actions/rust-toolchain@stable
with:
components: rustfmt
- name: install dependencies
run: pip install ruff
- name: build fish
run: cargo build --bin fish_indent
- name: check format
run: PATH="target/debug:$PATH" cargo xtask format --all --check
- name: check rustfmt
run: find build.rs crates src -type f -name '*.rs' | xargs rustfmt --check
clippy:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- rust_version: "stable"
features: ""
- rust_version: "stable"
features: "--no-default-features"
- rust_version: "msrv"
features: ""
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
- uses: ./.github/actions/rust-toolchain
with:
toolchain_channel: ${{ matrix.rust_version }}
components: clippy
- name: Update package database
run: sudo apt-get update
- name: Install deps
run: |
sudo apt install gettext
- name: Patch Cargo.toml to deny unknown lints
run: |
if [ "${{ matrix.rust_version }}" = stable ]; then
sed -i /^rust.unknown_lints/d Cargo.toml
fi
- name: cargo clippy
run: cargo clippy --workspace --all-targets ${{ matrix.features }} -- --deny=warnings
rustdoc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
- uses: ./.github/actions/rust-toolchain@stable
- name: Update package database
run: sudo apt-get update
- name: Install deps
run: |
sudo apt install gettext
- name: cargo doc
run: |
RUSTDOCFLAGS='-D warnings' cargo doc --workspace
- name: cargo doctest
run: |
cargo test --doc --workspace

View File

@@ -12,12 +12,13 @@ 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
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v4
- uses: dessant/lock-threads@f5f995c727ac99a91dec92781a8e34e7c839a65e # v6.0.0, build_tools/update-dependencies.sh
with:
github-token: ${{ github.token }}
issue-inactive-days: '365'

View File

@@ -1,42 +0,0 @@
name: macOS build and codesign
on:
workflow_dispatch: # Enables manual trigger from GitHub UI
jobs:
build-and-code-sign:
runs-on: macos-latest
environment: macos-codesign
steps:
- uses: actions/checkout@v4
- 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
- name: build-and-codesign
run: |
cargo install apple-codesign
mkdir -p "$FISH_ARTEFACT_PATH"
echo "$MAC_CODESIGN_APP_P12_BASE64" | base64 --decode > /tmp/app.p12
echo "$MAC_CODESIGN_INSTALLER_P12_BASE64" | base64 --decode > /tmp/installer.p12
echo "$MACOS_NOTARIZE_JSON" > /tmp/notarize.json
./build_tools/make_pkg.sh -s -f /tmp/app.p12 -i /tmp/installer.p12 -p "$MAC_CODESIGN_PASSWORD" -n -j /tmp/notarize.json
rm /tmp/installer.p12 /tmp/app.p12 /tmp/notarize.json
env:
MAC_CODESIGN_APP_P12_BASE64: ${{ secrets.MAC_CODESIGN_APP_P12_BASE64 }}
MAC_CODESIGN_INSTALLER_P12_BASE64: ${{ secrets.MAC_CODESIGN_INSTALLER_P12_BASE64 }}
MAC_CODESIGN_PASSWORD: ${{ secrets.MAC_CODESIGN_PASSWORD }}
MACOS_NOTARIZE_JSON: ${{ secrets.MACOS_NOTARIZE_JSON }}
# 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.
CARGO_NET_GIT_FETCH_WITH_CLI: true
FISH_ARTEFACT_PATH: /tmp/fish-built
- uses: actions/upload-artifact@v4
with:
name: macOS Artefacts
path: /tmp/fish-built/*
if-no-files-found: error

196
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,196 @@
name: Create a new release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (tag name)'
required: true
type: string
permissions:
contents: write
jobs:
is-release-tag:
name: Pre-release checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
with:
# Workaround for https://github.com/actions/checkout/issues/882
ref: ${{ inputs.version }}
- name: Check if the pushed tag looks like a release
run: |
set -x
commit_subject=$(git log -1 --format=%s)
tag=$(git describe)
[ "$commit_subject" = "Release $tag" ]
source-tarball:
needs: [is-release-tag]
name: Create the source tarball
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tarball-name: ${{ steps.version.outputs.tarball-name }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
with:
# Workaround for https://github.com/actions/checkout/issues/882
ref: ${{ inputs.version }}
- name: Update package database
run: sudo apt-get update
- name: Install dependencies
run: sudo apt install cmake gettext ninja-build python3-pip
- uses: ./.github/actions/install-sphinx
- name: Create tarball
run: |
set -x
mkdir /tmp/fish-built
FISH_ARTEFACT_PATH=/tmp/fish-built ./build_tools/make_tarball.sh
relnotes=/tmp/fish-built/release-notes.md
# Need history since the last release (i.e. tag) for stats.
git fetch --tags
git fetch --unshallow
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 '^$'
sed -i 1,2d "$relnotes"
- name: Upload tarball artifact
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0, build_tools/update-dependencies.sh
with:
name: source-tarball
path: |
/tmp/fish-built/fish-${{ inputs.version }}.tar.xz
/tmp/fish-built/release-notes.md
if-no-files-found: error
packages-for-linux:
needs: [is-release-tag]
name: Build single-file fish for Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
with:
# Workaround for https://github.com/actions/checkout/issues/882
ref: ${{ inputs.version }}
- name: Install Rust Stable
uses: ./.github/actions/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-musl,aarch64-unknown-linux-musl
- name: Update package database
run: sudo apt-get update
- name: Install dependencies
run: sudo apt install crossbuild-essential-arm64 gettext musl-tools
- uses: ./.github/actions/install-sphinx
- name: Build statically-linked executables
run: |
set -x
cargo build --release --target x86_64-unknown-linux-musl --bin fish
CFLAGS="-D_FORTIFY_SOURCE=2" \
CC=aarch64-linux-gnu-gcc \
RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc -C link-arg=-lgcc -C link-arg=-D_FORTIFY_SOURCE=0" \
cargo build --release --target aarch64-unknown-linux-musl --bin fish
- name: Compress
run: |
set -x
for arch in x86_64 aarch64; do
tar -cazf fish-$(git describe)-linux-$arch.tar.xz \
-C target/$arch-unknown-linux-musl/release fish
done
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0, build_tools/update-dependencies.sh
with:
name: Static builds for Linux
path: fish-${{ inputs.version }}-linux-*.tar.xz
if-no-files-found: error
create-draft-release:
needs:
- is-release-tag
- source-tarball
- packages-for-linux
name: Create release draft
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
with:
# Workaround for https://github.com/actions/checkout/issues/882
ref: ${{ inputs.version }}
- name: Download all artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0, build_tools/update-dependencies.sh
with:
merge-multiple: true
path: /tmp/artifacts
- name: List artifacts
run: find /tmp/artifacts -type f
- name: Create draft release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0, build_tools/update-dependencies.sh
with:
tag_name: ${{ inputs.version }}
name: fish ${{ inputs.version }}
body_path: /tmp/artifacts/release-notes.md
draft: true
files: |
/tmp/artifacts/fish-${{ inputs.version }}.tar.xz
/tmp/artifacts/fish-${{ inputs.version }}-linux-*.tar.xz
packages-for-macos:
needs: [is-release-tag, create-draft-release]
name: Build packages for macOS
runs-on: macos-latest
environment: macos-codesign
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
with:
# Workaround for https://github.com/actions/checkout/issues/882
ref: ${{ inputs.version }}
- name: Install Rust
uses: ./.github/actions/rust-toolchain@stable
with:
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; }
[ -n "$MAC_CODESIGN_APP_P12_BASE64" ] || die "Missing MAC_CODESIGN_APP_P12_BASE64"
[ -n "$MAC_CODESIGN_INSTALLER_P12_BASE64" ] || die "Missing MAC_CODESIGN_INSTALLER_P12_BASE64"
[ -n "$MAC_CODESIGN_PASSWORD" ] || die "Missing MAC_CODESIGN_PASSWORD"
[ -n "$MACOS_NOTARIZE_JSON" ] || die "Missing MACOS_NOTARIZE_JSON"
set -x
export FISH_ARTEFACT_PATH=/tmp/fish-built
# 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.
export CARGO_NET_GIT_FETCH_WITH_CLI=true
cargo install apple-codesign
mkdir -p "$FISH_ARTEFACT_PATH"
echo "$MAC_CODESIGN_APP_P12_BASE64" | base64 --decode >/tmp/app.p12
echo "$MAC_CODESIGN_INSTALLER_P12_BASE64" | base64 --decode >/tmp/installer.p12
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 -- -c "-DWITH_DOCS=ON"
version=$(git describe)
[ -f "${FISH_ARTEFACT_PATH}/fish-$version.app.zip" ]
[ -f "${FISH_ARTEFACT_PATH}/fish-$version.pkg" ]
rm /tmp/installer.p12 /tmp/app.p12 /tmp/notarize.json
env:
MAC_CODESIGN_APP_P12_BASE64: ${{ secrets.MAC_CODESIGN_APP_P12_BASE64 }}
MAC_CODESIGN_INSTALLER_P12_BASE64: ${{ secrets.MAC_CODESIGN_INSTALLER_P12_BASE64 }}
MAC_CODESIGN_PASSWORD: ${{ secrets.MAC_CODESIGN_PASSWORD }}
MACOS_NOTARIZE_JSON: ${{ secrets.MACOS_NOTARIZE_JSON }}
- name: Add macOS packages to the release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
version=$(git describe)
gh release upload $version \
/tmp/fish-built/fish-$version.app.zip \
/tmp/fish-built/fish-$version.pkg

View File

@@ -1,55 +0,0 @@
name: Rust checks
on: [push, pull_request]
permissions:
contents: read
jobs:
rustfmt:
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
clippy-stable:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/rust-toolchain@stable
with:
components: clippy
- name: Install deps
run: |
sudo apt install gettext
- name: cargo clippy
run: cargo clippy --workspace --all-targets -- --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:
- uses: actions/checkout@v3
- uses: ./.github/actions/rust-toolchain@stable
- name: cargo doc
run: |
RUSTDOCFLAGS='-D warnings' cargo doc --workspace
- name: cargo doctest
run: |
cargo test --doc --workspace

View File

@@ -1,76 +0,0 @@
name: staticbuilds
on:
# release:
# types: [published]
# schedule:
# - cron: "14 13 * * *"
workflow_dispatch:
jobs:
staticbuilds-linux:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: ./.github/actions/rust-toolchain@oldest-supported
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Prepare
run: |
sudo apt install python3-sphinx
rustup target add x86_64-unknown-linux-musl
rustup target add aarch64-unknown-linux-musl
sudo apt install musl-tools crossbuild-essential-arm64 python3-pexpect tmux -y
- name: Build
run: |
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2" CMAKE_WITH_GETTEXT=0 CC=aarch64-linux-gnu-gcc RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc -C link-arg=-lgcc -C link-arg=-D_FORTIFY_SOURCE=0" cargo build --release --target aarch64-unknown-linux-musl --bin fish
cargo build --release --target x86_64-unknown-linux-musl
- name: Test
run: |
tests/test_driver.py target/x86_64-unknown-linux-musl/release/
- name: Compress
run: |
tar -cazf fish-static-x86_64-$(git describe).tar.xz -C target/x86_64-unknown-linux-musl/release/ fish
tar -cazf fish-static-aarch64-$(git describe).tar.xz -C target/aarch64-unknown-linux-musl/release/ fish
- uses: actions/upload-artifact@v4
with:
name: fish-static-linux
path: |
fish-*.tar.xz
retention-days: 14
staticbuilds-macos:
runs-on: macos-latest
permissions:
contents: read
steps:
- uses: ./.github/actions/rust-toolchain@oldest-supported
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Prepare
run: |
sudo pip3 install --break-system-packages sphinx
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
- name: Build
run: |
PCRE2_SYS_STATIC=1 cargo build --release --target aarch64-apple-darwin --bin fish
PCRE2_SYS_STATIC=1 cargo build --release --target x86_64-apple-darwin --bin fish
- name: Compress
run: |
tar -cazf fish-macos-aarch64.tar.xz -C target/aarch64-apple-darwin/release/ fish
tar -cazf fish-macos-x86_64.tar.xz -C target/x86_64-apple-darwin/release/ fish
- uses: actions/upload-artifact@v4
with:
name: fish-static-macos
path: |
fish-macos-*.tar.xz
retention-days: 14

View File

@@ -1,4 +1,4 @@
name: make fish_run_tests
name: Test
on: [push, pull_request]
@@ -11,16 +11,16 @@ permissions:
jobs:
ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
- 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
- name: cmake
run: |
@@ -37,23 +37,26 @@ jobs:
# Generate PO files. This should not result it a change in the repo if all translations are
# up to date.
# Ensure that fish is available as an executable.
PATH="$PWD/build:$PATH" build_tools/update_translations.fish --no-mo
PATH="$PWD/build:$PATH" build_tools/update_translations.fish
# Show diff output. Fail if there is any.
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 --no-mo` after changing source files.'; exit 1; }
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: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
- 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: Update package database
run: sudo apt-get update
- name: Install deps
run: |
sudo apt update
sudo apt install gettext python3-pexpect g++-multilib tmux
uses: ./.github/actions/install-dependencies
with:
include_pcre: false
include_sphinx: false
- name: Install g++-multilib
run: sudo apt install g++-multilib
- name: cmake
env:
CFLAGS: "-m32"
@@ -68,7 +71,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:
@@ -78,18 +80,22 @@ jobs:
#
RUSTFLAGS: "-Zsanitizer=address"
# RUSTFLAGS: "-Zsanitizer=memory -Zsanitizer-memory-track-origins"
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
# All -Z options require running nightly
- uses: dtolnay/rust-toolchain@nightly
with:
# ASAN uses `cargo build -Zbuild-std` which requires the rust-src component
# this is comma-separated
components: rust-src
- name: Update package database
run: sudo apt-get update
- 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:
@@ -118,58 +124,63 @@ 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.
CARGO_NET_GIT_FETCH_WITH_CLI: true
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
- uses: ./.github/actions/rust-toolchain@oldest-supported
- name: Install deps
run: |
# --break-system-packages because homebrew has now declared itself "externally managed".
# this is CI so we don't actually care.
sudo pip3 install --break-system-packages pexpect
brew install tmux
brew install gettext tmux
- uses: ./.github/actions/install-sphinx
- name: cmake
run: |
mkdir build && cd build
cmake -DWITH_GETTEXT=NO -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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
- uses: msys2/setup-msys2@4f806de0a5a7294ffabaff804b38a9b435a73bda # v2.30.0, build_tools/update-dependencies.sh
with:
update: true
msystem: MSYS
id: msys2
- name: Install deps
# Not using setup-msys2 `install` option to make it easier to copy/paste
run: |
pacman --noconfirm -S --needed git rust
- name: rebase
env:
MSYS2_LOCATION: ${{ steps.msys2.outputs.msys2-location }}
shell: cmd
run: |
"%MSYS2_LOCATION%\usr\bin\dash" /usr/bin/rebaseall -p -v
- 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

5
.gitignore vendored
View File

@@ -7,7 +7,6 @@
*.DS_Store
*.a
*.app
*.d
*.dll
*.dylib
*.exe
@@ -38,7 +37,6 @@ Desktop.ini
Thumbs.db
ehthumbs.db
*.mo
.directory
.fuse_hidden*
@@ -106,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,94 +1,563 @@
fish 4.1.0 (released ???)
fish ?.?.? (released ???)
=========================
.. ignore for 4.1: 10929 10940 10948 10955 10965 10975 10989 10990 10998 11028 11052 11055 11069 11071 11079 11092 11098 11104 11106 11110 11140 11146 11148 11150 11214 11218 11259 11288 11299 11328 11350 11373 11395 11417 11419
Notable improvements and fixes
------------------------------
- Compound commands (``begin; echo 1; echo 2; end``) can now be now be abbreviated using braces (``{ echo1; echo 2 }``), like in other shells.
- Fish now supports transient prompts: if :envvar:`fish_transient_prompt` is set to 1, fish will reexecute prompt functions with the ``--final-rendering`` argument before running a commandline (:issue:`11153`).
- When tab completion results are truncated, any common directory name is omitted. E.g. if you complete "share/functions", and it includes the files "foo.fish" and "bar.fish",
the completion pager will now show "…/foo.fish" and "…/bar.fish". This will make the candidates shorter and allow for more to be shown at once (:issue:`11250`).
- The self-installing configuration introduced in fish 4.0 has been changed.
Now fish built with embedded data will just read the data straight from its own binary or write it out when necessary, instead of requiring an installation step on start.
That means it is now possible to build fish as a single file and copy it to a compatible system, including as a different user, without extracting any files.
As before this is the default when building via `cargo`, and disabled when building via `cmake`, and for packagers we continue to recommend cmake.
Note: When fish is built like this, the `$__fish_data_dir` variable will be empty because that directory no longer has meaning. If you need to load files from there,
use `status get-file` or find alternatives (like loading completions for "foo" via `complete -C"foo "`).
We're considering making data embedding mandatory in future releases because it has a few advantages even for installation from a package (like making file conflicts with other packages impossible). (:issue:`11143`)
Deprecations and removed features
---------------------------------
- Tokens like ``{echo,echo}`` or ``{ echo, echo }`` in command position are no longer interpreted as brace expansion but as compound command.
- Terminfo-style key names (``bind -k``) are no longer supported. They had been superseded by the native notation since 4.0,
and currently they would map back to information from terminfo, which does not match what terminals would send with the kitty keyboard protocol (:issue:`11342`).
- fish no longer reads the terminfo database, so its behavior is no longer affected by the :envvar:`TERM` environment variable (:issue:`11344`).
For the time being, this can be turned off via the "ignore-terminfo" feature flag::
set -Ua fish_features no-ignore-terminfo
- The ``--install`` option when fish is built as self-installable was removed. If you need to write out fish's data you can use the new ``status list-files`` and ``status get-file`` subcommands, but it should no longer be necessary. (:issue:`11143`)
- RGB colors (``set_color ff0000``) now default to using 24-bit RGB true-color commands, even if $COLORTERM is unset, because that is often lost e.g. over ssh (:issue:`11372`)
- To go back to using the nearest match from the 256-color palette, use ``set fish_term24bit 0`` or set $COLORTERM to a value that is not "24bit" or "truecolor".
To make the nearest-match logic use the 16 color palette instead, use ``set fish_term256 0``.
- Inside macOS Terminal.app, fish makes an attempt to still use the palette colors.
If that doesn't work, use ``set fish_term24bit 0``.
- ``set_color --background=COLOR`` no longer implicitly activates bold mode.
To mitigate this change on existing installations that use a default theme, update your theme with ``fish_config theme choose`` or ``fish_config theme save``.
Scripting improvements
----------------------
Interactive improvements
------------------------
- Autosuggestions are now also provided in multi-line command lines. Like `ctrl-r`, autosuggestions operate only on the current line.
- Autosuggestions used to not suggest multi-line commandlines from history; now autosuggestions include individual lines from multi-line command lines.
- The history search now preserves ordering between :kbd:`ctrl-s` forward and :kbd:`ctrl-r` backward searches.
- Left mouse click (as requested by `click_events <terminal-compatibility.html#click-events>`__) can now select pager items (:issue:`10932`).
- Instead of flashing all the text to the left of the cursor, fish now flashes the matched token during history token search, the completed token during completion (:issue:`11050`), the autosuggestion when deleting it, and the full command line in all other cases.
- Pasted commands are now stripped of any ``$`` prefix.
- The :kbd:`alt-s` binding will now also use ``run0`` if available.
Improved terminal support
-------------------------
Other improvements
------------------
- History is no longer corrupted with NUL bytes when fish receives SIGTERM or SIGHUP (:issue:`10300`).
- ``fish_update_completions`` now handles groff ``\X'...'`` device control escapes, fixing completion generation for man pages produced by help2man 1.50 and later (such as coreutils 9.10).
For distributors and developers
-------------------------------
- When the default global config directory (``$PREFIX/etc/fish``) exists but has been overridden with ``-DCMAKE_INSTALL_SYSCONFDIR``, fish will now respect that override (:issue:`10748`).
Regression fixes:
-----------------
fish 4.6.0 (released March 28, 2026)
====================================
Notable improvements and fixes
------------------------------
- New Spanish translations (:issue:`12489`).
- New Japanese translations (:issue:`12499`).
Deprecations and removed features
---------------------------------
- The default width for emoji is switched from 1 to 2, improving the experience for users connecting to old systems from modern desktops. Users of old desktops who notice that lines containing emoji are misaligned can set ``$fish_emoji_width`` back to 1 (:issue:`12562`).
Interactive improvements
------------------------
- The tab completion pager now left-justifies the description of each column (:issue:`12546`).
- fish now supports the ``SHELL_PROMPT_PREFIX``, ``SHELL_PROMPT_SUFFIX``, and ``SHELL_WELCOME`` environment variables. The prefix and suffix are automatically prepended and appended to the left prompt, and the welcome message is displayed on startup after the greeting.
These variables are set by systemd's ``run0`` for example (:issue:`10924`).
Improved terminal support
-------------------------
- ``set_color`` is able to turn off italics, reverse mode, strikethrough and underline individually (e.g. ``--italics=off``).
- ``set_color`` learned the foreground (``--foreground`` or ``-f``) and reset (``--reset``) options.
- An error caused by slow terminal responses at macOS startup has been addressed (:issue:`12571`).
Other improvements
------------------
- Signals like ``SIGWINCH`` (as sent on terminal resize) no longer interrupt builtin output (:issue:`12496`).
- For compatibility with Bash, fish now accepts ``|&`` as alternate spelling of ``&|``, for piping both standard output and standard error (:issue:`11516`).
- ``fish_indent`` now preserves comments and newlines immediately preceding a brace block (``{ }``) (:issue:`12505`).
- A crash when suspending certain pipelines with :kbd:`ctrl-z` has been fixed (:issue:`12301`).
For distributors and developers
-------------------------------
- ``cargo xtask`` subcommands no longer panic on test failures.
Regression fixes:
-----------------
- (from 4.5.0) Intermediate ```` artifact when redrawing prompt (:issue:`12476`).
- (from 4.4.0) ``history`` honors explicitly specified ``--color=`` again (:issue:`12512`).
- (from 4.4.0) Vi mode ``dl`` and ``dh`` (:issue:`12461`).
- (from 4.3.0) Error completing of commands starting with ``-`` (:issue:`12522`).
fish 4.5.0 (released February 17, 2026)
=======================================
This is mostly a patch release for Vi mode regressions in 4.4.0 but other minor behavior changes are included as well.
Interactive improvements
------------------------
- :kbd:`ctrl-l` no longer cancels history search (:issue:`12436`).
- History search cursor positioning now works correctly with characters of arbitrary width.
Deprecations and removed features
---------------------------------
- fish no longer reads the terminfo database to alter behaviour based on the :envvar:`TERM` environment variable, and does not depend on ncurses or terminfo. The ``ignore-terminfo`` feature flag, introduced and enabled by default in fish 4.1, is now permanently enabled. fish may no longer work correctly on Data General Dasher D220 and Wyse WY-350 terminals, but should continue to work on all known terminal emulators released in the 21st century.
Regression fixes:
-----------------
- (from 4.4.0) Vi mode ``d,f`` key binding did not work (:issue:`12417`).
- (from 4.4.0) Vi mode ``c,w`` key binding wrongly deleted trailing spaces (:issue:`12443`).
- (from 4.4.0) Vi mode crash on ``c,i,w`` after accepting autosuggestion (:issue:`12430`).
- (from 4.4.0) ``fish_vi_key_bindings`` called with a mode argument produced an error (:issue:`12413`).
- (from 4.0.0) Build on Illumos (:issue:`12410`).
fish 4.4.0 (released February 03, 2026)
=======================================
Deprecations and removed features
---------------------------------
- The default fossil prompt has been disabled (:issue:`12342`).
Interactive improvements
------------------------
- The ``bind`` builtin lists mappings from all modes if ``--mode`` is not provided (:issue:`12214`).
- Line-wise autosuggestions that don't start a command are no longer shown (739b82c34db, 58e7a50de8a).
- Builtin ``history`` now assumes that :envvar:`PAGER` supports ANSI color sequences.
- fish now clears the terminal's ``FLUSHO`` flag when acquiring control of the terminal, to fix an issue caused by pressing :kbd:`ctrl-o` on macOS (:issue:`12304`).
New or improved bindings
------------------------
- Vi mode word movements (``w``, ``W``, ``e``, and ``E``) are now largely in line with Vim. The only exception is that underscores are treated as word separators (:issue:`12269`).
- New special input functions to support these movements: ``forward-word-vi``, ``kill-word-vi``, ``forward-bigword-vi``, ``kill-bigword-vi``, ``forward-word-end``, ``backward-word-end``, ``forward-bigword-end``, ``backward-bigword-end``, ``kill-a-word``, ``kill-inner-word``, ``kill-a-bigword``, and ``kill-inner-bigword``.
- Vi mode key bindings now support counts for movement and deletion commands (e.g. `d3w` or `3l`), via a new operator mode (:issue:`2192`).
- New ``catppuccin-*`` color themes.
Improved terminal support
-------------------------
- ``set_color`` learned the strikethrough (``--strikethrough`` or ``-s``) modifier.
For distributors and developers
-------------------------------
- The CMake option ``WITH_GETTEXT`` has been renamed to ``WITH_MESSAGE_LOCALIZATION``, to reflect that it toggles localization independently of the backend used in the implementation.
- New ``cargo xtask`` commands can replace some CMake workflows.
Regression fixes:
-----------------
- (from 4.1.0) Crash when autosuggesting Unicode characters with nontrivial lowercase mapping (:issue:`12326`, 78f4541116e).
- (from 4.3.0) Glitch on ``read --prompt-str ""`` (:issue:`12296`).
fish 4.3.3 (released January 07, 2026)
======================================
This release fixes the following problems identified in fish 4.3.0:
- Selecting a completion could insert only part of the token (:issue:`12249`).
- Glitch with soft-wrapped autosuggestions and :doc:`fish_right_prompt <cmds/fish_right_prompt>` (:issue:`12255`).
- Spurious echo in tmux when typing a command really fast (:issue:`12261`).
- ``tomorrow`` theme always using the light variant (:issue:`12266`).
- ``fish_config theme choose`` sometimes not shadowing themes set by e.g. webconfig (:issue:`12278`).
- The sample prompts and themes are correctly installed (:issue:`12241`).
- Last line of command output could be hidden when missing newline (:issue:`12246`).
Other improvements include:
- The ``abbr``, ``bind``, ``complete``, ``functions``, ``history`` and ``type`` commands now support a ``--color`` option to control syntax highlighting in their output. Valid values are ``auto`` (default), ``always``, or ``never``.
- Existing file paths in redirection targets such as ``> file.txt`` are now highlighted using :envvar:`fish_color_valid_path`, indicating that ``file.txt`` will be clobbered (:issue:`12260`).
fish 4.3.2 (released December 30, 2025)
=======================================
This release fixes the following problems identified in 4.3.0:
- Pre-built macOS packages failed to start due to a ``Malformed Mach-O file`` error (:issue:`12224`).
- ``extra_functionsdir`` (usually ``vendor_functions.d``) and friends were not used (:issue:`12226`).
- Sample config file ``~/.config/fish/config.fish/`` and config directories ``~/.config/fish/conf.d/``, ``~/.config/fish/completions/`` and ``~/.config/fish/functions/`` were recreated on every startup instead of only the first time fish runs on a system (:issue:`12230`).
- Spurious echo of ``^[[I`` in some scenarios (:issue:`12232`).
- Infinite prompt redraw loop on some prompts (:issue:`12233`).
- The removal of pre-built HTML docs from tarballs revealed that cross compilation is broken because we use ``${CMAKE_BINARY_DIR}/fish_indent`` for building HTML docs.
As a workaround, the new CMake build option ``FISH_INDENT_FOR_BUILDING_DOCS`` can be set to the path of a runnable ``fish_indent`` binary.
fish 4.3.1 (released December 28, 2025)
=======================================
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 user-facing :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 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>`.
- 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:
- Many of our new Chinese translations were more confusing than helpful; they have been fixed or removed (:issue:`11833`).
Note that you can work around this type of issue by configuring fish's :doc:`message localization <cmds/_>`:
if your environment contains something like ``LANG=zh_CN.UTF-8``,
you can use ``set -g LC_MESSAGES en`` to use English messages inside fish.
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`).
- 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`).
fish 4.1.0 (released September 27, 2025)
========================================
Notable improvements and fixes
------------------------------
- Compound commands (``begin; echo 1; echo 2; end``) can now be written using braces (``{ echo1; echo 2 }``), like in other shells.
- fish now supports transient prompts: if :envvar:`fish_transient_prompt` is set to 1, fish will reexecute prompt functions with the ``--final-rendering`` argument before running a commandline (:issue:`11153`).
- Tab completion results are truncated up to the common directory path, instead of somewhere inside that path. E.g. if you complete "share/functions", and it includes the files "foo.fish" and "bar.fish",
the completion pager will now show "…/foo.fish" and "…/bar.fish" (:issue:`11250`).
- Self-installing builds as created by e.g. ``cargo install`` no longer install other files, see :ref:`below <changelog-4.1-embedded>`.
- Our gettext-based message-localization has been reworked,
adding translations to self-installing builds; see :ref:`below <changelog-4.1-gettext>`.
Deprecations and removed features
---------------------------------
- ``set_color --background=COLOR`` no longer implicitly activates bold mode.
If your theme is stored in universal variables (the historical default), some bold formatting might be lost.
To fix this, we suggest updating to the latest version of our theme, to explicitly activate bold mode,
for example use ``fish_config theme save "fish default"``.
- ``{echo,echo}`` or ``{ echo, echo }`` are no longer interpreted as brace expansion tokens but as :doc:`compound commands <cmds/begin>`.
- Terminfo-style key names (``bind -k nul``) are no longer supported. They had been superseded by fish's :doc:`own key names <cmds/bind>` since 4.0 (:issue:`11342`).
- fish no longer reads the terminfo database, so its behavior is generally no longer affected by the :envvar:`TERM` environment variable (:issue:`11344`).
For the time being, this change can be reversed via the ``ignore-terminfo`` :ref:`feature flag <featureflags>`.
To do so, run the following once and restart fish::
set -Ua fish_features no-ignore-terminfo
- The ``--install`` option when fish is built as self-installing is removed, see :ref:`below <changelog-4.1-embedded>`.
- ``set_color ff0000`` now outputs 24-bit RGB true-color even if :envvar:`COLORTERM` is unset.
One can override this by setting :envvar:`fish_term24bit` to 0 (:issue:`11372`).
- fish now requires the terminal to respond to queries for the :ref:`Primary Device Attribute <term-compat-primary-da>`.
For now, this can be reversed via a :ref:`feature flag <featureflags>`,
by running (once) ``set -Ua fish_features no-query-term`` and restarting fish.
- Users of GNU screen may experience :ref:`minor glitches <term-compat-dcs-gnu-screen>` when starting fish.
Scripting improvements
----------------------
- The :doc:`argparse <cmds/argparse>` builtin has seen many improvements, see :ref:`below <changelog-4.1-argparse>`.
- The :doc:`string pad <cmds/string-pad>` command now has a ``-C/--center`` option.
- The :doc:`psub <cmds/psub>` command now allows combining ``--suffix`` with ``--fifo`` (:issue:`11729`).
- The :doc:`read <cmds/read>` builtin has learned the ``--tokenize-raw`` option to tokenize without quote removal (:issue:`11084`).
Interactive improvements
------------------------
- Autosuggestions are now also provided in multi-line command lines. Like :kbd:`ctrl-r`, these operate only on the current line.
- Autosuggestions used to not suggest multi-line command-lines from history; now autosuggestions include individual lines from multi-line command-lines.
- The history pager search now preserves ordering between :kbd:`ctrl-s` forward and :kbd:`ctrl-r` backward searches.
- Instead of highlighting events by flashing *all text to the left of the cursor*,
failing history token search (:kbd:`alt-.`) flashes the associated token,
failing tab-completion flashes the to-be-completed token (:issue:`11050`),
deleting an autosuggestion (:kbd:`shift-delete`) flashes the suggestion,
and all other scenarios flash the full command line.
- Pasted commands are now stripped of any :code:`$\ ` command prefixes, to help pasting code snippets.
- Builtin help options (e.g. ``abbr --help``) now use ``man`` directly, meaning that variables like :envvar:`MANWIDTH` are respected (:issue:`11786`).
- ``funced`` will now edit copied functions directly, instead of the file where ``function --copy`` was invoked. (:issue:`11614`)
- Added a simple ``fish_jj_prompt`` which reduces visual noise in the prompt inside `Jujutsu <https://jj-vcs.github.io/jj/latest/>`__ repositories that are colocated with Git.
New or improved bindings
^^^^^^^^^^^^^^^^^^^^^^^^
- On non-macOS systems, :kbd:`alt-left`, :kbd:`alt-right`, :kbd:`alt-backspace`, :kbd:`alt-delete` no longer operate on punctuation-delimited words but on whole arguments, possibly including special characters like ``/`` and quoted spaces.
- On non-macOS systems, :kbd:`alt-left`, :kbd:`alt-right`, :kbd:`alt-backspace` and :kbd:`alt-delete` no longer operate on punctuation-delimited words but on whole arguments, possibly including special characters like ``/`` and quoted spaces.
On macOS, the corresponding :kbd:`ctrl-` prefixed keys operate on whole arguments.
Word operations are still available via the other respective modifier, same as in the browser.
Word operations are still available via the other respective modifier, just like in most web browsers.
- :kbd:`ctrl-z` (undo) after executing a command will restore the previous cursor position instead of placing the cursor at the end of the command line.
- The OSC 133 prompt marking feature has learned about kitty's ``click_events=1`` flag, which allows moving fish's cursor by clicking.
- :kbd:`ctrl-l` now pushes all text located above the prompt to the terminal's scrollback, before clearing and redrawing the screen (via a new special input function ``scrollback-push``).
For compatibility with terminals that do not provide the scroll-forward command,
this is only enabled by default if the terminal advertises support for the ``indn`` capability via XTGETTCAP.
- Bindings using shift with non-ASCII letters (such as :kbd:`ctrl-shift-ä`) are now supported.
If there is any modifier other than shift, this is the recommended notation (as opposed to :kbd:`ctrl-Ä`).
- The :kbd:`alt-s` binding will now also use ``run0`` if available.
- Some mouse support has been added: the OSC 133 prompt marking feature has learned about kitty's ``click_events=1`` flag, which allows moving fish's cursor by clicking in the command line,
and selecting pager items (:issue:`10932`).
- Before clearing the screen and redrawing, :kbd:`ctrl-l` now pushes all text located above the prompt to the terminal's scrollback,
via a new special input function :ref:`scrollback-push <special-input-functions-scrollback-push>`.
For compatibility with terminals that do not implement ECMA-48's :ref:`SCROLL UP <term-compat-indn>` command,
this function is only used if the terminal advertises support for that via :ref:`XTGETTCAP <term-compat-xtgettcap>`.
- Vi mode has learned :kbd:`ctrl-a` (increment) and :kbd:`ctrl-x` (decrement) (:issue:`11570`).
Completions
^^^^^^^^^^^
- ``git`` completions now show the remote url as a description when completing remotes.
- ``systemctl`` completions no longer print escape codes if ``SYSTEMD_COLORS`` is set (:issue:`11465`).
- ``git`` completions now show the remote URL as description when completing remotes.
- ``systemctl`` completions no longer print escape codes if ``SYSTEMD_COLORS`` happens to be set (:issue:`11465`).
- Added and improved many completion scripts, notably ``tmux``.
Improved terminal support
^^^^^^^^^^^^^^^^^^^^^^^^^
- Support for double, curly, dotted and dashed underlines in `fish_color_*` variables and :doc:`set_color <cmds/set_color>` (:issue:`10957`).
- Support for double, curly, dotted and dashed underlines, for use in ``fish_color_*`` variables and the :doc:`set_color builtin <cmds/set_color>` (:issue:`10957`).
- Underlines can now be colored independent of text (:issue:`7619`).
- New documentation page `Terminal Compatibility <terminal-compatibility.html>`_ (also accessible via ``man fish-terminal-compatibility``) lists required and optional terminal control sequences used by fish.
- New documentation page :doc:`Terminal Compatibility <terminal-compatibility>` (also accessible via ``man fish-terminal-compatibility``) lists the terminal control sequences used by fish.
Other improvements
------------------
- ``fish_indent`` and ``fish_key_reader`` are now available as builtins, and if fish is called with that name it will act like the given tool (as a multi-call binary).
This allows truly distributing fish as a single file. (:issue:`10876`)
- Updated Chinese and German translations.
- ``fish_indent --dump-parse-tree`` now emits simple metrics about the tree including its memory consumption.
- We added some tools to improve development workflows, for example ``build_tools/{check,update_translations,release}.sh`` and ``tests/test_driver.py``.
In conjunction with ``cargo``, these enable almost all day-to-day development tasks without using CMake.
For distributors
----------------
- ``fish_indent`` and ``fish_key_reader`` are still built as separate binaries for now, but can also be replaced with a symlink if you want to save disk space (:issue:`10876`).
- The CMake system was simplified and no longer second-guesses rustup. It will run rustc and cargo via $PATH or in ~/.cargo/bin/.
If that doesn't match your setup, set the Rust_COMPILER and Rust_CARGO cmake variables (:issue:`11328`).
- Cygwin support has been reintroduced, since rust gained a Cygwin target (https://github.com/rust-lang/rust/pull/134999, :issue:`11238`).
- Builtin commands that support the ``--help`` option now require the ``man`` program.
The direct dependency on ``mandoc`` and ``nroff`` has been removed.
- fish no longer uses gettext MO files, see :ref:`below <changelog-4.1-gettext>`.
If you have use cases which are incompatible with our new approach, please let us know.
- The :doc:`fish_indent <cmds/fish_indent>` and :doc:`fish_key_reader <cmds/fish_key_reader>` programs are now also available as builtins.
If fish is invoked via e.g. a symlink with one of these names,
it will act like the given tool (i.e. it's a multi-call binary).
This allows truly distributing fish as a single file (:issue:`10876`).
- The CMake build configuration has been simplified and no longer second-guesses rustup.
It will run rustc and cargo via :envvar:`PATH` or in ~/.cargo/bin/.
If that doesn't match your setup, set the Rust_COMPILER and Rust_CARGO CMake variables (:issue:`11328`).
- Cygwin support has been reintroduced, since `Rust gained a Cygwin target <https://github.com/rust-lang/rust/pull/134999>`__ (:issue:`11238`).
- CMake 3.15 is now required.
.. _changelog-4.1-embedded:
Changes to self-installing builds
---------------------------------
The self-installing build type introduced in fish 4.0 has been changed (:issue:`11143`).
Now fish built with embedded data will just read the data straight from its own binary or write it out to temporary files when necessary, instead of requiring an installation step on start.
That means it is now possible to build fish as a single file and copy it to any system with a compatible CPU architecture, including as a different user, without extracting any files.
As before, this is the default when building via ``cargo``, and disabled when building via CMake.
For packagers we continue to recommend CMake.
Note: When fish is built like this, the :envvar:`__fish_data_dir` variable will be empty because that directory no longer has meaning.
You should generally not need these files.
For example, if you want to make sure that completions for "foo" are loaded, use ``complete -C"foo " >/dev/null`` instead).
The raw files are still exposed via :ref:`status subcommands <status-get-file>`, mainly for fish's internal use, but you can also use them as a last resort.
Remaining benefits of a full installation (as currently done by CMake) are:
- man pages like ``fish(1)`` in standard locations, easily accessible from outside fish.
- a local copy of the HTML documentation, typically accessed via the :doc:`help <cmds/help>` function.
In builds with embedded data, ``help`` will redirect to e.g. `<https://fishshell.com/docs/current/>`__
- ``fish_indent`` and ``fish_key_reader`` as separate files, making them easily accessible outside fish
- an (empty) ``/etc/fish/config.fish`` as well as empty directories ``/etc/fish/{functions,completions,conf.d}``
- ``$PREFIX/share/pkgconfig/fish.pc``, which defines directories for configuration-snippets, like ``vendor_completions.d``
.. _changelog-4.1-gettext:
Changes to gettext localization
-------------------------------
We replaced several parts of the gettext functionality with custom implementations (:issue:`11726`).
Most notably, message extraction, which should now work reliably, and the runtime implementation, where we no longer dynamically link to gettext, but instead use our own implementation, whose behavior is similar to GNU gettext, with some :doc:`minor deviations <cmds/_>`.
Our implementation now fully respects fish variables, so locale variables do not have to be exported for fish localizations to work.
They still have to be exported to inform other programs about language preferences.
The :envvar:`LANGUAGE` environment variable is now treated as a path variable, meaning it is an implicitly colon-separated list.
While we no longer have any runtime dependency on gettext, we still need gettext tools for building, most notably ``msgfmt``.
When building without ``msgfmt`` available, localization will not work with the resulting executable.
Localization data is no longer sourced at runtime from MO files on the file system, but instead built into the executable.
This is always done, independently of the other data embedding, so all fish executables will have access to all message catalogs, regardless of the state of the file system.
Disabling our new ``localize-messages`` cargo feature will cause fish to be built without localization support.
CMake builds can continue to use the ``WITH_GETTEXT`` option, with the same semantics as the ``localize-messages`` feature.
The current implementation does not provide any configuration options for controlling which language catalogs are built into the executable (other than disabling them all).
As a workaround, you can delete files in the ``po`` directory before building to exclude unwanted languages.
.. _changelog-4.1-argparse:
Changes to the :doc:`argparse <cmds/argparse>` builtin
------------------------------------------------------
- ``argparse`` now saves recognised options, including option-arguments in :envvar:`argv_opts`, allowing them to be forwarded to other commands (:issue:`6466`).
- ``argparse`` options can now be marked to be deleted from :envvar:`argv_opts` (by adding a ``&`` at the end of the option spec, before a ``!`` if present). There is now also a corresponding ``-d`` / ``--delete`` option to ``fish_opt``.
- ``argparse --ignore-unknown`` now removes preceding known short options from groups containing unknown options (e.g. when parsing ``-abc``, if ``a`` is known but ``b`` is not, then :envvar:`argv` will contain ``-bc``).
- ``argparse`` now has an ``-u`` / ``--move-unknown`` option that works like ``--ignore-unknown`` but preserves unknown options in :envvar:`argv`.
- ``argparse`` now has an ``-S`` / ``--strict-longopts`` option that forbids abbreviating long options or passing them with a single dash (e.g. if there is a long option called ``foo``, ``--fo`` and ``--foo`` won't match it).
- ``argparse`` now has a ``-U`` / ``--unknown-arguments`` option to specify how to parse unknown option's arguments.
- ``argparse`` now allows specifying options that take multiple optional values by using ``=*`` in the option spec (:issue:`8432`).
In addition, ``fish_opt`` has been modified to support such options by using the ``--multiple-vals`` together with ``-o`` / ``--optional-val``; ``-m`` is also now acceptable as an abbreviation for ``--multiple-vals``.
- ``fish_opt`` no longer requires you give a short flag name when defining options, provided you give it a long flag name with more than one character.
- ``argparse`` option specifiers for long-only options can now start with ``/``, allowing the definition of long options with a single letter. Due to this change, the ``--long-only`` option to ``fish_opt`` is now no longer necessary and is deprecated.
- ``fish_opt`` now has a ``-v`` / ``--validate`` option you can use to give a fish script to validate values of the option.
--------------
fish 4.0.9 (released September 27, 2025)
========================================
This release fixes:
- a regression in 4.0.6 causing shifted keys to not be inserted on some terminals (:issue:`11813`).
- a regression in 4.0.6 causing the build to fail on systems where ``char`` is unsigned (:issue:`11804`).
- a regression in 4.0.0 causing a crash on an invalid :doc:`bg <cmds/bg>` invocation.
--------------
fish 4.0.8 (released September 18, 2025)
========================================
This release fixes a regression in 4.0.6 that caused user bindings to be shadowed by either fish's or a plugin's bindings (:issue:`11803`).
--------------
fish 4.0.6 (released September 12, 2025)
========================================
This release of fish fixes a number of issues identified in fish 4.0.2:
- fish now properly inherits $PATH under Windows WSL2 (:issue:`11354`).
- Remote filesystems are detected properly again on non-Linux systems.
- the :doc:`printf <cmds/printf>` builtin no longer miscalculates width of multi-byte characters (:issue:`11412`).
- For many years, fish has been "relocatable" -- it was possible to move the entire ``CMAKE_INSTALL_PREFIX`` and fish would use paths relative to its binary.
Only gettext locale paths were still determined purely at compile time, which has been fixed.
- the :doc:`commandline <cmds/commandline>` builtin failed to print the commandline set by a ``commandline -C`` invocation, which broke some completion scripts.
This has been corrected (:issue:`11423`).
- To work around terminals that fail to parse Operating System Command (OSC) sequences, a temporary feature flag has been added.
It allows you to disable prompt marking (OSC 133) by running (once) ``set -Ua fish_features no-mark-prompt`` and restarting fish (:issue:`11749`).
- The routines to save history and universal variables have seen some robustness improvements.
- builtin :doc:`status current-command <cmds/status>` no longer prints a trailing blank line.
- A crash displaying multi-line quoted command substitutions has been fixed (:issue:`11444`).
- Commands like ``set fish_complete_path ...`` accidentally disabled completion autoloading, which has been corrected.
- ``nmcli`` completions have been fixed to query network information dynamically instead of only when completing the first time.
- Git completions no longer print an error when no `git-foo` executable is in :envvar:`PATH`.
- Custom completions like ``complete foo -l long -xa ...`` that use the output of ``commandline -t``.
on a command-line like ``foo --long=`` have been invalidated by a change in 4.0; the completion scripts have been adjusted accordingly (:issue:`11508`).
- Some completions were misinterpreted, which caused garbage to be displayed in the completion list. This has been fixed.
- fish no longer interprets invalid control sequences from the terminal as if they were :kbd:`alt-[` or :kbd:`alt-o` key strokes.
- :doc:`bind <cmds/bind>` has been taught about the :kbd:`printscreen` and :kbd:`menu` keys.
- :kbd:`alt-delete` now deletes the word right of the cursor.
- :kbd:`ctrl-alt-h` erases the last word again (:issue:`11548`).
- :kbd:`alt-left` :kbd:`alt-right` were misinterpreted because they send unexpected sequences on some terminals; a workaround has been added. (:issue:`11479`).
- Key bindings like ``bind shift-A`` are no longer accepted; use ``bind shift-a`` or ``bind A``.
- Key bindings like ``bind shift-a`` take precedence over ``bind A`` when the key event included the shift modifier.
- Bindings using shift with non-ASCII letters (such as :kbd:`ctrl-shift-ä`) are now supported.
- Bindings with modifiers such as ``bind ctrl-w`` work again on non-Latin keyboard layouts such as a Russian one.
This is implemented by allowing key events such as :kbd:`ctrl-ц` to match bindings of the corresponding Latin key, using the kitty keyboard protocol's base layout key (:issue:`11520`).
- Vi mode: The cursor position after pasting via :kbd:`p` has been corrected.
- Vi mode: Trying to replace the last character via :kbd:`r` no longer replaces the last-but-one character (:issue:`11484`).
--------------
@@ -101,7 +570,7 @@ This release of fish fixes a number of issues identified in fish 4.0.1:
- The warning when the terminfo database can't be found has been downgraded to a log message. fish will act as if the terminal behaves like xterm-256color, which is correct for the vast majority of cases (:issue:`11277`, :issue:`11290`).
- Key combinations using the super (Windows/command) key can now (actually) be bound using the :kbd:`super-` prefix (:issue:`11217`). This was listed in the release notes for 4.0.1 but did not work correctly.
- :doc:`function <cmds/function>` is stricter about argument parsing, rather than allowing additional parameters to be silently ignored (:issue:`11295`).
- Using parentheses in the :doc:`test <cmds/test>` builtin works correctly, following a regression in 4.0.0 where they were not recognized (:issue:`11387`).
- Using parentheses in the :doc:`test <cmds/test>` builtin works correctly, following a regression in 4.0.0 where they were not recognized (:issue:`11387`).
- :kbd:`delete` in Vi mode when Num Lock is active will work correctly (:issue:`11303`).
- Abbreviations cannot alter the command-line contents, preventing a crash (:issue:`11324`).
- Improvements to various completions, including new completions for ``wl-randr`` (:issue:`11301`), performance improvements for ``cargo`` completions by avoiding network requests (:issue:`11347`), and other improvements for ``btrfs`` (:issue:`11320`), ``cryptsetup`` (:issue:`11315`), ``git`` (:issue:`11319`, :issue:`11322`, :issue:`11323`), ``jj`` (:issue:`11046`), and ``systemd-analyze`` (:issue:`11314`).
@@ -151,7 +620,7 @@ Notable backwards-incompatible changes
- As part of a larger binding rework, ``bind`` gained a new key notation.
In most cases the old notation should keep working, but in rare cases you may have to change a ``bind`` invocation to use the new notation.
See :ref:`below <changelog-new-bindings>` for details.
See :ref:`below <changelog-4.0-new-bindings>` for details.
- :kbd:`ctrl-c` now calls a new bind function called ``clear-commandline``. The old behavior, which leaves a "^C" marker, is available as ``cancel-commandline`` (:issue:`10935`)
- ``random`` will produce different values from previous versions of fish when used with the same seed, and will work more sensibly with small seed numbers.
The seed was never guaranteed to give the same result across systems,
@@ -173,7 +642,7 @@ Notable backwards-incompatible changes
Notable improvements and fixes
------------------------------
.. _changelog-new-bindings:
.. _changelog-4.0-new-bindings:
- fish now requests XTerm's ``modifyOtherKeys`` keyboard encoding and `kitty keyboard protocol's <https://sw.kovidgoyal.net/kitty/keyboard-protocol/>`_ progressive enhancements (:issue:`10359`).
Depending on terminal support, this allows to binding more key combinations, including arbitrary combinations of modifiers :kbd:`ctrl`, :kbd:`alt` and :kbd:`shift`, and distinguishing (for example) :kbd:`ctrl-i` from :kbd:`tab`.
@@ -304,7 +773,7 @@ Interactive improvements
New or improved bindings
^^^^^^^^^^^^^^^^^^^^^^^^
- When the cursor is on a command that resolves to an executable script, :kbd:`alt-o` will now open that script in your editor (:issue:`10266`).
- During up-arrow history search, :kbd:`shift-delete` will delete the current search item and move to the next older item. Previously this was only supported in the history pager.
- During up-arrow history search, :kbd:`shift-delete` will delete the current search item and move to the next older item. Previously this was only supported in the history pager.
- :kbd:`shift-delete` will also remove the currently-displayed autosuggestion from history, and remove it as a suggestion.
- :kbd:`ctrl-Z` (also known as :kbd:`ctrl-shift-z`) is now bound to redo.
- Some improvements to the :kbd:`alt-e` binding which edits the command line in an external editor:
@@ -316,7 +785,7 @@ New or improved bindings
- Bindings like :kbd:`alt-l` that print output in between prompts now work correctly with multiline commandlines.
- :kbd:`alt-d` on an empty command line lists the directory history again. This restores the behavior of version 2.1.
- ``history-prefix-search-backward`` and ``-forward`` now maintain the cursor position, instead of moving the cursor to the end of the command line (:issue:`10430`).
- The following keys have refined behavior if the terminal supports :ref:`the new keyboard encodings <changelog-new-bindings>`:
- The following keys have refined behavior if the terminal supports :ref:`the new keyboard encodings <changelog-4.0-new-bindings>`:
- :kbd:`shift-enter` now inserts a newline instead of executing the command line.
- :kbd:`ctrl-backspace` now deletes the last word instead of only one character (:issue:`10741`).
@@ -375,7 +844,7 @@ Improved terminal support
Other improvements
------------------
- ``status`` gained a ``buildinfo`` subcommand, to print information on how fish was built, to help with debugging (:issue:`10896`).
- ``status`` gained a ``build-info`` subcommand, to print information on how fish was built, to help with debugging (:issue:`10896`).
- ``fish_indent`` will now collapse multiple empty lines into one (:issue:`10325`).
- ``fish_indent`` now preserves the modification time of files if there were no changes (:issue:`10624`).
- Performance in launching external processes has been improved for many cases (:issue:`10869`).
@@ -690,7 +1159,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
@@ -1115,7 +1584,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

@@ -15,8 +15,6 @@ endif()
# Set up standard directories.
include(GNUInstallDirs)
include(cmake/gettext.cmake)
# Set up PCRE2
# This sets an environment variable that needs to be available before the Rust stanzas
include(cmake/PCRE2.cmake)
@@ -26,9 +24,26 @@ include(cmake/Rust.cmake)
# Work around issue where archive-built libs go in the wrong place.
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
# Set up the machinery around FISH-BUILD-VERSION-FILE
# This defines the FBVF variable.
include(Version)
find_program(SPHINX_EXECUTABLE NAMES sphinx-build
HINTS
$ENV{SPHINX_DIR}
PATH_SUFFIXES bin
DOC "Sphinx documentation generator")
# 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)
@@ -38,40 +53,43 @@ add_definitions(-DCMAKE_SOURCE_DIR="${REAL_CMAKE_SOURCE_DIR}")
set(build_types Release RelWithDebInfo Debug "")
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")
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(
${target} ALL
add_custom_target(
fish 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
${CARGO_FLAGS}
${FEATURES_ARG}
&&
"${CMAKE_COMMAND}" -E
copy "${rust_target_dir}/${rust_profile}/${target}" "${CMAKE_CURRENT_BINARY_DIR}"
"${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
)
endfunction(CREATE_TARGET)
)
# Define fish.
create_target(fish)
function(CREATE_LINK target)
add_custom_target(
${target} ALL
DEPENDS fish
COMMAND ln -f fish ${target}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
endfunction(CREATE_LINK)
# Define fish_indent.
create_target(fish_indent)
create_link(fish_indent)
# Define fish_key_reader.
create_target(fish_key_reader)
create_link(fish_key_reader)
# Set up the docs.
include(cmake/Docs.cmake)

View File

@@ -11,13 +11,20 @@ Contributions are welcome, and there are many ways to contribute!
Whether you want to change some of the core Rust source, enhance or add a completion script or function,
improve the documentation or translate something, this document will tell you how.
Getting Set Up
==============
Fish is developed on Github, at https://github.com/fish-shell/fish-shell.
Mailing List
============
Send patches to the public mailing list: mailto:~krobelus/fish-shell@lists.sr.ht.
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.
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
@@ -29,7 +36,7 @@ For that, you'll require:
- Rust - when in doubt, try rustup
- CMake
- PCRE2 (headers and libraries) - optional, this will be downloaded if missing
- gettext (headers and libraries) - optional, for translation support
- gettext (only the msgfmt tool) - optional, for translation support
- Sphinx - optional, to build the documentation
Of course not everything is required always - if you just want to contribute something to the documentation you'll just need Sphinx,
@@ -43,7 +50,24 @@ Guidelines
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 (including ``make fish_run_tests`` and ``build_tools/style.fish``)
- Use automated tools to help you (``cargo xtask check``)
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
========================
@@ -64,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.
@@ -81,45 +105,40 @@ Contributing documentation
==========================
The documentation is stored in ``doc_src/``, and written in ReStructured Text and built with Sphinx.
The builtins and various functions shipped with fish are documented in ``doc_src/cmds/``.
To build it locally, run from the main fish-shell directory::
To build an HTML version of the docs locally, run::
sphinx-build -j 8 -b html -n doc_src/ /tmp/fish-doc/
cargo xtask html-docs
which will build the docs as html in /tmp/fish-doc. You can open it in a browser and see that it looks okay.
will output to ``target/fish-docs/html`` or, if you use CMake::
cmake --build build -t sphinx-docs
will output to ``build/cargo/fish-docs/html/``. You can also run ``sphinx-build`` directly, which allows choosing the output directory::
sphinx-build -j auto -b html doc_src/ /tmp/fish-doc/
will output HTML docs to ``/tmp/fish-doc``.
After building them, you can open the HTML docs in a browser and see that it looks okay.
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 an xtask
::
build_tools/style.fish --all
That command will refuse to restyle any files if you have uncommitted
changes.
cargo xtask format --all
cargo xtask format somefile.rs some.fish
Fish Script Style Guide
-----------------------
@@ -171,10 +190,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
=======
@@ -183,111 +202,70 @@ 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
while read from _ to _; do
if [ "x$to" = "xrefs/heads/$protected_branch" ]; then
isprotected=1
fi
done
if [ "x$isprotected" = x1 ]; then
echo "Running tests before push to master"
make fish_run_tests
RESULT=$?
if [ $RESULT -ne 0 ]; then
echo "Tests failed for a push to master, we can't let you do that" >&2
exit 1
fi
fi
exit 0
This will check if the push is to the master branch and, if it is, only
allow the push if running ``make fish_run_tests`` 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.
Coverity Scan
-------------
We use Coveritys static analysis tool which offers free access to open
source projects. While access to the tool itself is restricted,
fish-shell organization members should know that they can login
`here <https://scan.coverity.com/projects/fish-shell-fish-shell?tab=overview>`__
with their GitHub account. Currently, tests are triggered upon merging
the ``master`` branch into ``coverity_scan_master``. Even if you are not
a fish developer, you can keep an eye on our statistics there.
cargo xtask check
Contributing Translations
=========================
Fish uses the GNU gettext library to translate messages from English to
other languages.
Fish uses GNU gettext to translate messages from English to other languages.
We use custom tools for extracting messages from source files and to localize at runtime.
This means that we do not have a runtime dependency on the gettext library.
It also means that some features are not supported, such as message context and plurals.
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 ``LANG.po``, where ``LANG`` is the
two letter ISO 639-1 language code of the target language (e.g. ``de`` for
German). A region specifier can also be used (e.g. ``pt_BR`` for Brazilian Portuguese).
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.
These are the files you will interact with when adding translations.
Adding translations for a new language
--------------------------------------
@@ -297,21 +275,36 @@ More specifically, you will need ``msguniq`` and ``msgmerge`` for creating trans
language.
To create a new translation, run::
build_tools/update_translations.fish po/LANG.po
build_tools/update_translations.fish localization/po/ll_CC.po
By default, this also creates ``mo`` files, which contain the information from the ``po`` files in a
binary format.
Fish uses these files for translating at runtime.
They are not tracked in version control, but they can help translators check if their translations
show up correctly.
If you build fish locally (``cargo build``), and then run the resulting binary,
it will make use of the ``mo`` files generated by the script.
Use the ``LANG`` environment variable to tell fish which language to use, e.g.::
This will create a new PO file containing all messages available for translation.
If the file already exists, it will be updated.
LANG=pt_BR.utf8 target/debug/fish
After modifying a PO file, you can recompile fish, and it will integrate the modifications you made.
This requires that the ``msgfmt`` utility is installed (comes as part of ``gettext``).
It is important that the ``localize-messages`` cargo feature is enabled, which it is by default.
You can explicitly enable it using::
If you do not care about the ``mo`` files you can pass the ``--no-mo`` flag to the
``update_translations.fish`` script.
cargo build --features=localize-messages
Use environment variables to tell fish which language to use, e.g.::
LANG=pt_BR.utf8 fish
or within the running fish shell::
set LANG pt_BR.utf8
For more options regarding how to choose languages, see
`the corresponding gettext documentation
<https://www.gnu.org/software/gettext/manual/html_node/Locale-Environment-Variables.html>`__.
One neat thing you can do is set a list of languages to check for translations in the order defined
using the ``LANGUAGE`` variable, e.g.::
set LANGUAGE pt_BR de_DE
to try to translate messages to Portuguese, if that fails try German, and if that fails too you will
see the English version defined in the source code.
Modifying existing translations
-------------------------------
@@ -319,13 +312,8 @@ Modifying existing translations
If you want to work on translations for a language which already has a corresponding ``po`` file, it
is sufficient to edit this file. No other changes are necessary.
To see your translations in action you can run::
build_tools/update_translations.fish --only-mo po/LANG.po
to update the binary ``mo`` used by fish. Check the information for adding new languages for a
description on how you can get fish to use these files.
Running this script requires a fish executable and the gettext ``msgfmt`` tool.
After recompiling fish, you should be able to see your translations in action. See the previous
section for details.
Editing PO files
----------------
@@ -333,20 +321,20 @@ 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"
msgstr ""
msgid "%s: No suitable job\n"
msgstr ""
The ``msgid`` here is the "name" of the string to translate, typically the English string to translate.
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.
@@ -359,9 +347,9 @@ 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 ``#~``).
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
@@ -373,7 +361,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.
@@ -382,20 +370,26 @@ that the following are **not** valid:
::
echo (_ hello)
_ "goodbye"
echo (_ hello)
_ "goodbye"
Above should be written like this instead:
::
echo (_ "hello")
echo (_ "goodbye")
echo (_ "hello")
echo (_ "goodbye")
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
==========

892
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +1,85 @@
[workspace]
resolver = "2"
members = ["printf", "gettext-extraction"]
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]
anstyle = "1.0.13"
assert_matches = "1.5.0"
bitflags = "2.5.0"
cc = "1.0.94"
cfg-if = "1.0.3"
clap = { version = "4.5.54", features = ["derive"] }
errno = "0.3.0"
fish-build-helper = { path = "crates/build-helper" }
fish-build-man-pages = { path = "crates/build-man-pages" }
fish-color = { path = "crates/color" }
fish-common = { path = "crates/common" }
fish-fallback = { path = "crates/fallback" }
fish-feature-flags = { path = "crates/feature-flags" }
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"] }
fish-tempfile = { path = "crates/tempfile" }
fish-util = { path = "crates/util" }
fish-wcstringutil = { path = "crates/wcstringutil" }
fish-widecharwidth = { path = "crates/widecharwidth" }
fish-widestring = { path = "crates/widestring" }
fish-wgetopt = { path = "crates/wgetopt" }
itertools = "0.14.0"
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.
lru = "0.16.2"
nix = { version = "0.31.1", default-features = false, features = [
"event",
"fs",
"inotify",
"hostname",
"resource",
"process",
"signal",
"term",
"user",
] }
num-traits = "0.2.19"
once_cell = "1.19.0"
pcre2 = { git = "https://github.com/fish-shell/rust-pcre2", tag = "0.2.9-utf32", default-features = false, features = [
"utf32",
] }
phf = { version = "0.13", default-features = false }
phf_codegen = "0.13"
portable-atomic = { version = "1", default-features = false, features = [
"fallback",
] }
proc-macro2 = "1.0"
rand = { version = "0.9.2", default-features = false, features = [
"small_rng",
"thread_rng",
] }
rsconf = "0.3.0"
rust-embed = { version = "8.11.0", features = [
"deterministic-timestamps",
"include-exclude",
"interpolate-folder-path",
] }
serial_test = { version = "3", default-features = false }
widestring = "1.2.0"
unicode-segmentation = "1.12.0"
unicode-width = "0.2.0"
unix_path = "1.0.1"
walkdir = "2.5.0"
xterm-color = "1.0.1"
[profile.release]
overflow-checks = true
@@ -18,62 +91,74 @@ debug = true
[package]
name = "fish"
version = "4.1.0-alpha0"
version = "4.6.0"
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]
pcre2 = { git = "https://github.com/fish-shell/rust-pcre2", tag = "0.2.9-utf32", default-features = false, features = [
"utf32",
] }
bitflags = "2.5.0"
errno = "0.3.0"
libc = "0.2"
# 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.
lru = "0.13.0"
nix = { version = "0.30.1", default-features = false, features = [
"event",
"inotify",
"resource",
"fs",
] }
num-traits = "0.2.19"
once_cell = "1.19.0"
fish-printf = { path = "./printf", features = ["widestring"] }
fish-gettext-extraction = { path = "./gettext-extraction" }
# 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"] }
widestring = "1.2.0"
# We need 0.9.0 specifically for some crash fixes.
terminfo = "0.9.0"
rust-embed = { version = "8.2.0", optional = true }
assert_matches.workspace = true
bitflags.workspace = true
cfg-if.workspace = true
errno.workspace = true
fish-build-helper.workspace = true
fish-build-man-pages = { workspace = true, optional = true }
fish-color.workspace = true
fish-common.workspace = true
fish-fallback.workspace = true
fish-feature-flags.workspace = true
fish-gettext = { workspace = true, optional = true }
fish-gettext-extraction = { workspace = true, optional = true }
fish-printf.workspace = true
fish-tempfile.workspace = true
fish-util.workspace = true
fish-wcstringutil.workspace = true
fish-wgetopt.workspace = true
fish-widecharwidth.workspace = true
fish-widestring.workspace = true
itertools.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
rand.workspace = true
xterm-color.workspace = true
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]
portable-atomic = { version = "1", default-features = false, features = [
"fallback",
portable-atomic.workspace = true
[target.'cfg(windows)'.dependencies]
rust-embed = { workspace = true, features = [
"deterministic-timestamps",
"debug-embed",
"include-exclude",
"interpolate-folder-path",
] }
[target.'cfg(not(windows))'.dependencies]
rust-embed = { workspace = true, features = [
"deterministic-timestamps",
"include-exclude",
"interpolate-folder-path",
] }
[dev-dependencies]
serial_test = { version = "3", default-features = false }
serial_test.workspace = true
[build-dependencies]
cc = "1.0.94"
rsconf = "0.2.2"
cc.workspace = true
fish-build-helper.workspace = true
fish-gettext-mo-file-parser.workspace = true
phf_codegen = { workspace = true, optional = true }
rsconf.workspace = true
[target.'cfg(windows)'.build-dependencies]
unix_path = "1.0.1"
unix_path.workspace = true
[lib]
crate-type = ["rlib"]
@@ -92,28 +177,56 @@ name = "fish_key_reader"
path = "src/bin/fish_key_reader.rs"
[features]
default = ["embed-data"]
default = ["embed-manpages", "localize-messages"]
benchmark = []
embed-data = ["dep:rust-embed"]
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: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 `cargo xtask check` and when calling
# `build_tools/update_translations.fish`, so there should not be a need to enable it manually.
gettext-extract = ["dep:fish-gettext-extraction"]
# The following features are auto-detected by the build-script and should not be enabled manually.
asan = []
tsan = []
[workspace.lints]
rust.non_camel_case_types = "allow"
rust.non_upper_case_globals = "allow"
rust.unknown_lints = "allow"
rust.unknown_lints = { level = "allow", priority = -1 }
rust.unstable_name_collisions = "allow"
clippy.manual_range_contains = "allow"
clippy.needless_return = "allow"
clippy.needless_lifetimes = "allow"
rustdoc.private_intra_doc_links = "allow"
[workspace.lints.clippy]
assigning_clones = "warn"
cloned_instead_of_copied = "warn"
explicit_into_iter_loop = "warn"
format_push_string = "warn"
implicit_clone = "warn"
len_without_is_empty = "allow" # we're not a library crate
let_and_return = "allow"
manual_assert = "warn"
manual_range_contains = "allow"
map_unwrap_or = "warn"
mut_mut = "warn"
needless_lifetimes = "allow"
new_without_default = "allow"
option_map_unit_fn = "allow"
ptr_offset_by_literal = "warn"
ref_option = "warn"
semicolon_if_nothing_returned = "warn"
stable_sort_primitive = "warn"
str_to_string = "warn"
unnecessary_semicolon = "warn"
unused_trait_names = "warn"
# We do not want to use the e?print(ln)?! macros.
# These lints flag their use.
# In the future, they might change to flag other methods of printing.
clippy.print_stdout = "deny"
clippy.print_stderr = "deny"
print_stdout = "deny"
print_stderr = "deny"
[lints]
workspace = true

View File

@@ -1,18 +0,0 @@
FROM centos:latest
# Build dependency
RUN yum update -y &&\
yum install -y epel-release &&\
yum install -y clang cmake3 gcc-c++ make &&\
yum clean all
# Test dependency
RUN yum install -y expect vim-common
ADD . /src
WORKDIR /src
# Build fish
RUN cmake3 . &&\
make &&\
make install

View File

@@ -7,7 +7,7 @@
CMAKE ?= cmake
GENERATOR ?= $(shell (which ninja > /dev/null 2> /dev/null && echo Ninja) || \
echo 'Unix Makefiles')
echo 'Unix Makefiles')
prefix ?= /usr/local
PREFIX ?= $(prefix)
@@ -34,7 +34,7 @@ all: .begin build/fish
.PHONY: .begin
.begin:
@which $(CMAKE) > /dev/null 2> /dev/null || \
(echo 'Please install CMake and then re-run the `make` command!' 1>&2 && false)
(echo 'Please install CMake and then re-run the `make` command!' 1>&2 && false)
.PHONY: build/fish
build/fish: build/$(BUILDFILE)

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
~~~~~~~~~~~~~~~~~~
@@ -66,7 +66,8 @@ Windows
for Linux with the instructions for the appropriate distribution
listed above under “Packages for Linux”, or from source with the
instructions below.
- fish (4.0 on and onwards) cannot be installed in Cygwin, due to a lack of Rust support.
- Fish can also be installed on all versions of Windows using
`Cygwin <https://cygwin.com/>`__ or `MSYS2 <https://github.com/Berrysoft/fish-msys2>`__.
Building from source
~~~~~~~~~~~~~~~~~~~~
@@ -89,19 +90,17 @@ 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``, ``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)
- The gettext library, if compiled with
translation support
The following optional features also have specific requirements:
- builtin commands that have the ``--help`` option or print usage
messages require ``nroff`` or ``mandoc`` for
display
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
@@ -113,24 +112,22 @@ 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), including cargo
- 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
- gettext (headers and libraries) - optional, for translation support
- gettext (only the msgfmt tool) - optional, for translation support
- an Internet connection, as other dependencies will be downloaded automatically
Sphinx is also optionally required to build the documentation from a
cloned git repository.
Additionally, running the full test suite requires Python 3, 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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -142,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 ..
@@ -160,40 +157,52 @@ 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_INDENT_FOR_BUILDING_DOCS - useful for cross-compilation.
Set this to the path to the ``fish_indent`` executable to use for building HTML docs.
By default, ``${CMAKE_BINARY_DIR}/fish_indent`` will be used.
If that's not runnable on the compile host,
you can build a native one with ``cargo build --bin fish_indent`` and set this to ``$PWD/target/debug/fish_indent``.
- 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 build with gettext support for translations.
- WITH_MESSAGE_LOCALIZATION=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 4.0.0 # to build from git with a specific version
cargo install --git https://github.com/fish-shell/fish-shell # to build the current development snapshot without cloning
uv run --no-managed-python \
cargo install --path .
This will place the 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) or translations.
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-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
--------------------------------

482
build.rs
View File

@@ -1,87 +1,51 @@
#![allow(clippy::uninlined_format_args)]
use rsconf::{LinkType, Target};
use std::env;
use std::error::Error;
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::path::{Path, PathBuf};
fn canonicalize<P: AsRef<Path>>(path: P) -> PathBuf {
std::fs::canonicalize(path).unwrap()
}
fn canonicalize_str<P: AsRef<Path>>(path: P) -> String {
canonicalize(path).to_str().unwrap().to_owned()
}
const MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR");
fn main() {
setup_paths();
// Add our default to enable tools that don't go through CMake, like "cargo test" and the
// language server.
let cargo_target_dir: PathBuf = option_env!("CARGO_TARGET_DIR")
.map(canonicalize)
.unwrap_or(canonicalize(MANIFEST_DIR).join("target"));
// FISH_BUILD_DIR is set by CMake, if we are using it.
rsconf::set_env_value(
"FISH_BUILD_DIR",
option_env!("FISH_BUILD_DIR").unwrap_or(cargo_target_dir.to_str().unwrap()),
"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.
fish_build_dir().canonicalize().unwrap().to_str().unwrap(),
);
// We need to canonicalize (i.e. realpath) the manifest dir because we want to be able to
// compare it directly as a string at runtime.
rsconf::set_env_value("CARGO_MANIFEST_DIR", &canonicalize_str(MANIFEST_DIR));
rsconf::set_env_value(
"CARGO_MANIFEST_DIR",
workspace_root().canonicalize().unwrap().to_str().unwrap(),
);
// 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);
rsconf::set_env_value("FISH_BUILD_VERSION", &get_version());
std::env::set_var("FISH_BUILD_VERSION", version);
fish_build_helper::rebuild_if_embedded_path_changed("share");
let targetman = cargo_target_dir.join("fish-man");
#[cfg(feature = "embed-data")]
#[cfg(not(clippy))]
{
build_man(&targetman);
}
#[cfg(any(not(feature = "embed-data"), clippy))]
{
let sec1dir = targetman.join("man1");
let _ = std::fs::create_dir_all(sec1dir.to_str().unwrap());
}
rsconf::rebuild_if_paths_changed(&["src", "printf", "Cargo.toml", "Cargo.lock", "build.rs"]);
// 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(not(debug_assertions))]
rsconf::rebuild_if_paths_changed(&["doc_src", "share"]);
rsconf::rebuild_if_env_changed("FISH_GETTEXT_EXTRACTION_FILE");
cc::Build::new().file("src/libc.c").compile("flibc.a");
let mut build = cc::Build::new();
// Add to the default library search path
build.flag_if_supported("-L/usr/local/lib/");
rsconf::add_library_search_path("/usr/local/lib");
let build = cc::Build::new();
let mut target = Target::new_from(build).unwrap();
// Keep verbose mode on until we've ironed out rust build script stuff
target.set_verbose(true);
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,
@@ -96,127 +60,45 @@ 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.
(
"",
&(|_: &Target| Ok(false)) as &dyn Fn(&Target) -> Result<bool, Box<dyn Error>>,
),
("apple", &detect_apple),
("bsd", &detect_bsd),
("cygwin", &detect_cygwin),
("gettext", &have_gettext),
("small_main_stack", &has_small_stack),
// See if libc supports the thread-safe localeconv_l(3) alternative to localeconv(3).
("localeconv_l", &|target| {
Ok(target.has_symbol("localeconv_l"))
}),
("FISH_USE_POSIX_SPAWN", &|target| {
Ok(target.has_header("spawn.h"))
}),
("HAVE_PIPE2", &|target| {
Ok(target.has_symbol("pipe2"))
}),
("HAVE_EVENTFD", &|target| {
// Ignore the first entry, it just sets up the type inference.
("", &(|_: &Target| false) as &dyn Fn(&Target) -> bool),
("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") {
Ok(false)
} else {
Ok(target.has_header("sys/eventfd.h"))
if target_os() == "netbsd" {
false
} else {
target.has_header("sys/eventfd.h")
}
}),
("HAVE_WAITSTATUS_SIGNAL_RET", &|target| {
Ok(target.r#if("WEXITSTATUS(0x007f) == 0x7f", &["sys/wait.h"]))
("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"])
}),
] {
match handler(target) {
Err(e) => {
rsconf::warn!("{}: {}", name, e);
rsconf::declare_cfg(name, false);
},
Ok(enabled) => rsconf::declare_cfg(name, enabled),
}
}
}
fn detect_apple(_: &Target) -> Result<bool, Box<dyn Error>> {
Ok(cfg!(any(target_os = "ios", target_os = "macos")))
}
fn detect_cygwin(_: &Target) -> Result<bool, Box<dyn Error>> {
// Cygwin target is usually cross-compiled.
Ok(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) -> Result<bool, Box<dyn Error>> {
// 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();
}
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!");
Ok(is_bsd)
}
/// Detect libintl/gettext and its needed symbols to enable internationalization/localization
/// support.
fn have_gettext(target: &Target) -> Result<bool, Box<dyn Error>> {
// The following script correctly detects and links against gettext, but so long as we are using
// C++ and generate a static library linked into the C++ binary via CMake, we need to account
// for the CMake option WITH_GETTEXT being explicitly disabled.
rsconf::rebuild_if_env_changed("CMAKE_WITH_GETTEXT");
if let Some(with_gettext) = std::env::var_os("CMAKE_WITH_GETTEXT") {
if with_gettext.eq_ignore_ascii_case("0") {
return Ok(false);
}
}
// In order for fish to correctly operate, we need some way of notifying libintl to invalidate
// its localizations when the locale environment variables are modified. Without the libintl
// symbol _nl_msg_cat_cntr, we cannot use gettext even if we find it.
let mut libraries = Vec::new();
let mut found = 0;
let symbols = ["gettext", "_nl_msg_cat_cntr"];
for symbol in &symbols {
// Historically, libintl was required in order to use gettext() and co, but that
// functionality was subsumed by some versions of libc.
if target.has_symbol(symbol) {
// No need to link anything special for this symbol
found += 1;
continue;
}
for library in ["intl", "gettextlib"] {
if target.has_symbol_in(symbol, &[library]) {
libraries.push(library);
found += 1;
continue;
}
}
}
match found {
0 => Ok(false),
1 => Err(format!("gettext found but cannot be used without {}", symbols[1]).into()),
_ => {
rsconf::link_libraries(&libraries, LinkType::Default);
Ok(true)
}
rsconf::declare_cfg(name, handler(target));
}
}
@@ -226,31 +108,28 @@ fn have_gettext(target: &Target) -> Result<bool, Box<dyn Error>> {
///
/// 0.5 MiB is small enough that we'd have to drastically reduce MAX_STACK_DEPTH to less than 10, so
/// we instead use a workaround to increase the main thread size.
fn has_small_stack(_: &Target) -> Result<bool, Box<dyn Error>> {
fn has_small_stack(_: &Target) -> bool {
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "netbsd")))]
return Ok(false);
return false;
// NetBSD 10 also needs this but can't find pthread_get_stacksize_np.
#[cfg(target_os = "netbsd")]
return Ok(true);
return true;
#[cfg(any(target_os = "ios", target_os = "macos"))]
{
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 => Ok(true),
_ => Ok(false),
}
stack_size <= TWO_MIB
}
}
@@ -258,200 +137,65 @@ 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_from_home, prefix) = if let Ok(pre) = env::var("PREFIX") {
(false, PathBuf::from(pre))
} else {
(true, PathBuf::from(".local/"))
};
// If someone gives us a $PREFIX, we need it to be absolute.
// Otherwise we would try to get it from $HOME and that won't really work.
if !prefix_from_home && prefix.is_relative() {
panic!("Can't have relative prefix");
}
rsconf::rebuild_if_env_changed("PREFIX");
rsconf::set_env_value("PREFIX", prefix.to_str().unwrap());
let datadir = get_path("DATADIR", "share/", &prefix);
rsconf::set_env_value("DATADIR", datadir.to_str().unwrap());
rsconf::rebuild_if_env_changed("DATADIR");
let datadir_subdir = if prefix_from_home {
"fish/install"
} else {
"fish"
};
rsconf::set_env_value("DATADIR_SUBDIR", datadir_subdir);
let bindir = get_path("BINDIR", "bin/", &prefix);
rsconf::set_env_value("BINDIR", bindir.to_str().unwrap());
rsconf::rebuild_if_env_changed("BINDIR");
let sysconfdir = get_path(
"SYSCONFDIR",
// If we get our prefix from $HOME, we should use the system's /etc/
// ~/.local/share/etc/ makes no sense
if prefix_from_home { "/etc/" } else { "etc/" },
&datadir,
);
rsconf::set_env_value("SYSCONFDIR", sysconfdir.to_str().unwrap());
rsconf::rebuild_if_env_changed("SYSCONFDIR");
let localedir = get_path("LOCALEDIR", "locale/", &datadir);
rsconf::set_env_value("LOCALEDIR", localedir.to_str().unwrap());
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");
}
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") {
return var;
}
let path = src_dir.join("version");
if let Ok(strver) = read_to_string(path) {
return strver;
}
let args = &["describe", "--always", "--dirty=-dirty"];
if let Ok(output) = Command::new("git").args(args).output() {
let rev = String::from_utf8_lossy(&output.stdout).trim().to_string();
if !rev.is_empty() {
// If it contains a ".", we have a proper version like "3.7",
// or "23.2.1-1234-gfab1234"
if rev.contains('.') {
return rev;
}
// If it doesn't, we probably got *just* the commit SHA,
// like "f1242abcdef".
// So we prepend the crate version so it at least looks like
// "3.8-gf1242abcdef"
// This lacks the commit *distance*, but that can't be helped without
// tags.
let version = env!("CARGO_PKG_VERSION").to_owned();
return version + "-g" + &rev;
}
}
// git did not tell us a SHA either because it isn't installed,
// or because it refused (safe.directory applies to `git describe`!)
// So we read the SHA ourselves.
fn get_git_hash() -> Result<String, Box<dyn std::error::Error>> {
let gitdir = Path::new(MANIFEST_DIR).join(".git");
let jjdir = Path::new(MANIFEST_DIR).join(".jj");
let commit_id = if gitdir.exists() {
// .git/HEAD contains ref: refs/heads/branch
let headpath = gitdir.join("HEAD");
let headstr = read_to_string(headpath)?;
let headref = headstr.split(' ').nth(1).unwrap().trim();
// .git/refs/heads/branch contains the SHA
let refpath = gitdir.join(headref);
// Shorten to 9 characters (what git describe does currently)
read_to_string(refpath)?
} else if jjdir.exists() {
let output = Command::new("jj")
.args([
"log",
"--revisions",
"@",
"--no-graph",
"--ignore-working-copy",
"--template",
"commit_id",
])
.output()
.unwrap();
String::from_utf8_lossy(&output.stdout).to_string()
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 {
return Err("did not find either of .git or .jj".into());
};
let refstr = &commit_id[0..9];
let refstr = refstr.trim();
let version = env!("CARGO_PKG_VERSION").to_owned();
Ok(version + "-g" + refstr)
path
}
}
get_git_hash().expect("Could not get a version. Either set $FISH_BUILD_VERSION or install git.")
let prefix = overridable_path("PREFIX", |env_prefix| {
Some(PathBuf::from(env_prefix.unwrap_or("/usr/local".to_owned())))
})
.unwrap();
overridable_path("SYSCONFDIR", |env_sysconfdir| {
Some(join_if_relative(
&prefix,
env_sysconfdir.unwrap_or("/etc/".to_owned()),
))
});
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,
)
})
});
}
#[cfg(feature = "embed-data")]
// disable clippy because otherwise it would panic without sphinx
#[cfg(not(clippy))]
fn build_man(build_dir: &Path) {
fn get_version() -> String {
use std::process::Command;
let mandir = build_dir;
let sec1dir = mandir.join("man1");
let docsrc_path = canonicalize(MANIFEST_DIR).join("doc_src");
let docsrc = docsrc_path.to_str().unwrap();
let args = &[
"-j",
"auto",
"-q",
"-b",
"man",
"-c",
docsrc,
// doctree path - put this *above* the man1 dir to exclude it.
// this is ~6M
"-d",
mandir.to_str().unwrap(),
docsrc,
sec1dir.to_str().unwrap(),
];
let _ = std::fs::create_dir_all(sec1dir.to_str().unwrap());
rsconf::rebuild_if_env_changed("FISH_BUILD_DOCS");
if env::var("FISH_BUILD_DOCS") == Ok("0".to_string()) {
println!("cargo:warning=Skipping man pages because $FISH_BUILD_DOCS is set to 0");
return;
}
// We run sphinx to build the man pages.
// Every error here is fatal so cargo doesn't cache the result
// - 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.
match Command::new("sphinx-build").args(args).spawn() {
Err(x) if x.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.");
}
println!("cargo:warning=Cannot find sphinx-build to build man pages.");
println!("cargo:warning=If you install it now you need to run `cargo clean` and rebuild, or set $FISH_BUILD_DOCS=1 explicitly.");
}
Err(x) => {
// Another error - permissions wrong etc
panic!("Error starting sphinx-build to build man pages: {:?}", x);
}
Ok(mut x) => match x.wait() {
Err(err) => {
panic!(
"Error waiting for sphinx-build to build man pages: {:?}",
err
);
}
Ok(out) => {
if !out.success() {
panic!("sphinx-build failed to build the man pages.");
}
}
},
}
String::from_utf8(
Command::new("build_tools/git_version_gen.sh")
.output()
.unwrap()
.stdout,
)
.unwrap()
.trim_ascii_end()
.to_owned()
}

View File

@@ -8,6 +8,40 @@ if [ "$FISH_CHECK_LINT" = false ]; then
lint=false
fi
case "$(uname)" in
MSYS*)
is_cygwin=true
cygwin_var=MSYS
;;
CYGWIN*)
is_cygwin=true
cygwin_var=CYGWIN
;;
*)
is_cygwin=false
;;
esac
check_dependency_versions=false
if [ "${FISH_CHECK_DEPENDENCY_VERSIONS:-false}" != false ]; then
check_dependency_versions=true
fi
green='\e[0;32m'
yellow='\e[1;33m'
reset='\e[m'
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
@@ -17,13 +51,18 @@ fi
cargo() {
subcmd=$1
shift
# shellcheck disable=2086
command cargo "$subcmd" $cargo_args "$@"
if [ -n "$FISH_CHECK_RUST_TOOLCHAIN" ]; then
# shellcheck disable=2086
command cargo "+$FISH_CHECK_RUST_TOOLCHAIN" "$subcmd" $cargo_args "$@"
else
# shellcheck disable=2086
command cargo "$subcmd" $cargo_args "$@"
fi
}
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
}
@@ -34,21 +73,73 @@ if $lint; then
export RUSTDOCFLAGS="--deny=warnings ${RUSTDOCFLAGS}"
fi
repo_root="$(dirname "$0")/.."
build_dir="${CARGO_TARGET_DIR:-$repo_root/target}/${target_triple}/debug"
workspace_root="$(dirname "$0")/.."
target_dir=${CARGO_TARGET_DIR:-$workspace_root/target}
if [ -n "$target_triple" ]; then
target_dir="$target_dir/$target_triple"
fi
# The directory containing the binaries produced by cargo/rustc.
# 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
if $lint; then
PATH="$build_dir:$PATH" "$repo_root/build_tools/style.fish" --all --check
cargo clippy --workspace --all-targets
if [ -n "$FISH_TEST_MAX_CONCURRENCY" ]; then
export RUST_TEST_THREADS="$FISH_TEST_MAX_CONCURRENCY"
export CARGO_BUILD_JOBS="$FISH_TEST_MAX_CONCURRENCY"
fi
cargo test --no-default-features --workspace --all-targets
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" cargo xtask format --all --check
for features in "" --no-default-features; do
cargo clippy --workspace --all-targets $features
done
fi
# When running `cargo test`, some binaries (e.g. `fish_gettext_extraction`)
# are dynamically linked against Rust's `std-xxx.dll` instead of being
# statically link as they usually are.
# On Cygwin, `PATH`is not properly updated to point to the `std-xxx.dll`
# location, so we have to do it manually.
# See:
# - https://github.com/rust-lang/rust/issues/149050
# - https://github.com/msys2/MSYS2-packages/issues/5784
(
if $is_cygwin; then
export PATH="$PATH:$(rustc --print target-libdir)"
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
# Using "()" not "{}" because we do want a subshell (for the export)
system_tests() (
[ -n "$@" ] && export "$@"
export FISH_GETTEXT_EXTRACTION_DIR="$gettext_template_dir"
"$workspace_root/tests/test_driver.py" "$build_dir"
)
test_cmd='FISH_GETTEXT_EXTRACTION_DIR="$gettext_template_dir" "$workspace_root/tests/test_driver.py" "$build_dir"'
if $is_cygwin; then
echo -e "=== Running ${green}integration tests ${yellow}with${green} symlinks${reset}"
system_tests $cygwin_var=winsymlinks
echo -e "=== Running ${green}integration tests ${yellow}without${green} symlinks${reset}"
system_tests $cygwin_var=winsymlinks
else
echo -e "=== Running ${green}integration tests${reset}"
system_tests
fi
FISH_GETTEXT_EXTRACTION_FILE=$template_file "$repo_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

@@ -12,35 +12,48 @@ begin
# Note that this results in the file being overwritten.
# This is desired behavior, to get rid of the results of prior invocations
# of this script.
begin
echo 'msgid ""'
echo 'msgstr ""'
echo '"Content-Type: text/plain; charset=UTF-8\n"'
echo ""
end
set -l header 'msgid ""\nmsgstr "Content-Type: text/plain; charset=UTF-8\\\\n"\n\n'
printf $header
set -g repo_root (status dirname)/..
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
FISH_GETTEXT_EXTRACTION_DIR=$rust_extraction_dir cargo check --features=gettext-extract
or exit 1
end
# Get rid of duplicates and sort.
msguniq --no-wrap --strict --sort-output $rust_extraction_file
or exit 1
if not set -l --query _flag_use_existing_template
rm $rust_extraction_file
function mark_section
set -l section_name $argv[1]
echo 'msgid "fish-section-'$section_name'"'
echo 'msgstr ""'
echo ''
end
function extract_fish_script_messages --argument-names regex
mark_section tier1-from-rust
# Get rid of duplicates and sort.
begin
# Without providing this header, msguniq complains when a msgid is non-ASCII.
printf $header
find $rust_extraction_dir -type f -exec cat {} +
end |
msguniq --no-wrap --sort-output |
# Remove the header again. Otherwise it would appear twice, breaking the msguniq at the end
# of this file.
sed '/^msgid ""$/ {N; /\nmsgstr "Content-Type: text\/plain; charset=UTF-8\\\\n"$/ {N; d}}'
if not set -l --query _flag_use_existing_template
rm -r $rust_extraction_dir
end
function extract_fish_script_messages_impl
set -l regex $argv[1]
set -e argv[1]
# Using xgettext causes more trouble than it helps.
# This is due to handling of escaping in fish differing from formats xgettext understands
# (e.g. POSIX shell strings).
@@ -59,24 +72,74 @@ begin
# 5. Double quotes are escaped, such that they are not interpreted as the start or end of
# a msgid.
# 6. We transform the string into the format expected in a PO file.
cat $share_dir/config.fish $share_dir/completions/*.fish $share_dir/functions/*.fish |
cat $argv |
string replace --filter --regex $regex '$1' |
string unescape |
sort -u |
sed -E -e 's_\\\\_\\\\\\\\_g' -e 's_"_\\\\"_g' -e 's_^(.*)$_msgid "\1"\nmsgstr ""\n_'
end
set -g share_dir $repo_root/share
function extract_fish_script_messages
set -l tier $argv[1]
set -e argv[1]
if not set -q argv[1]
return
end
# This regex handles explicit requests to translate a message. These are more important to translate
# than messages which should be implicitly translated.
set -l explicit_regex '.*\( *_ (([\'"]).+?(?<!\\\\)\\2) *\).*'
mark_section "$tier-from-script-explicitly-added"
extract_fish_script_messages_impl $explicit_regex $argv
# This regex handles explicit requests to translate a message. These are more important to translate
# than messages which should be implicitly translated.
set -l explicit_regex '.*\( *_ (([\'"]).+?(?<!\\\\)\\2) *\).*'
extract_fish_script_messages $explicit_regex
# This regex handles descriptions for `complete` and `function` statements. These messages are not
# particularly important to translate. Hence the "implicit" label.
set -l implicit_regex '^(?:\s|and |or )*(?:complete|function).*? (?:-d|--description) (([\'"]).+?(?<!\\\\)\\2).*'
mark_section "$tier-from-script-implicitly-added"
extract_fish_script_messages_impl $implicit_regex $argv
end
# This regex handles descriptions for `complete` and `function` statements. These messages are not
# particularly important to translate. Hence the "implicit" label.
set -l implicit_regex '^(?:\s|and |or )*(?:complete|function).*? (?:-d|--description) (([\'"]).+?(?<!\\\\)\\2).*'
extract_fish_script_messages $implicit_regex
set -g share_dir $workspace_root/share
set -l tier1 $share_dir/config.fish
set -l tier2
set -l tier3
for file in $share_dir/completions/*.fish $share_dir/functions/*.fish
# set -l tier (string match -r '^# localization: .*' <$file)
set -l tier (string replace -rf -m1 \
'^# localization: (.*)$' '$1' <$file)
if set -q tier[1]
switch "$tier"
case tier1 tier2 tier3
set -a $tier $file
case 'skip*'
case '*'
echo >&2 "$file:1 unexpected localization tier: $tier"
exit 1
end
continue
end
set -l dirname (path basename (path dirname $file))
set -l command_name (path basename --no-extension $file)
if test $dirname = functions &&
string match -q -- 'fish_*' $command_name
set -a tier1 $file
continue
end
if test $dirname != completions
echo >&2 "$file:1 missing localization tier for function file"
exit 1
end
if test -e $workspace_root/doc_src/cmds/$command_name.rst
set -a tier1 $file
else
set -a tier3 $file
end
end
extract_fish_script_messages tier1 $tier1
extract_fish_script_messages tier2 $tier2
extract_fish_script_messages tier3 $tier3
end |
# At this point, all extracted strings have been written to stdout,
# starting with the ones taken from the Rust sources,

View File

@@ -1,70 +1,22 @@
#!/bin/sh
# Originally from the git sources (GIT-VERSION-GEN)
# Presumably (C) Junio C Hamano <junkio@cox.net>
# Reused under GPL v2.0
# Modified for fish by David Adam <zanchey@ucc.gu.uwa.edu.au>
set -e
# Find the fish directory as two levels up from script directory.
FISH_BASE_DIR="$( cd "$( dirname "$( dirname "$0" )" )" && pwd )"
DEF_VER=unknown
git_permission_failed=0
# First see if there is a version file (included in release tarballs),
# then try git-describe, then default.
if test -f version
then
VN=$(cat version) || VN="$DEF_VER"
else
if VN=$(git -C "$FISH_BASE_DIR" describe --always --dirty 2>/dev/null); then
:
version=$(
awk <"$FISH_BASE_DIR/Cargo.toml" -F'"' '$1 == "version = " { print $2 }'
)
if git_version=$(
GIT_CEILING_DIRECTORIES=$FISH_BASE_DIR/.. \
git -C "$FISH_BASE_DIR" describe --always --dirty 2>/dev/null); then
if [ "$git_version" = "${git_version#"$version"}" ]; then
version=$version-g$git_version
else
if test $? = 128; then
# Current git versions return status 128
# when run in a repo owned by another user.
# Even for describe and everything.
# This occurs for `sudo make install`.
git_permission_failed=1
fi
VN="$DEF_VER"
version=$git_version
fi
fi
# If the first param is --stdout, then output to stdout and exit.
if test "$1" = '--stdout'
then
echo $VN
exit 0
fi
# Set the output directory as either the first param or cwd.
test -n "$1" && OUTPUT_DIR=$1/ || OUTPUT_DIR=
FBVF="${OUTPUT_DIR}FISH-BUILD-VERSION-FILE"
if test "$VN" = unknown && test -r "$FBVF" && test "$git_permission_failed" = 1
then
# HACK: Git failed, so we keep the current version file.
# This helps in case you built fish as a normal user
# and then try to `sudo make install` it.
date +%s > "${OUTPUT_DIR}"fish-build-version-witness.txt
exit 0
fi
if test -r "$FBVF"
then
VC=$(cat "$FBVF")
else
VC="unset"
fi
# Maybe output the FBVF
# It looks like "2.7.1-621-ga2f065e6"
test "$VN" = "$VC" || {
echo >&2 "$VN"
echo "$VN" >"$FBVF"
}
# Output the fish-build-version-witness.txt
# See https://cmake.org/cmake/help/v3.4/policy/CMP0058.html
date +%s > "${OUTPUT_DIR}"fish-build-version-witness.txt
echo "$version"

View File

@@ -1,3 +0,0 @@
# LSAN can detect leaks tracing back to __asan::AsanThread::ThreadStart (probably caused by our
# threads not exiting before their TLS dtors are called). Just ignore it.
leak:AsanThread

View File

@@ -0,0 +1,83 @@
#!/bin/sh
# This script takes a source tarball (from build_tools/make_tarball.sh) and a vendor tarball (from
# build_tools/make_vendor_tarball.sh, generated if not present), and produces:
# * Appropriately-named symlinks to look like a Debian package
# * Debian .changes and .dsc files with plain names ($version-1) and supported Ubuntu prefixes
# ($version-1~somedistro)
# * An RPM spec file
# By default, input and output files go in ~/fish_built, but this can be controlled with the
# FISH_ARTEFACT_PATH environment variable.
{
set -e
version=$1
[ -n "$version" ] || { echo "Version number required as argument" >&2; exit 1; }
[ -n "$DEB_SIGN_KEYID$DEB_SIGN_KEYFILE" ] ||
echo "Warning: neither DEB_SIGN_KEYID or DEB_SIGN_KEYFILE environment variables are set; you
will need a signing key for the author of the most recent debian/changelog entry." >&2
workpath=${FISH_ARTEFACT_PATH:-~/fish_built}
source_tarball="$workpath"/fish-"$version".tar.xz
vendor_tarball="$workpath"/fish-"$version"-vendor.tar.xz
[ -e "$source_tarball" ] || { echo "Missing source tarball, expected at $source_tarball" >&2; exit 1; }
cd "$workpath"
# Unpack the sources
tar xf "$source_tarball"
sourcepath="$workpath"/fish-"$version"
# Generate the vendor tarball if it is not already present
[ -e "$vendor_tarball" ] || (cd "$sourcepath"; build_tools/make_vendor_tarball.sh;)
# This step requires network access, so do it early in case it fails
# sh has no real array support
ubuntu_versions=$(uv run --script "$sourcepath"/build_tools/supported_ubuntu_versions.py)
# Write the specfile
[ -e "$workpath"/fish.spec ] && { echo "Cowardly refusing to overwite an existing fish.spec" >&2;
exit 1; }
rpmversion=$(echo "$version" |sed -e 's/-/+/' -e 's/-/./g')
sed -e "s/@version@/$version/g" -e "s/@rpmversion@/$rpmversion/g" \
< "$sourcepath"/fish.spec.in > "$workpath"/fish.spec
# Make the symlinks for Debian
ln -s "$source_tarball" "$workpath"/fish_"$version".orig.tar.xz
ln -s "$vendor_tarball" "$workpath"/fish_"$version".orig-cargo-vendor.tar.xz
# Set up the Debian source tree
cd "$sourcepath"
mkdir cargo-vendor
tar -C cargo-vendor -x -f "$vendor_tarball"
cp -r contrib/debian debian
# The vendor tarball contains a new .cargo/config.toml, which has the
# vendoring overrides appended to it. dpkg-source will add this as a
# patch using the flags in debian/
cp cargo-vendor/.cargo/config.toml .cargo/config.toml
# Update the Debian changelog
# The release scripts do this for release builds - skip if it has already been done
if head -n1 debian/changelog | grep --invert-match --quiet --fixed-strings "$version"; then
debchange --newversion "$version-1" --distribution unstable "Snapshot build"
fi
# Builds the "plain" Debian package
# debuild runs lintian, which takes ten minutes to run over the vendor directories
# just use dpkg-buildpackage directly
dpkg-buildpackage --build=source -d
# Build the Ubuntu packages
# deb-reversion does not work on source packages, so do the whole thing ourselves
for series in $ubuntu_versions; do
sed -i -e "1 s/$version-1)/$version-1~$series)/" -e "1 s/unstable/$series/" debian/changelog
dpkg-buildpackage --build=source -d
sed -i -e "1 s/$version-1~$series)/$version-1)/" -e "1 s/$series/unstable/" debian/changelog
done
}

164
build_tools/make_macos_pkg.sh Executable file
View File

@@ -0,0 +1,164 @@
#!/usr/bin/env bash
# Script to produce an OS X installer .pkg and .app(.zip)
usage() {
echo "Build macOS packages, optionally signing and notarizing them."
echo "Usage: $0 options"
echo "Options:"
echo " -s Enables code signing"
echo " -f <APP_KEY.p12> Path to .p12 file for application signing"
echo " -i <INSTALLER_KEY.p12> Path to .p12 file for installer signing"
echo " -p <PASSWORD> Password for the .p12 files (necessary to access the certificates)"
echo " -e <entitlements file> (Optional) Path to an entitlements XML file"
echo " -n Enables notarization. This will fail if code signing is not also enabled."
echo " -j <API_KEY.JSON> Path to JSON file generated with \`rcodesign encode-app-store-connect-api-key\` (required for notarization)"
echo
exit 1
}
set -x
set -e
SIGN=
NOTARIZE=
ARM64_DEPLOY_TARGET='MACOSX_DEPLOYMENT_TARGET=11.0'
X86_64_DEPLOY_TARGET='MACOSX_DEPLOYMENT_TARGET=10.12'
cmake_args=()
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");;
p) P12_PASSWORD="$OPTARG";;
e) ENTITLEMENTS_FILE=$(realpath "$OPTARG");;
n) NOTARIZE=1;;
j) API_KEY_FILE=$(realpath "$OPTARG");;
\?) usage;;
esac
done
if [ -n "$SIGN" ] && { [ -z "$P12_APP_FILE" ] || [ -z "$P12_INSTALL_FILE" ] || [ -z "$P12_PASSWORD" ]; }; then
usage
fi
if [ -n "$NOTARIZE" ] && [ -z "$API_KEY_FILE" ]; then
usage
fi
VERSION=$(build_tools/git_version_gen.sh)
echo "Version is $VERSION"
PKGDIR=$(mktemp -d)
echo "$PKGDIR"
SRC_DIR=$PWD
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" \
&& 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 a fat binary inside the root.
{ cd "$PKGDIR/build_x86_64" \
&& do_cmake -DRust_CARGO_TARGET=x86_64-apple-darwin \
&& env $X86_64_DEPLOY_TARGET make VERBOSE=1 -j 12; }
# Fatten it up.
FILE=$PKGDIR/root/usr/local/bin/fish
X86_FILE=$PKGDIR/build_x86_64/$(basename "$FILE")
rcodesign macho-universal-create --output "$FILE" "$FILE" "$X86_FILE"
chmod 755 "$FILE"
if test -n "$SIGN"; then
echo "Signing executables"
ARGS=(
--p12-file "$P12_APP_FILE"
--p12-password "$P12_PASSWORD"
--code-signature-flags runtime
--for-notarization
)
if [ -n "$ENTITLEMENTS_FILE" ]; then
ARGS+=(--entitlements-xml-file "$ENTITLEMENTS_FILE")
fi
(set +x; rcodesign sign "${ARGS[@]}" "$PKGDIR"/root/usr/local/bin/fish)
fi
pkgbuild --scripts "$SRC_DIR/build_tools/osx_package_scripts" --root "$PKGDIR/root/" --identifier 'com.ridiculousfish.fish-shell-pkg' --version "$VERSION" "$PKGDIR/intermediates/fish.pkg"
productbuild --package-path "$PKGDIR/intermediates" --distribution "$SRC_DIR/build_tools/osx_distribution.xml" --resources "$SRC_DIR/build_tools/osx_package_resources/" "$OUTPUT_PATH/fish-$VERSION.pkg"
if test -n "$SIGN"; then
echo "Signing installer"
ARGS=(
--p12-file "$P12_INSTALL_FILE"
--p12-password "$P12_PASSWORD"
--code-signature-flags runtime
--for-notarization
)
(set +x; rcodesign sign "${ARGS[@]}" "$OUTPUT_PATH/fish-$VERSION.pkg")
fi
# Make the app
(cd "$PKGDIR/build_arm64" && env $ARM64_DEPLOY_TARGET make -j 12 fish_macapp)
(cd "$PKGDIR/build_x86_64" && env $X86_64_DEPLOY_TARGET make -j 12 fish_macapp)
# Make the app's /usr/local/bin/fish binary universal. Note fish.app/Contents/MacOS/fish already is, courtesy of CMake.
cd "$PKGDIR/build_arm64"
FILE=fish.app/Contents/Resources/base/usr/local/bin/fish
X86_FILE=$PKGDIR/build_x86_64/fish.app/Contents/Resources/base/usr/local/bin/$(basename "$FILE")
rcodesign macho-universal-create --output "$FILE" "$FILE" "$X86_FILE"
# macho-universal-create screws up the permissions.
chmod 755 "$FILE"
if test -n "$SIGN"; then
echo "Signing app"
ARGS=(
--p12-file "$P12_APP_FILE"
--p12-password "$P12_PASSWORD"
--code-signature-flags runtime
--for-notarization
)
if [ -n "$ENTITLEMENTS_FILE" ]; then
ARGS+=(--entitlements-xml-file "$ENTITLEMENTS_FILE")
fi
(set +x; rcodesign sign "${ARGS[@]}" "fish.app")
fi
cp -R "fish.app" "$OUTPUT_PATH/fish-$VERSION.app"
cd "$OUTPUT_PATH"
# Maybe notarize.
if test -n "$NOTARIZE"; then
echo "Notarizing"
rcodesign notarize --staple --wait --max-wait-seconds 1800 --api-key-file "$API_KEY_FILE" "$OUTPUT_PATH/fish-$VERSION.pkg"
rcodesign notarize --staple --wait --max-wait-seconds 1800 --api-key-file "$API_KEY_FILE" "$OUTPUT_PATH/fish-$VERSION.app"
fi
# Zip it up.
zip -r "fish-$VERSION.app.zip" "fish-$VERSION.app" && rm -Rf "fish-$VERSION.app"
rm -rf "$PKGDIR"

View File

@@ -1,183 +0,0 @@
#!/usr/bin/env bash
# Script to produce an OS X installer .pkg and .app(.zip)
usage() {
echo "Build macOS packages, optionally signing and notarizing them."
echo "Usage: $0 options"
echo "Options:"
echo " -s Enables code signing"
echo " -f <APP_KEY.p12> Path to .p12 file for application signing"
echo " -i <INSTALLER_KEY.p12> Path to .p12 file for installer signing"
echo " -p <PASSWORD> Password for the .p12 files (necessary to access the certificates)"
echo " -e <entitlements file> (Optional) Path to an entitlements XML file"
echo " -n Enables notarization. This will fail if code signing is not also enabled."
echo " -j <API_KEY.JSON> Path to JSON file generated with \`rcodesign encode-app-store-connect-api-key\` (required for notarization)"
echo
exit 1
}
set -x
set -e
SIGN=
NOTARIZE=
ARM64_DEPLOY_TARGET='MACOSX_DEPLOYMENT_TARGET=11.0'
X86_64_DEPLOY_TARGET='MACOSX_DEPLOYMENT_TARGET=10.9'
# 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
case $opt in
s) SIGN=1;;
f) P12_APP_FILE=$(realpath "$OPTARG");;
i) P12_INSTALL_FILE=$(realpath "$OPTARG");;
p) P12_PASSWORD="$OPTARG";;
e) ENTITLEMENTS_FILE=$(realpath "$OPTARG");;
n) NOTARIZE=1;;
j) API_KEY_FILE=$(realpath "$OPTARG");;
\?) usage;;
esac
done
if [ -n "$SIGN" ] && { [ -z "$P12_APP_FILE" ] || [ -z "$P12_INSTALL_FILE" ] || [ -z "$P12_PASSWORD" ]; }; then
usage
fi
if [ -n "$NOTARIZE" ] && [ -z "$API_KEY_FILE" ]; then
usage
fi
VERSION=$(git describe --always --dirty 2>/dev/null)
if test -z "$VERSION" ; then
echo "Could not get version from git"
if test -f version; then
VERSION=$(cat version)
fi
fi
echo "Version is $VERSION"
PKGDIR=$(mktemp -d)
echo "$PKGDIR"
SRC_DIR=$PWD
OUTPUT_PATH=${FISH_ARTEFACT_PATH:-~/fish_built}
mkdir -p "$PKGDIR/build_x86_64" "$PKGDIR/build_arm64" "$PKGDIR/root" "$PKGDIR/intermediates" "$PKGDIR/dst"
# 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" \
-DWITH_GETTEXT=OFF \
-DRust_CARGO_TARGET=aarch64-apple-darwin \
-DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' \
-DFISH_USE_SYSTEM_PCRE2=OFF \
"$SRC_DIR" \
&& 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" \
-DWITH_GETTEXT=OFF \
-DRust_TOOLCHAIN="$RUST_VERSION_X86_64" \
-DRust_CARGO_TARGET=x86_64-apple-darwin \
-DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' \
-DFISH_USE_SYSTEM_PCRE2=OFF "$SRC_DIR" \
&& env $X86_64_DEPLOY_TARGET make VERBOSE=1 -j 12; }
# Fatten them up.
for FILE in "$PKGDIR"/root/usr/local/bin/*; do
X86_FILE="$PKGDIR/build_x86_64/$(basename "$FILE")"
rcodesign macho-universal-create --output "$FILE" "$FILE" "$X86_FILE"
chmod 755 "$FILE"
done
if test -n "$SIGN"; then
echo "Signing executables"
ARGS=(
--p12-file "$P12_APP_FILE"
--p12-password "$P12_PASSWORD"
--code-signature-flags runtime
--for-notarization
)
if [ -n "$ENTITLEMENTS_FILE" ]; then
ARGS+=(--entitlements-xml-file "$ENTITLEMENTS_FILE")
fi
for FILE in "$PKGDIR"/root/usr/local/bin/*; do
(set +x; rcodesign sign "${ARGS[@]}" "$FILE")
done
fi
pkgbuild --scripts "$SRC_DIR/build_tools/osx_package_scripts" --root "$PKGDIR/root/" --identifier 'com.ridiculousfish.fish-shell-pkg' --version "$VERSION" "$PKGDIR/intermediates/fish.pkg"
productbuild --package-path "$PKGDIR/intermediates" --distribution "$SRC_DIR/build_tools/osx_distribution.xml" --resources "$SRC_DIR/build_tools/osx_package_resources/" "$OUTPUT_PATH/fish-$VERSION.pkg"
if test -n "$SIGN"; then
echo "Signing installer"
ARGS=(
--p12-file "$P12_INSTALL_FILE"
--p12-password "$P12_PASSWORD"
--code-signature-flags runtime
--for-notarization
)
(set +x; rcodesign sign "${ARGS[@]}" "$OUTPUT_PATH/fish-$VERSION.pkg")
fi
# Make the app
(cd "$PKGDIR/build_arm64" && env $ARM64_DEPLOY_TARGET make -j 12 fish_macapp)
(cd "$PKGDIR/build_x86_64" && env $X86_64_DEPLOY_TARGET make -j 12 fish_macapp)
# Make the app's /usr/local/bin binaries universal. Note fish.app/Contents/MacOS/fish already is, courtesy of CMake.
cd "$PKGDIR/build_arm64"
for FILE in fish.app/Contents/Resources/base/usr/local/bin/*; do
X86_FILE="$PKGDIR/build_x86_64/fish.app/Contents/Resources/base/usr/local/bin/$(basename "$FILE")"
rcodesign macho-universal-create --output "$FILE" "$FILE" "$X86_FILE"
# macho-universal-create screws up the permissions.
chmod 755 "$FILE"
done
if test -n "$SIGN"; then
echo "Signing app"
ARGS=(
--p12-file "$P12_APP_FILE"
--p12-password "$P12_PASSWORD"
--code-signature-flags runtime
--for-notarization
)
if [ -n "$ENTITLEMENTS_FILE" ]; then
ARGS+=(--entitlements-xml-file "$ENTITLEMENTS_FILE")
fi
(set +x; rcodesign sign "${ARGS[@]}" "fish.app")
fi
cp -R "fish.app" "$OUTPUT_PATH/fish-$VERSION.app"
cd "$OUTPUT_PATH"
# Maybe notarize.
if test -n "$NOTARIZE"; then
echo "Notarizing"
rcodesign notarize --staple --wait --max-wait-seconds 1800 --api-key-file "$API_KEY_FILE" "$OUTPUT_PATH/fish-$VERSION.pkg"
rcodesign notarize --staple --wait --max-wait-seconds 1800 --api-key-file "$API_KEY_FILE" "$OUTPUT_PATH/fish-$VERSION.app"
fi
# Zip it up.
zip -r "fish-$VERSION.app.zip" "fish-$VERSION.app" && rm -Rf "fish-$VERSION.app"
rm -rf "$PKGDIR"

1
build_tools/make_pkg.sh Symbolic link
View File

@@ -0,0 +1 @@
make_macos_pkg.sh

View File

@@ -1,79 +1,42 @@
#!/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 wil 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
# Get the version
VERSION=$(build_tools/git_version_gen.sh)
# Use Ninja if available, as it automatically paralellises
BUILD_TOOL="make"
BUILD_GENERATOR="Unix Makefiles"
if command -v ninja >/dev/null; then
BUILD_TOOL="ninja"
BUILD_GENERATOR="Ninja"
fi
prefix=fish-$VERSION
path=${FISH_ARTEFACT_PATH:-~/fish_built}/$prefix.tar.xz
# 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
tmpdir=$(mktemp -d)
manifest=$tmpdir/Cargo.toml
lockfile=$tmpdir/Cargo.lock
if [ "$TAR" = "notfound" ]; then
echo 'No suitable tar (supporting --mtime) found as tar/gtar/gnutar in PATH'
exit 1
fi
sed "s/^version = \".*\"\$/version = \"$VERSION\"/g" Cargo.toml >"$manifest"
awk -v version=$VERSION '
/^name = "fish"$/ { ok=1 }
ok == 1 && /^version = ".*"$/ {
ok = 2;
$0 = "version = \"" version "\"";
}
{print}
' \
Cargo.lock >"$lockfile"
# Get the current directory, which we'll use for symlinks
wd="$PWD"
git archive \
--prefix="$prefix/" \
--add-virtual-file="$prefix/Cargo.toml:$(cat "$manifest")" \
--add-virtual-file="$prefix/Cargo.lock:$(cat "$lockfile")" \
HEAD |
xz >"$path"
# Get the version from git-describe
VERSION=$(git describe --dirty 2>/dev/null)
# The name of the prefix, which is the directory that you get when you untar
prefix="fish-$VERSION"
# 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"
rm "$manifest"
rm "$lockfile"
rmdir "$tmpdir"
# 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

@@ -8,25 +8,11 @@
# Exit on error
set -e
# 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 telling Cargo where to find the sources
wd="$PWD"
# Get the version from git-describe
VERSION=$(git describe --dirty 2>/dev/null)
VERSION=$(build_tools/git_version_gen.sh)
# The name of the prefix, which is the directory that you get when you untar
prefix="fish-$VERSION"
@@ -42,8 +28,14 @@ rm -f "$path" "$path".xz
PREFIX_TMPDIR=$(mktemp -d)
cd "$PREFIX_TMPDIR"
# Add .cargo/config.toml. This means that the caller may need to remove that file from the tarball.
# See e4674cd7b5f (.cargo/config.toml: exclude from tarball, 2025-01-12)
mkdir .cargo
cargo vendor --manifest-path "$wd/Cargo.toml" > .cargo/config.toml
{
cat "$wd"/.cargo/config.toml
cargo vendor --manifest-path "$wd/Cargo.toml"
} > .cargo/config.toml
tar cfvJ "$path".xz vendor .cargo

View File

@@ -1,28 +1,28 @@
<html>
<head>
<style>
body {
font-family: system-ui, -apple-system, "Helvetica Neue", sans-serif;
font-size: 10pt;
}
code, tt {
font-family: ui-monospace, Menlo, monospace;
}
</style>
</head>
<body>
<p>
<strong>fish</strong> is a smart and user-friendly command line shell. For more information, visit <a href="https://fishshell.com">fishshell.com</a>.
</p>
<p>
<strong>fish</strong> will be installed into <tt>/usr/local/</tt>, and its path will be added to <wbr><tt>/etc/shells</tt> if necessary.
</p>
<p>
Your default shell will <em>not</em> be changed. To make <strong>fish</strong> your login shell after the installation, run:
</p>
<p>
<code>chsh -s /usr/local/bin/fish</code>
</p>
<p>Enjoy! Bugs can be reported on <a href="https://github.org/fish-shell/fish-shell/">GitHub</a>.</p>
</body>
<head>
<style>
body {
font-family: system-ui, -apple-system, "Helvetica Neue", sans-serif;
font-size: 10pt;
}
code, tt {
font-family: ui-monospace, Menlo, monospace;
}
</style>
</head>
<body>
<p>
<strong>fish</strong> is a smart and user-friendly command line shell. For more information, visit <a href="https://fishshell.com">fishshell.com</a>.
</p>
<p>
<strong>fish</strong> will be installed into <tt>/usr/local/</tt>, and its path will be added to <wbr><tt>/etc/shells</tt> if necessary.
</p>
<p>
Your default shell will <em>not</em> be changed. To make <strong>fish</strong> your login shell after the installation, run:
</p>
<p>
<code>chsh -s /usr/local/bin/fish</code>
</p>
<p>Enjoy! Bugs can be reported on <a href="https://github.com/fish-shell/fish-shell/">GitHub</a>.</p>
</body>
</html>

View File

@@ -4,14 +4,14 @@
if test $# -eq 0
then
echo "usage: $0 shellname [shellname ...]"
exit 1
echo "usage: $0 shellname [shellname ...]"
exit 1
fi
scriptname=$(basename "$0")
if [ "$(id -u)" -ne 0 ]; then
echo "${scriptname} must be run as root"
exit 1
echo "${scriptname} must be run as root"
exit 1
fi
file=/etc/shells

View File

@@ -2,6 +2,6 @@
echo "Removing any previous installation"
pkgutil --pkg-info "${INSTALL_PKG_SESSION_ID}" && pkgutil --only-files --files "${INSTALL_PKG_SESSION_ID}" | while read -r installed
do rm -v "${DSTVOLUME}${installed}"
do rm -v "${DSTVOLUME}${installed}"
done
echo "... removed"

110
build_tools/release-notes.sh Executable file
View File

@@ -0,0 +1,110 @@
#!/bin/sh
set -e
workspace_root=$(dirname "$0")/..
relnotes_tmp=$(mktemp -d)
mkdir -p "$relnotes_tmp/fake-workspace" "$relnotes_tmp/out"
(
cd "$workspace_root"
cp -r doc_src CONTRIBUTING.rst README.rst "$relnotes_tmp/fake-workspace"
)
version=$(sed 's,^fish \(\S*\) .*,\1,; 1q' "$workspace_root/CHANGELOG.rst")
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"
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")
printf %s \
"This release brings $num_commits new commits since $previous_version," \
" contributed by $num_authors authors, $num_new_authors of which are new committers."
echo
echo
)
} fi
printf '%s\n' "$(awk <"$workspace_root/CHANGELOG.rst" '
NR <= 2 || /^\.\. ignore / { next }
/^===/ { exit }
{ print }
' | sed '$d')" |
sed -e '$s/^----*$//' # Remove spurious transitions at the end of the document.
if $add_stats; then {
JoinEscaped() {
LC_CTYPE=C.UTF-8 sed 's/\S/\\&/g' |
awk '
NR != 1 { printf ",\n" }
{ printf "%s", $0 }
END { printf "\n" }
'
}
echo ""
echo "---"
echo ""
echo "Thanks to everyone who contributed through issue discussions, code reviews, or code changes."
echo
printf "Welcome our new committers: "
JoinEscaped <"$relnotes_tmp/committers-new"
echo
printf "Welcome back our returning committers: "
JoinEscaped <"$relnotes_tmp/committers-returning"
} fi
echo
echo "---"
echo
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`` 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 \
-W -E -b markdown -c "$workspace_root/doc_src" \
-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_flavor=github \
"$@"
# Skip changelog header
sed -n 1p "$relnotes_tmp/out/relnotes.md" | grep -Fxq "# Release notes"
sed -n 2p "$relnotes_tmp/out/relnotes.md" | grep -Fxq ''
sed 1,2d "$relnotes_tmp/out/relnotes.md"
rm -r "$relnotes_tmp"

314
build_tools/release.sh Executable file
View File

@@ -0,0 +1,314 @@
#!/bin/sh
{
set -ex
version=$1
repository_owner=fish-shell
remote=origin
if [ -n "$2" ]; then
set -u
repository_owner=$2
remote=$3
set +u
[ $# -eq 3 ]
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"
exit 1
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
if ! git -C "$path" diff HEAD --quiet ||
git ls-files --others --exclude-standard | grep .; then
echo >&2 "$0: index and worktree must be clean"
exit 1
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
fi
integration_branch=$(
git for-each-ref --points-at=HEAD 'refs/heads/Integration_*' \
--format='%(refname:strip=2)'
)
[ -n "$integration_branch" ] ||
git merge-base --is-ancestor $remote/master HEAD
sed -n 1p CHANGELOG.rst | grep -q '^fish .*(released .*)$'
sed -n 2p CHANGELOG.rst | grep -q '^===*$'
changelog_title="fish $version (released $(date +'%B %d, %Y'))"
sed -i \
-e "1c$changelog_title" \
-e "2c$(printf %s "$changelog_title" | sed s/./=/g)" \
CHANGELOG.rst
CreateCommit() {
git commit -m "$1
Created by ./build_tools/release.sh $version"
}
sed -i "s/^version = \".*\"/version = \"$1\"/g" Cargo.toml
cargo fetch --offline # bumps the version in Cargo.lock
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
CreateCommit "Release $version"
# Tags must be full objects, not lightweight tags, for
# git_version-gen.sh to work.
git -c "user.signingKey=$committer" \
tag --sign --message="Release $version" $version
git push $remote $version
TIMEOUT=
gh() {
command ${TIMEOUT:+timeout $TIMEOUT} \
gh --repo "$repository_owner/fish-shell" "$@"
}
gh workflow run release.yml --ref="$version" \
--raw-field="version=$version"
run_id=
while [ -z "$run_id" ] && sleep 5
do
run_id=$(gh run list \
--json=databaseId --jq=.[].databaseId \
--workflow=release.yml --limit=1 \
--commit="$(git rev-parse "$version^{commit}")")
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_tar_xz"
do
TIMEOUT=30 gh run watch "$run_id" ||:
sleep 5
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_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/local-tarball/fish-$version/cargo/fish-docs/html" "$fish_site/site/docs/$1"
git -C $fish_site add "site/docs/$1"
}
minor_version=${version%.*}
CopyDocs "$minor_version"
latest_release=$(
releases=$(git tag | grep '^[0-9]*\.[0-9]*\.[0-9]*.*' |
sed $(: "De-prioritize release candidates (1.2.3-rc0)") \
's/-/~/g' | LC_ALL=C sort --version-sort)
printf %s\\n "$releases" | tail -1
)
if [ "$version" = "$latest_release" ]; then
CopyDocs current
fi
rm -rf "$tmpdir"
(
cd "$fish_site"
make
git add -u
git add docs
if git ls-files --others --exclude-standard | grep .; then
exit 1
fi
git commit --message="$(printf %s "\
| Release $version (docs)
|
| Created by ../fish-shell/build_tools/release.sh
" | sed 's,^\s*| \?,,')"
)
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/$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" ]
}
do
sleep 5
done
echo '
{
"environment_ids": ['"$environment_id"'],
"state": "approved",
"comment": "Approved via ./build_tools/release.sh"
}
' |
gh_pending_deployments --method POST --input=-
# Await completion.
gh run watch "$run_id"
while {
! draft=$(gh release view "$version" --json=isDraft --jq=.isDraft) \
|| [ "$draft" = true ]
}
do
sleep 20
done
(
cd "$fish_site"
make new-release
git add -u
git add docs
if git ls-files --others --exclude-standard | grep .; then
exit 1
fi
git commit --message="$(printf %s "\
| Release $version (release list update)
|
| Created by ../fish-shell/build_tools/release.sh
" | 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 "$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 {
changelog=$(cat - CHANGELOG.rst <<EOF
fish ?.?.? (released ???)
=========================
EOF
)
printf %s\\n "$changelog" >CHANGELOG.rst
git add CHANGELOG.rst
CreateCommit "start new cycle"
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

@@ -1,124 +0,0 @@
#!/usr/bin/env fish
#
# This runs Python files, fish scripts (*.fish), and Rust files
# through their respective code formatting programs.
#
# `--all`: Format all eligible files instead of the ones specified as arguments.
# `--check`: Instead of reformatting, fail if a file is not formatted correctly.
# `--force`: Proceed without asking if uncommitted changes are detected.
# Only relevant if `--all` is specified but `--check` is not specified.
set -l fish_files
set -l python_files
set -l rust_files
set -l all no
argparse all check force -- $argv
or exit $status
if set -l -q _flag_all
set all yes
if set -q argv[1]
echo "Unexpected arguments: '$argv'"
exit 1
end
end
set -l repo_root (status dirname)/..
if test $all = yes
if not set -l -q _flag_force; and not set -l -q _flag_check
# Potential for false positives: Not all fish files are formatted, see the `fish_files`
# definition below.
set -l relevant_uncommitted_changes (git status --porcelain --short --untracked-files=all | sed -e 's/^ *[^ ]* *//' | grep -E '.*\.(fish|py|rs)$')
if set -q relevant_uncommitted_changes[1]
for changed_file in $relevant_uncommitted_changes
echo $changed_file
end
echo
echo 'You have uncommitted changes (listed above). Are you sure you want to restyle?'
read -P 'y/N? ' -n1 -l ans
if not string match -qi y -- $ans
exit 1
end
end
end
set fish_files $repo_root/{benchmarks,build_tools,etc,share}/**.fish
set python_files {doc_src,share,tests}/**.py
else
# Format the files specified as arguments.
set -l files $argv
set fish_files (string match -r '^.*\.fish$' -- $files)
set python_files (string match -r '^.*\.py$' -- $files)
set rust_files (string match -r '^.*\.rs$' -- $files)
end
set -l red (set_color red)
set -l green (set_color green)
set -l yellow (set_color yellow)
set -l normal (set_color normal)
if set -q fish_files[1]
if not type -q fish_indent
echo
echo $yellow'Could not find `fish_indent` in `$PATH`.'$normal
exit 127
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
else
fish_indent -w -- $fish_files
end
end
if set -q python_files[1]
if not type -q black
echo
echo $yellow'Please install `black` to style python'$normal
exit 127
end
echo === Running "$green"black"$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
else
black $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
end
else
if set -l -q _flag_all
cargo fmt
else
if set -q rust_files[1]
rustfmt $rust_files
end
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,60 @@
#!/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
# TODO This is copied from .github/actions/install-sphinx/action.yml
uv lock --check --exclude-newer="$(awk -F'"' <uv.lock '/^exclude-newer[[:space:]]*=/ {print $2}')"
update_gh_action() {
repo=$1
version=$(curl -fsS "https://api.github.com/repos/$repo/releases/latest" | jq -r .tag_name)
[ -n "$version" ]
tag_oid=$(git ls-remote "https://github.com/$repo.git" "refs/tags/$version" | cut -f1)
[ -n "$tag_oid" ]
find .github/workflows -name '*.yml' -type f -exec \
sed -i "s|uses: $repo@\S\+\( \+#.*\)\?|\
uses: $repo@$tag_oid # $version, build_tools/update-dependencies.sh|g" {} +
}
update_gh_action actions/checkout
update_gh_action actions/github-script
update_gh_action actions/upload-artifact
update_gh_action actions/download-artifact
update_gh_action docker/login-action
update_gh_action docker/build-push-action
update_gh_action docker/metadata-action
update_gh_action EmbarkStudios/cargo-deny-action
update_gh_action dessant/lock-threads
update_gh_action softprops/action-gh-release
update_gh_action msys2/setup-msys2
updatecli "${@:-apply}"
# Python version constraints may have changed.
uv lock --upgrade --exclude-newer="$(date --date='7 days ago' --iso-8601)"
from_gh() {
repo=$1
path=$2
destination=$3
contents=$(curl -fsS https://raw.githubusercontent.com/"${repo}"/refs/heads/master/"${path}")
printf '%s\n' "$contents" >"$destination"
}
from_gh ridiculousfish/widecharwidth widechar_width.rs crates/widecharwidth/src/widechar_width.rs
from_gh ridiculousfish/littlecheck littlecheck/littlecheck.py tests/littlecheck.py
from_gh catppuccin/fish themes/catppuccin-frappe.theme share/themes/catppuccin-frappe.theme
from_gh catppuccin/fish themes/catppuccin-macchiato.theme share/themes/catppuccin-macchiato.theme
from_gh catppuccin/fish themes/catppuccin-mocha.theme share/themes/catppuccin-mocha.theme
# Update Cargo.lock
cargo update
# Update Cargo.toml and Cargo.lock
cargo +nightly -Zunstable-options update --breaking

View File

@@ -1,49 +1,42 @@
#!/usr/bin/env fish
# Updates the files used for gettext translations.
# By default, the whole xgettext, msgmerge, msgfmt pipeline runs,
# By default, the whole xgettext + msgmerge pipeline runs,
# which extracts the messages from the source files into $template_file,
# updates the PO files for each language from that
# (changed line numbers, added messages, removed messages),
# and finally generates a machine-readable MO file for each language,
# which is stored in share/locale/$LANG/LC_MESSAGES/fish.mo (relative to the repo root).
# and updates the PO files for each language from that.
#
# Use cases:
# For developers:
# - Run with args `--no-mo` to update all PO files after making changes to Rust/fish
# sources.
# - Run with no args to update all PO files after making changes to Rust/fish sources.
# For translators:
# - Run with `--no-mo` first, to ensure that the strings you are translating are up to date.
# - 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
# 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 -g tmpdir
set -l po_dir $build_tools/../po
set -l po_dir $build_tools/../localization/po
set -l extract
set -l po
set -l mo
argparse --exclusive 'no-mo,only-mo,dry-run' no-mo only-mo dry-run use-existing-template= -- $argv
argparse dry-run use-existing-template= -- $argv
or exit $status
if test -z $argv[1]
@@ -52,8 +45,8 @@ if test -z $argv[1]
else
set -l po_dir_id (stat --format='%d:%i' -- $po_dir)
for arg in $argv
set -l arg_dir_id (stat --format='%d:%i' -- (dirname $arg))
if test $po_dir_id != $arg_dir_id
set -l arg_dir_id (stat --format='%d:%i' -- (dirname $arg) 2>/dev/null)
if test $po_dir_id != "$arg_dir_id"
echo "Argument $arg is not a file in the directory $(realpath $po_dir)."
echo "Non-option arguments must specify paths to files in this directory."
echo ""
@@ -63,7 +56,7 @@ else
echo "So valid filenames are of the shape 'll.po' or 'll_CC.po'."
exit 1
end
if not basename $arg | grep -qE '^[a-z]{2}(_[A-Z]{2})?\.po$'
if not basename $arg | grep -qE '^[a-z]{2,3}(_[A-Z]{2})?\.po$'
echo "Filename does not match the expected format ('ll.po' or 'll_CC.po')."
exit 1
end
@@ -71,14 +64,6 @@ else
set -g po_files $argv
end
if set -l --query _flag_no_mo
set -l --erase mo
end
if set -l --query _flag_only_mo
set -l --erase extract
set -l --erase po
end
set -g template_file (mktemp)
# Protect from externally set $tmpdir leaking into this script.
set -g tmpdir
@@ -105,41 +90,67 @@ 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)
# On a dry-run, we do not update the MO files.
set -l --erase mo
# Ensure tmpdir has the same initial state as the po dir.
cp -r $po_dir/* $tmpdir
end
# This is used to identify lines which should be set here via $header_lines.
# Make sure that this prefix does not appear elsewhere in the file and only contains characters
# without special meaning in a sed pattern.
set -g header_prefix "# fish-note-sections: "
function print_header
set -l header_lines \
"Translations are divided into sections, each starting with a fish-section-* pseudo-message." \
"The first few sections are more important." \
"Ignore the tier3 sections unless you have a lot of time."
for line in $header_lines
printf '%s%s\n' $header_prefix $line
end
end
function merge_po_files --argument-names template_file po_file
msgmerge --no-wrap --update --no-fuzzy-matching --backup=none --quiet \
$po_file $template_file
or cleanup_exit
set -l new_po_file (mktemp) # TODO Remove on failure.
# Remove obsolete messages instead of keeping them as #~ entries.
and msgattrib --no-wrap --no-obsolete -o $new_po_file $po_file
or cleanup_exit
begin
print_header
# Paste PO file without old header lines.
sed '/^'$header_prefix'/d' $new_po_file
end >$po_file
rm $new_po_file
end
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
msgmerge --no-wrap --update --no-fuzzy-matching --backup=none --quiet $po_file $template_file
and msgattrib --no-wrap --no-obsolete -o $po_file $po_file
or cleanup_exit
else
cp $template_file $po_file
end
end
if set -l --query mo
set -l locale_dir $build_tools/../share/locale
set -l out_dir $locale_dir/(basename $po_file .po)/LC_MESSAGES
mkdir -p $out_dir
msgfmt --check-format --output-file=$out_dir/fish.mo $po_file
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 cleanup_exit
or begin
echo ERROR: translations in localization/po/ are stale. Try running build_tools/update_translations.fish
cleanup_exit
end
end
cleanup_exit

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

@@ -1,86 +1,60 @@
find_program(SPHINX_EXECUTABLE NAMES sphinx-build
HINTS
$ENV{SPHINX_DIR}
PATH_SUFFIXES bin
DOC "Sphinx documentation generator")
include(FeatureSummary)
set(SPHINX_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/doc_src")
set(SPHINX_ROOT_DIR "${CMAKE_CURRENT_BINARY_DIR}/user_doc")
set(SPHINX_BUILD_DIR "${SPHINX_ROOT_DIR}/build")
set(SPHINX_HTML_DIR "${SPHINX_ROOT_DIR}/html")
set(SPHINX_MANPAGE_DIR "${SPHINX_ROOT_DIR}/man")
set(SPHINX_OUTPUT_DIR "${FISH_RUST_BUILD_DIR}/fish-docs")
set(FISH_INDENT_FOR_BUILDING_DOCS "" CACHE FILEPATH "Path to fish_indent executable for building HTML docs")
if(FISH_INDENT_FOR_BUILDING_DOCS)
set(SPHINX_HTML_FISH_INDENT_DEP)
else()
set(FISH_INDENT_FOR_BUILDING_DOCS "${CMAKE_CURRENT_BINARY_DIR}/fish_indent")
set(SPHINX_HTML_FISH_INDENT_DEP fish_indent)
endif()
set(VARS_FOR_CARGO_SPHINX_WRAPPER
"CARGO_TARGET_DIR=${FISH_RUST_BUILD_DIR}"
"FISH_SPHINX=${SPHINX_EXECUTABLE}"
)
# sphinx-docs uses fish_indent for highlighting.
# Prepend the output dir of fish_indent to PATH.
add_custom_target(sphinx-docs
mkdir -p ${SPHINX_HTML_DIR}/_static/
COMMAND env PATH="${CMAKE_BINARY_DIR}:$$PATH"
${SPHINX_EXECUTABLE}
-j auto
-q -b html
-c "${SPHINX_SRC_DIR}"
-d "${SPHINX_ROOT_DIR}/.doctrees-html"
"${SPHINX_SRC_DIR}"
"${SPHINX_HTML_DIR}"
DEPENDS ${SPHINX_SRC_DIR}/fish_indent_lexer.py fish_indent
COMMAND env ${VARS_FOR_CARGO_SPHINX_WRAPPER}
${Rust_CARGO} xtask html-docs --fish-indent=${FISH_INDENT_FOR_BUILDING_DOCS}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
DEPENDS ${SPHINX_HTML_FISH_INDENT_DEP}
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}
-j auto
-q -b man
-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
COMMAND env ${VARS_FOR_CARGO_SPHINX_WRAPPER}
${Rust_CARGO} xtask man-pages
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
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()
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)
configure_file("${SPHINX_SRC_DIR}/conf.py" "${SPHINX_BUILD_DIR}/conf.py" @ONLY)
add_custom_target(doc ALL
DEPENDS sphinx-docs sphinx-manpages)
add_feature_info(Documentation WITH_DOCS "user manual and documentation")
if(WITH_DOCS)
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)
set_property(
TARGET doc sphinx-docs sphinx-manpages
PROPERTY FOLDER cmake/DocTargets
)
endif()

View File

@@ -22,17 +22,17 @@ foreach(_VAR ${_Rust_USER_VARS})
endforeach()
if (NOT DEFINED Rust_CARGO_CACHED)
find_program(Rust_CARGO_CACHED cargo PATHS "$ENV{HOME}/.cargo/bin")
find_program(Rust_CARGO_CACHED cargo PATHS "$ENV{HOME}/.cargo/bin")
endif()
if (NOT EXISTS "${Rust_CARGO_CACHED}")
message(FATAL_ERROR "The cargo executable ${Rust_CARGO_CACHED} was not found. "
"Consider setting `Rust_CARGO_CACHED` to the absolute path of `cargo`."
)
message(FATAL_ERROR "The cargo executable ${Rust_CARGO_CACHED} was not found. "
"Consider setting `Rust_CARGO_CACHED` to the absolute path of `cargo`."
)
endif()
if (NOT DEFINED Rust_COMPILER_CACHED)
find_program(Rust_COMPILER_CACHED rustc PATHS "$ENV{HOME}/.cargo/bin")
find_program(Rust_COMPILER_CACHED rustc PATHS "$ENV{HOME}/.cargo/bin")
endif()
@@ -45,31 +45,31 @@ endif()
# Figure out the target by just using the host target.
# If you want to cross-compile, you'll have to set Rust_CARGO_TARGET
if(NOT Rust_CARGO_TARGET_CACHED)
execute_process(
COMMAND "${Rust_COMPILER_CACHED}" --version --verbose
OUTPUT_VARIABLE _RUSTC_VERSION_RAW
RESULT_VARIABLE _RUSTC_VERSION_RESULT
)
if(NOT ( "${_RUSTC_VERSION_RESULT}" EQUAL "0" ))
message(FATAL_ERROR "Failed to get rustc version.\n"
"${Rust_COMPILER} --version failed with error: `${_RUSTC_VERSION_RESULT}`")
endif()
if (_RUSTC_VERSION_RAW MATCHES "host: ([a-zA-Z0-9_\\-]*)\n")
set(Rust_DEFAULT_HOST_TARGET "${CMAKE_MATCH_1}")
else()
message(FATAL_ERROR
"Failed to parse rustc host target. `rustc --version --verbose` evaluated to:\n${_RUSTC_VERSION_RAW}"
execute_process(
COMMAND "${Rust_COMPILER_CACHED}" --version --verbose
OUTPUT_VARIABLE _RUSTC_VERSION_RAW
RESULT_VARIABLE _RUSTC_VERSION_RESULT
)
endif()
if(CMAKE_CROSSCOMPILING)
message(FATAL_ERROR "CMake is in cross-compiling mode."
"Manually set `Rust_CARGO_TARGET`."
)
endif()
set(Rust_CARGO_TARGET_CACHED "${Rust_DEFAULT_HOST_TARGET}" CACHE STRING "Target triple")
if(NOT ( "${_RUSTC_VERSION_RESULT}" EQUAL "0" ))
message(FATAL_ERROR "Failed to get rustc version.\n"
"${Rust_COMPILER} --version failed with error: `${_RUSTC_VERSION_RESULT}`")
endif()
if (_RUSTC_VERSION_RAW MATCHES "host: ([a-zA-Z0-9_\\-]*)\n")
set(Rust_DEFAULT_HOST_TARGET "${CMAKE_MATCH_1}")
else()
message(FATAL_ERROR
"Failed to parse rustc host target. `rustc --version --verbose` evaluated to:\n${_RUSTC_VERSION_RAW}"
)
endif()
if(CMAKE_CROSSCOMPILING)
message(FATAL_ERROR "CMake is in cross-compiling mode."
"Manually set `Rust_CARGO_TARGET`."
)
endif()
set(Rust_CARGO_TARGET_CACHED "${Rust_DEFAULT_HOST_TARGET}" CACHE STRING "Target triple")
endif()
# Set the input variables as non-cache variables so that the variables are available after

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})
@@ -16,31 +14,37 @@ set(rel_completionsdir "fish/vendor_completions.d")
set(rel_functionsdir "fish/vendor_functions.d")
set(rel_confdir "fish/vendor_conf.d")
set(extra_completionsdir
"${datadir}/${rel_completionsdir}"
CACHE STRING "Path for extra completions")
set(
extra_completionsdir "${datadir}/${rel_completionsdir}"
CACHE STRING "Path for extra completions"
)
set(extra_functionsdir
"${datadir}/${rel_functionsdir}"
CACHE STRING "Path for extra functions")
set(
extra_functionsdir "${datadir}/${rel_functionsdir}"
CACHE STRING "Path for extra functions"
)
set(extra_confdir
"${datadir}/${rel_confdir}"
CACHE STRING "Path for extra configuration")
set(
extra_confdir "${datadir}/${rel_confdir}"
CACHE STRING "Path for extra configuration"
)
# These are the man pages that go in system manpath; all manpages go in the fish-specific manpath.
set(MANUALS ${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/fish.1
${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/fish_indent.1
${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/fish_key_reader.1
${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/fish-doc.1
${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/fish-tutorial.1
${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/fish-language.1
${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/fish-interactive.1
${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/fish-completions.1
${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/fish-prompt-tutorial.1
${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/fish-for-bash-users.1
${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/fish-faq.1)
set(MANUALS
${SPHINX_OUTPUT_DIR}/man/man1/fish.1
${SPHINX_OUTPUT_DIR}/man/man1/fish_indent.1
${SPHINX_OUTPUT_DIR}/man/man1/fish_key_reader.1
${SPHINX_OUTPUT_DIR}/man/man1/fish-doc.1
${SPHINX_OUTPUT_DIR}/man/man1/fish-tutorial.1
${SPHINX_OUTPUT_DIR}/man/man1/fish-language.1
${SPHINX_OUTPUT_DIR}/man/man1/fish-interactive.1
${SPHINX_OUTPUT_DIR}/man/man1/fish-terminal-compatibility.1
${SPHINX_OUTPUT_DIR}/man/man1/fish-completions.1
${SPHINX_OUTPUT_DIR}/man/man1/fish-prompt-tutorial.1
${SPHINX_OUTPUT_DIR}/man/man1/fish-for-bash-users.1
${SPHINX_OUTPUT_DIR}/man/man1/fish-faq.1
)
# Determine which man page we don't want to install.
# On OS X, don't install a man page for open, since we defeat fish's open
@@ -48,128 +52,167 @@ set(MANUALS ${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/fish.1
# On other operating systems, don't install a realpath man page, as they almost all have a realpath
# command, while macOS does not.
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CONDEMNED_PAGE "open.1")
set(CONDEMNED_PAGE "open.1")
else()
set(CONDEMNED_PAGE "realpath.1")
set(CONDEMNED_PAGE "realpath.1")
endif()
# Define a function to help us create directories.
function(FISH_CREATE_DIRS)
foreach(dir ${ARGV})
install(DIRECTORY DESTINATION ${dir})
endforeach(dir)
foreach(dir ${ARGV})
install(DIRECTORY DESTINATION ${dir})
endforeach(dir)
endfunction(FISH_CREATE_DIRS)
function(FISH_TRY_CREATE_DIRS)
foreach(dir ${ARGV})
if(NOT IS_ABSOLUTE ${dir})
set(abs_dir "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${dir}")
else()
set(abs_dir "\$ENV{DESTDIR}${dir}")
endif()
install(SCRIPT CODE "EXECUTE_PROCESS(COMMAND mkdir -p ${abs_dir} OUTPUT_QUIET ERROR_QUIET)
execute_process(COMMAND chmod 755 ${abs_dir} OUTPUT_QUIET ERROR_QUIET)
")
endforeach()
foreach(dir ${ARGV})
if(NOT IS_ABSOLUTE ${dir})
set(abs_dir "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${dir}")
else()
set(abs_dir "\$ENV{DESTDIR}${dir}")
endif()
install(SCRIPT CODE "
EXECUTE_PROCESS(COMMAND mkdir -p ${abs_dir} OUTPUT_QUIET ERROR_QUIET)
execute_process(COMMAND chmod 755 ${abs_dir} OUTPUT_QUIET ERROR_QUIET)
")
endforeach()
endfunction(FISH_TRY_CREATE_DIRS)
install(PROGRAMS ${PROGRAMS}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION ${bindir})
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/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
)
fish_create_dirs(
${rel_datadir}/fish ${rel_datadir}/fish/completions
${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/prompts
${rel_datadir}/fish/themes
)
configure_file(share/__fish_build_paths.fish.in share/__fish_build_paths.fish)
install(FILES share/config.fish
${CMAKE_CURRENT_BINARY_DIR}/share/__fish_build_paths.fish
DESTINATION ${rel_datadir}/fish)
${CMAKE_CURRENT_BINARY_DIR}/share/__fish_build_paths.fish
DESTINATION ${rel_datadir}/fish
)
# Create only the vendor directories inside the prefix (#5029 / #6508)
fish_create_dirs(${rel_datadir}/fish/vendor_completions.d ${rel_datadir}/fish/vendor_functions.d
${rel_datadir}/fish/vendor_conf.d)
fish_create_dirs(
${rel_datadir}/fish/vendor_completions.d
${rel_datadir}/fish/vendor_functions.d
${rel_datadir}/fish/vendor_conf.d
)
fish_try_create_dirs(${rel_datadir}/pkgconfig)
configure_file(fish.pc.in fish.pc.noversion @ONLY)
add_custom_command(OUTPUT fish.pc
add_custom_command(
OUTPUT fish.pc
COMMAND sed '/Version/d' fish.pc.noversion > fish.pc
COMMAND printf "Version: " >> fish.pc
COMMAND cat ${FBVF} >> fish.pc
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build_tools/git_version_gen.sh >> fish.pc
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS CHECK-FISH-BUILD-VERSION-FILE ${CMAKE_CURRENT_BINARY_DIR}/fish.pc.noversion)
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/fish.pc.noversion
)
add_custom_target(build_fish_pc ALL DEPENDS fish.pc)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/fish.pc
DESTINATION ${rel_datadir}/pkgconfig)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/fish.pc
DESTINATION ${rel_datadir}/pkgconfig
)
install(DIRECTORY share/completions/
DESTINATION ${rel_datadir}/fish/completions
FILES_MATCHING PATTERN "*.fish")
install(
DIRECTORY share/completions/
DESTINATION ${rel_datadir}/fish/completions
FILES_MATCHING PATTERN "*.fish"
)
install(DIRECTORY share/functions/
DESTINATION ${rel_datadir}/fish/functions
FILES_MATCHING PATTERN "*.fish")
install(
DIRECTORY share/functions/
DESTINATION ${rel_datadir}/fish/functions
FILES_MATCHING PATTERN "*.fish"
)
install(DIRECTORY share/groff
DESTINATION ${rel_datadir}/fish)
install(
DIRECTORY share/prompts/
DESTINATION ${rel_datadir}/fish/prompts
FILES_MATCHING PATTERN "*.fish"
)
install(
DIRECTORY share/themes/
DESTINATION ${rel_datadir}/fish/themes
FILES_MATCHING PATTERN "*.theme"
)
# 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/
DESTINATION ${rel_datadir}/fish/man/man1
FILES_MATCHING
PATTERN "*.1"
PATTERN ${CONDEMNED_PAGE} EXCLUDE)
install(
DIRECTORY ${SPHINX_OUTPUT_DIR}/man/man1/
DESTINATION ${rel_datadir}/fish/man/man1
FILES_MATCHING
PATTERN "*.1"
PATTERN ${CONDEMNED_PAGE} EXCLUDE
)
install(PROGRAMS share/tools/create_manpage_completions.py share/tools/deroff.py
DESTINATION ${rel_datadir}/fish/tools/)
install(
PROGRAMS share/tools/create_manpage_completions.py
DESTINATION ${rel_datadir}/fish/tools/
)
install(DIRECTORY share/tools/web_config
DESTINATION ${rel_datadir}/fish/tools/
FILES_MATCHING
PATTERN "*.png"
PATTERN "*.css"
PATTERN "*.html"
PATTERN "*.py"
PATTERN "*.js"
PATTERN "*.theme"
PATTERN "*.fish")
install(
DIRECTORY share/tools/web_config
DESTINATION ${rel_datadir}/fish/tools/
FILES_MATCHING
PATTERN "*.png"
PATTERN "*.css"
PATTERN "*.html"
PATTERN "*.py"
PATTERN "*.js"
)
# Building the man pages is optional: if Sphinx isn't installed, they're not built
install(FILES ${MANUALS} DESTINATION ${mandir}/man1/ OPTIONAL)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/user_doc/html/ # Trailing slash is important!
DESTINATION ${docdir} OPTIONAL)
install(
DIRECTORY ${SPHINX_OUTPUT_DIR}/html/ # Trailing slash is important!
DESTINATION ${docdir} OPTIONAL
)
install(FILES CHANGELOG.rst DESTINATION ${docdir})
# These files are built by cmake/gettext.cmake, but using GETTEXT_PROCESS_PO_FILES's
# INSTALL_DESTINATION leads to them being installed as ${lang}.gmo, not fish.mo
# The ${languages} array comes from cmake/gettext.cmake
if(GETTEXT_FOUND)
foreach(lang ${languages})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${lang}.gmo DESTINATION
${CMAKE_INSTALL_LOCALEDIR}/${lang}/LC_MESSAGES/ RENAME fish.mo)
endforeach()
endif()
# Group install targets into a InstallTargets folder
set_property(TARGET build_fish_pc CHECK-FISH-BUILD-VERSION-FILE
PROPERTY FOLDER cmake/InstallTargets)
set_property(
TARGET build_fish_pc
PROPERTY FOLDER cmake/InstallTargets
)
# Make a target build_root that installs into the buildroot directory, for testing.
set(BUILDROOT_DIR ${CMAKE_CURRENT_BINARY_DIR}/buildroot)
add_custom_target(build_root
COMMAND DESTDIR=${BUILDROOT_DIR} ${CMAKE_COMMAND}
--build ${CMAKE_CURRENT_BINARY_DIR} --target install)
add_custom_target(
build_root
COMMAND DESTDIR=${BUILDROOT_DIR} ${CMAKE_COMMAND}
--build ${CMAKE_CURRENT_BINARY_DIR} --target install
)

View File

@@ -24,15 +24,15 @@ add_executable(fish_macapp EXCLUDE_FROM_ALL
# Compute the version. Note this is done at generation time, not build time,
# so cmake must be re-run after version changes for the app to be updated. But
# generally this will be run by make_pkg.sh which always re-runs cmake.
# generally this will be run by make_macos_pkg.sh which always re-runs cmake.
execute_process(
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build_tools/git_version_gen.sh --stdout
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build_tools/git_version_gen.sh
COMMAND cut -d- -f1
OUTPUT_VARIABLE FISH_SHORT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Note CMake appends .app, so the real output name will be fish.app.
# Note CMake appends .app, so the real output name will be fish.app.
# This target does not include the 'base' resource.
set_target_properties(fish_macapp PROPERTIES OUTPUT_NAME "fish")

View File

@@ -1,9 +1,10 @@
set(FISH_USE_SYSTEM_PCRE2 ON CACHE BOOL
"Try to use PCRE2 from the system, instead of the pcre2-sys version")
"Try to use PCRE2 from the system, instead of the pcre2-sys version"
)
if(FISH_USE_SYSTEM_PCRE2)
message(STATUS "Trying to use PCRE2 from the system")
message(STATUS "Trying to use PCRE2 from the system")
else()
message(STATUS "Forcing static build of PCRE2")
set(FISH_PCRE2_BUILDFLAG "PCRE2_SYS_STATIC=1")
message(STATUS "Forcing static build of PCRE2")
set(FISH_PCRE2_BUILDFLAG "PCRE2_SYS_STATIC=1")
endif(FISH_USE_SYSTEM_PCRE2)

View File

@@ -1,15 +1,15 @@
include(FeatureSummary)
include(FindRust)
find_package(Rust REQUIRED)
set(FISH_RUST_BUILD_DIR "${CMAKE_BINARY_DIR}/cargo/build")
set(FISH_RUST_BUILD_DIR "${CMAKE_BINARY_DIR}/cargo")
if(DEFINED ASAN)
list(APPEND CARGO_FLAGS "-Z" "build-std")
list(APPEND FISH_CRATE_FEATURES "asan")
endif()
if(DEFINED TSAN)
list(APPEND CARGO_FLAGS "-Z" "build-std")
list(APPEND FISH_CRATE_FEATURES "tsan")
list(APPEND FISH_CARGO_FEATURES_LIST "tsan")
endif()
if (Rust_CARGO_TARGET)
@@ -19,36 +19,18 @@ 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>")
# Temporary hack to propagate CMake flags/options to build.rs. We need to get CMake to evaluate the
# truthiness of the strings if they are set.
set(CMAKE_WITH_GETTEXT "1")
if(DEFINED WITH_GETTEXT AND NOT "${WITH_GETTEXT}")
set(CMAKE_WITH_GETTEXT "0")
if (NOT DEFINED WITH_MESSAGE_LOCALIZATION) # Don't check for legacy options if the new one is defined, to help bisecting.
if(DEFINED WITH_GETTEXT)
message(FATAL_ERROR "the WITH_GETTEXT option is no longer supported, use -DWITH_MESSAGE_LOCALIZATION=ON|OFF")
endif()
endif()
option(WITH_MESSAGE_LOCALIZATION "Build with localization support. Requires `msgfmt` to work." ON)
# Enable gettext feature unless explicitly disabled.
if(NOT DEFINED WITH_MESSAGE_LOCALIZATION OR "${WITH_MESSAGE_LOCALIZATION}")
list(APPEND FISH_CARGO_FEATURES_LIST "localize-messages")
endif()
if(FISH_CRATE_FEATURES)
set(FEATURES_ARG ${FISH_CRATE_FEATURES})
list(PREPEND FEATURES_ARG "--features")
endif()
add_feature_info(Translation WITH_MESSAGE_LOCALIZATION "message localization (requires gettext)")
# 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}"
# Temporary hack to propagate CMake flags/options to build.rs.
"CMAKE_WITH_GETTEXT=${CMAKE_WITH_GETTEXT}"
# 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}"
"LOCALEDIR=${CMAKE_INSTALL_FULL_LOCALEDIR}"
"CARGO_TARGET_DIR=${FISH_RUST_BUILD_DIR}"
"CARGO_BUILD_RUSTC=${Rust_COMPILER}"
"${FISH_PCRE2_BUILDFLAG}"
"RUSTFLAGS=$ENV{RUSTFLAGS} ${rust_debugflags}"
)
list(JOIN FISH_CARGO_FEATURES_LIST , FISH_CARGO_FEATURES)

View File

@@ -1,29 +1,27 @@
add_executable(fish_test_helper tests/fish_test_helper.c)
FILE(GLOB FISH_CHECKS CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/tests/checks/*.fish)
foreach(CHECK ${FISH_CHECKS})
get_filename_component(CHECK_NAME ${CHECK} NAME)
add_custom_target(
test_${CHECK_NAME}
COMMAND ${CMAKE_SOURCE_DIR}/tests/test_driver.py ${CMAKE_CURRENT_BINARY_DIR}
checks/${CHECK_NAME}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
DEPENDS fish fish_indent fish_key_reader fish_test_helper
USES_TERMINAL
)
get_filename_component(CHECK_NAME ${CHECK} NAME)
add_custom_target(
test_${CHECK_NAME}
COMMAND ${CMAKE_SOURCE_DIR}/tests/test_driver.py ${CMAKE_CURRENT_BINARY_DIR}
checks/${CHECK_NAME}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
DEPENDS fish fish_indent fish_key_reader
USES_TERMINAL
)
endforeach(CHECK)
FILE(GLOB PEXPECTS CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/tests/pexpects/*.py)
foreach(PEXPECT ${PEXPECTS})
get_filename_component(PEXPECT ${PEXPECT} NAME)
add_custom_target(
test_${PEXPECT}
COMMAND ${CMAKE_SOURCE_DIR}/tests/test_driver.py ${CMAKE_CURRENT_BINARY_DIR}
pexpects/${PEXPECT}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
DEPENDS fish fish_indent fish_key_reader fish_test_helper
USES_TERMINAL
)
get_filename_component(PEXPECT ${PEXPECT} NAME)
add_custom_target(
test_${PEXPECT}
COMMAND ${CMAKE_SOURCE_DIR}/tests/test_driver.py ${CMAKE_CURRENT_BINARY_DIR}
pexpects/${PEXPECT}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
DEPENDS fish fish_indent fish_key_reader
USES_TERMINAL
)
endforeach(PEXPECT)
# Rust stuff.
@@ -32,14 +30,20 @@ if(DEFINED ASAN)
# Rust w/ -Zsanitizer=address requires explicitly specifying the --target triple or else linker
# errors pertaining to asan symbols will ensue.
if(NOT DEFINED Rust_CARGO_TARGET)
message(FATAL_ERROR "ASAN requires defining the CMake variable Rust_CARGO_TARGET to the
intended target triple")
message(
FATAL_ERROR
"ASAN requires defining the CMake variable Rust_CARGO_TARGET to the
intended target triple"
)
endif()
endif()
if(DEFINED TSAN)
if(NOT DEFINED Rust_CARGO_TARGET)
message(FATAL_ERROR "TSAN requires defining the CMake variable Rust_CARGO_TARGET to the
intended target triple")
message(
FATAL_ERROR
"TSAN requires defining the CMake variable Rust_CARGO_TARGET to the
intended target triple"
)
endif()
endif()
@@ -55,10 +59,18 @@ endif()
# The top-level test target is "fish_run_tests".
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}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
DEPENDS fish fish_indent fish_key_reader fish_test_helper
USES_TERMINAL
# 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} ${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
USES_TERMINAL
)

View File

@@ -1,55 +0,0 @@
# This file adds commands to manage the FISH-BUILD-VERSION-FILE (hereafter
# FBVF). This file exists in the build directory and is used to populate the
# documentation and also the version string in fish_version.o (printed with
# `echo $version` and also fish --version). The essential idea is that we are
# going to invoke git_version_gen.sh, which will update the
# FISH-BUILD-VERSION-FILE only if it needs to change; this is what makes
# incremental rebuilds fast.
#
# This code is delicate, with the chief subtlety revolving around Ninja. A
# natural and naive approach would tell the generated build system that FBVF is
# a dependency of fish_version.o, and that git_version_gen.sh updates it. Make
# will then invoke the script, check the timestamp on fish_version.o and FBVF,
# see that FBVF is earlier, and then not rebuild fish_version.o. Ninja,
# however, decides what to build up-front and will unconditionally rebuild
# fish_version.o.
#
# To avoid this with Ninja, we want to hook into its 'restat' option which we
# can do through the BYPRODUCTS feature of CMake. See
# https://cmake.org/cmake/help/latest/policy/CMP0058.html
#
# Unfortunately BYPRODUCTS behaves strangely with the Makefile generator: it
# marks FBVF as generated and then CMake itself will `touch` it on every build,
# meaning that using BYPRODUCTS will cause fish_version.o to be rebuilt
# unconditionally with the Makefile generator. Thus we want to use the
# natural-and-naive approach for Makefiles.
# **IMPORTANT** If you touch these build rules, please test both Ninja and
# Makefile generators with both a clean and dirty git tree. Verify that both
# generated build systems rebuild fish when the git tree goes from dirty to
# clean (and vice versa), and verify they do NOT rebuild it when the git tree
# stays the same (incremental builds must be fast).
# Just a handy abbreviation.
set(FBVF FISH-BUILD-VERSION-FILE)
# TODO: find a cleaner way to do this.
IF (${CMAKE_GENERATOR} STREQUAL Ninja)
set(FBVF-OUTPUT fish-build-version-witness.txt)
set(CFBVF-BYPRODUCTS ${FBVF})
else(${CMAKE_GENERATOR} STREQUAL Ninja)
set(FBVF-OUTPUT ${FBVF})
set(CFBVF-BYPRODUCTS)
endif(${CMAKE_GENERATOR} STREQUAL Ninja)
# Set up the version targets
add_custom_target(CHECK-FISH-BUILD-VERSION-FILE
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build_tools/git_version_gen.sh ${CMAKE_CURRENT_BINARY_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
BYPRODUCTS ${CFBVF-BYPRODUCTS})
add_custom_command(OUTPUT ${FBVF-OUTPUT}
DEPENDS CHECK-FISH-BUILD-VERSION-FILE)
# Abbreviation for the target.
set(CFBVF CHECK-FISH-BUILD-VERSION-FILE)

View File

@@ -1,22 +0,0 @@
set(languages de en fr pl pt_BR sv zh_CN)
include(FeatureSummary)
option(WITH_GETTEXT "translate messages if gettext is available" ON)
if(WITH_GETTEXT)
find_package(Gettext)
endif()
add_feature_info(gettext GETTEXT_FOUND "translate messages with gettext")
# Define translations
if(GETTEXT_FOUND)
# Group pofile targets into their own folder, as there's a lot of them.
set(CMAKE_FOLDER pofiles)
foreach(lang ${languages})
# Our translations aren't set up entirely as CMake expects, so installation is done in
# cmake/Install.cmake instead of using INSTALL_DESTINATION
gettext_process_po_files(${lang} ALL
PO_FILES po/${lang}.po)
endforeach()
set(CMAKE_FOLDER)
endif()

512
contrib/debian/changelog Normal file
View File

@@ -0,0 +1,512 @@
fish (4.6.0-1) stable; urgency=medium
* Release of new version 4.6.0.
See https://github.com/fish-shell/fish-shell/releases/tag/4.6.0 for details.
-- Johannes Altmanninger <aclopte@gmail.com> Sat, 28 Mar 2026 12:56:37 +0800
fish (4.5.0-1) stable; urgency=medium
* Release of new version 4.5.0.
See https://github.com/fish-shell/fish-shell/releases/tag/4.5.0 for details.
-- Johannes Altmanninger <aclopte@gmail.com> Tue, 17 Feb 2026 11:32:33 +1100
fish (4.4.0-1) stable; urgency=medium
* Release of new version 4.4.0.
See https://github.com/fish-shell/fish-shell/releases/tag/4.4.0 for details.
-- Johannes Altmanninger <aclopte@gmail.com> Tue, 03 Feb 2026 12:11:51 +1100
fish (4.3.3-1) stable; urgency=medium
* Release of new version 4.3.3.
See https://github.com/fish-shell/fish-shell/releases/tag/4.3.3 for details.
-- Johannes Altmanninger <aclopte@gmail.com> Wed, 07 Jan 2026 08:34:20 +0100
fish (4.3.2-1) stable; urgency=medium
* Release of new version 4.3.2.
See https://github.com/fish-shell/fish-shell/releases/tag/4.3.2 for details.
-- Johannes Altmanninger <aclopte@gmail.com> Tue, 30 Dec 2025 17:21:04 +0100
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,
python3-sphinx,
# Test dependencies
locales-all,
ncurses-base,
man-db | man,
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 gettext command
gettext-base,
# for nroff and preconv
groff-base,
# for terminal definitions
ncurses-base,
# for showing built-in help pages
man-db | man,
# 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
@@ -34,7 +34,7 @@ Copyright: 1990-2007 Free Software Foundation, Inc.
2022 fish-shell contributors
License: GPL-2+
Files: src/wgetopt.rs
Files: crates/wgetopt/src/wgetopt.rs
Copyright: 1989-1994 Free Software Foundation, Inc.
License: LGPL-2+

28
contrib/debian/rules Executable file
View File

@@ -0,0 +1,28 @@
#!/usr/bin/make -f
# -*- makefile -*-
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 $@ --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
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
-unlink vendor
override_dh_auto_test:
cd build && make fish_run_tests

View File

@@ -0,0 +1,3 @@
# The vendor tarball drops a new version of .cargo/config into place. Representing this as a patch
# in automated workflows is tricky, so for our purposes auto-commit is fine.
auto-commit

33
contrib/shell.nix Normal file
View File

@@ -0,0 +1,33 @@
# Environment containing all dependencies needed for
# - building fish,
# - building documentation,
# - running all tests,
# - formatting and checking lints.
#
# enter interactive bash shell:
# nix-shell contrib/shell.nix
#
# using system nixpkgs (otherwise fetches pinned version):
# nix-shell contrib/shell.nix --arg pkgs 'import <nixpkgs> {}'
#
# run single command:
# nix-shell contrib/shell --run "cargo xtask check"
{ pkgs ? (import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/nixos-25.11.tar.gz";
sha256 = "1ia5kjykm9xmrpwbzhbaf4cpwi3yaxr7shl6amj8dajvgbyh2yh4";
}) { }), ... }:
pkgs.mkShell {
buildInputs = [
(pkgs.python3.withPackages (pyPkgs: [ pyPkgs.pexpect ]))
pkgs.cargo
pkgs.clippy
pkgs.cmake
pkgs.gettext
pkgs.pcre2
pkgs.procps # tests use pgrep/pkill
pkgs.ruff
pkgs.rustc
pkgs.rustfmt
pkgs.sphinx
];
}

View File

@@ -0,0 +1,13 @@
[package]
name = "fish-build-helper"
edition.workspace = true
rust-version.workspace = true
version = "0.0.0"
repository.workspace = true
license.workspace = true
[dependencies]
rsconf.workspace = true
[lints]
workspace = true

View File

@@ -0,0 +1,112 @@
use std::{borrow::Cow, env, os::unix::ffi::OsStrExt as _, 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"));
manifest_dir.ancestors().nth(2).unwrap()
}
fn cargo_target_dir() -> Cow<'static, Path> {
option_env!("CARGO_TARGET_DIR")
.map(|d| Cow::Borrowed(Path::new(d)))
.unwrap_or(Cow::Owned(workspace_root().join("target")))
}
pub fn fish_build_dir() -> Cow<'static, Path> {
option_env!("FISH_CMAKE_BINARY_DIR")
.map(|d| Cow::Borrowed(Path::new(d)))
.unwrap_or(cargo_target_dir())
}
pub fn fish_doc_dir() -> Cow<'static, Path> {
cargo_target_dir().join("fish-docs").into()
}
fn l10n_dir() -> Cow<'static, Path> {
workspace_root().join("localization").into()
}
pub fn po_dir() -> Cow<'static, Path> {
l10n_dir().join("po").into()
}
// TODO Move this to rsconf
pub fn rebuild_if_path_changed<P: AsRef<Path>>(path: P) {
rsconf::rebuild_if_path_changed(path.as_ref().to_str().unwrap());
}
// TODO Move this to rsconf
pub fn rebuild_if_paths_changed<P: AsRef<Path>, I: IntoIterator<Item = P>>(paths: I) {
for path in 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"
}
#[macro_export]
macro_rules! as_os_strs {
[ $( $x:expr, )* ] => {
{
use std::ffi::OsStr;
fn as_os_str<S: AsRef<OsStr> + ?Sized>(s: &S) -> &OsStr {
s.as_ref()
}
&[
$( as_os_str($x), )*
]
}
}
}

View File

@@ -0,0 +1,14 @@
[package]
name = "fish-build-man-pages"
edition.workspace = true
rust-version.workspace = true
version = "0.0.0"
repository.workspace = true
license.workspace = true
[build-dependencies]
fish-build-helper.workspace = true
rsconf.workspace = true
[lints]
workspace = true

View File

@@ -0,0 +1,101 @@
use std::path::Path;
use fish_build_helper::{as_os_strs, fish_doc_dir};
fn main() {
let sec1_dir = fish_doc_dir().join("man").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(&sec1_dir);
}
}
fn build_man(sec1_dir: &Path) {
use fish_build_helper::{env_var, workspace_root};
use std::process::{Command, Stdio};
let workspace_root = workspace_root();
let doc_src_dir = workspace_root.join("doc_src");
let doctrees_dir = fish_doc_dir().join(".doctrees-man");
fish_build_helper::rebuild_if_paths_changed([
&workspace_root.join("CHANGELOG.rst"),
&workspace_root.join("CONTRIBUTING.rst"),
&doc_src_dir,
]);
let args = 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",
&doctrees_dir,
&doc_src_dir,
&sec1_dir,
];
rsconf::rebuild_if_env_changed("FISH_BUILD_DOCS");
if env_var("FISH_BUILD_DOCS") == Some("0".to_owned()) {
rsconf::warn!("Skipping man pages because $FISH_BUILD_DOCS is set to 0");
return;
}
// We run sphinx to build the man pages.
// Every error here is fatal so cargo doesn't cache the result
// - 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(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 => {
assert_ne!(
env_var("FISH_BUILD_DOCS"),
Some("1".to_owned()),
"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!(
"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) => {
// Another error - permissions wrong etc
panic!("Error starting sphinx-build to build man pages: {:?}", e);
}
Ok(sphinx_build) => sphinx_build,
};
match sphinx_build.wait_with_output() {
Err(err) => {
panic!(
"Error waiting for sphinx-build to build man pages: {:?}",
err
);
}
Ok(out) => {
if !out.stderr.is_empty() {
rsconf::warn!("sphinx-build: {}", String::from_utf8_lossy(&out.stderr));
}
assert_eq!(&String::from_utf8_lossy(&out.stdout), "");
assert!(
out.status.success(),
"sphinx-build failed to build the man pages."
);
}
}
}

View File

@@ -0,0 +1 @@

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

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

View File

@@ -1,6 +1,7 @@
use std::cmp::Ordering;
use crate::wchar::prelude::*;
use fish_common::assert_sorted_by_name;
use fish_widestring::{L, wstr};
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct Color24 {
@@ -321,8 +322,8 @@ fn term256_color_for_rgb(color: Color24) -> u8 {
#[cfg(test)]
mod tests {
use crate::color::{Color, Color24};
use crate::wchar::prelude::*;
use super::{Color, Color24};
use fish_widestring::L;
#[test]
fn parse() {
@@ -342,9 +343,18 @@ fn parse() {
#[test]
fn parse_rgb() {
assert!(Color::from_wstr(L!("##FF00A0")).is_none());
assert!(Color::from_wstr(L!("#FF00A0")) == Some(Color::from_rgb(0xff, 0x00, 0xa0)));
assert!(Color::from_wstr(L!("FF00A0")) == Some(Color::from_rgb(0xff, 0x00, 0xa0)));
assert!(Color::from_wstr(L!("FAF")) == Some(Color::from_rgb(0xff, 0xaa, 0xff)));
assert_eq!(
Color::from_wstr(L!("#FF00A0")),
Some(Color::from_rgb(0xff, 0x00, 0xa0))
);
assert_eq!(
Color::from_wstr(L!("FF00A0")),
Some(Color::from_rgb(0xff, 0x00, 0xa0))
);
assert_eq!(
Color::from_wstr(L!("FAF")),
Some(Color::from_rgb(0xff, 0xaa, 0xff))
);
}
// Regression test for multiplicative overflow in convert_color.

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

@@ -0,0 +1,21 @@
[package]
name = "fish-common"
edition.workspace = true
rust-version.workspace = true
version = "0.0.0"
repository.workspace = true
license.workspace = true
[dependencies]
bitflags.workspace = true
fish-feature-flags.workspace = true
fish-widestring.workspace = true
libc.workspace = true
nix.workspace = true
[build-dependencies]
fish-build-helper.workspace = true
rsconf.workspace = true
[lints]
workspace = true

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

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

1598
crates/common/src/lib.rs Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,21 @@
[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-widecharwidth.workspace = true
fish-widestring.workspace = true
libc.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());
}

174
crates/fallback/src/lib.rs Normal file
View File

@@ -0,0 +1,174 @@
//! This file only contains fallback implementations of functions which have been found to be missing
//! or broken by the configuration scripts.
//!
//! Many of these functions are more or less broken and incomplete.
use fish_widecharwidth::{WcLookupTable, WcWidth};
use fish_widestring::prelude::*;
use std::cmp;
use std::sync::{
LazyLock,
atomic::{AtomicUsize, Ordering},
};
/// Width of ambiguous East Asian characters and, as of TR11, all private-use characters.
/// 1 is the typical default, but we accept any non-negative override via `$fish_ambiguous_width`.
pub static FISH_AMBIGUOUS_WIDTH: AtomicUsize = AtomicUsize::new(1);
/// Width of emoji characters.
///
/// This must be configurable because the value changed between Unicode 8 and Unicode 9, `wcwidth()`
/// is emoji-unaware, and terminal emulators do different things.
///
/// See issues like [#4539](https://github.com/fish-shell/fish-shell/issues/4539) and <https://github.com/neovim/neovim/issues/4976> for how painful this is.
///
/// Valid values are 1, and 2. 1 is the typical emoji width used in Unicode 8 while some newer
/// terminals use a width of 2 since Unicode 9.
// For some reason, this is declared here and exposed here, but is set in `env_dispatch`.
pub static FISH_EMOJI_WIDTH: AtomicUsize = AtomicUsize::new(2);
static WC_LOOKUP_TABLE: LazyLock<WcLookupTable> = LazyLock::new(WcLookupTable::new);
pub fn fish_wcwidth(c: char) -> Option<usize> {
// Check for VS16 which selects emoji presentation. This "promotes" a character like U+2764
// (width 1) to an emoji (probably width 2). So treat it as width 1 so the sums work. See #2652.
// VS15 selects text presentation.
let variation_selector_16 = '\u{FE0F}';
let variation_selector_15 = '\u{FE0E}';
if c == variation_selector_16 {
return Some(1);
} else if c == variation_selector_15 {
return Some(0);
}
// Check for Emoji_Modifier property. Only the Fitzpatrick modifiers have this, in range
// 1F3FB..1F3FF. This is a hack because such an emoji appearing on its own would be drawn as
// width 2, but that's unlikely to be useful. See #8275.
if ('\u{1F3FB}'..='\u{1F3FF}').contains(&c) {
return Some(0);
}
let width = WC_LOOKUP_TABLE.classify(c);
Some(match width {
WcWidth::NonPrint => return None,
WcWidth::NonCharacter | WcWidth::Combining | WcWidth::Unassigned => 0,
WcWidth::Ambiguous | WcWidth::PrivateUse => {
// TR11: "All private-use characters are by default classified as Ambiguous".
FISH_AMBIGUOUS_WIDTH.load(Ordering::Relaxed)
}
WcWidth::One => 1,
WcWidth::Two => 2,
WcWidth::WidenedIn9 => FISH_EMOJI_WIDTH.load(Ordering::Relaxed),
})
}
pub fn fish_wcswidth(s: &wstr) -> Option<usize> {
fish_wcswidth_canonicalizing(s, std::convert::identity)
}
pub fn fish_wcswidth_canonicalizing(s: &wstr, canonicalize: fn(char) -> char) -> Option<usize> {
let chars = s.chars().map(canonicalize);
// ascii fast path
if chars.clone().all(|c| c.is_ascii() && !c.is_ascii_control()) {
return Some(s.len());
}
let mut result = 0;
for c in chars {
result += fish_wcwidth(c)?;
}
Some(result)
}
pub fn wcscasecmp(lhs: &wstr, rhs: &wstr) -> cmp::Ordering {
wcscasecmp_fuzzy(lhs, rhs, std::convert::identity)
}
/// Compare two wide strings in a case-insensitive fashion
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))
}
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: Chars,
}
impl<Chars: Iterator<Item = char>, ToLowercase: Iterator<Item = char>> Iterator
for ToLowerBuffer<Chars, ToLowercase>
{
type Item = char;
fn next(&mut self) -> Option<Self::Item> {
if let Some(c) = self.current.next() {
return Some(c);
}
self.current = (self.to_lowercase)(self.chars.next()?);
self.current.next()
}
}
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 {
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,
}
}
}
ToLowerBuffer::new(chars, to_lowercase)
}
#[cfg(test)]
mod tests {
use super::wcscasecmp;
use fish_widestring::prelude::*;
use std::cmp::Ordering;
#[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);
// Multi-byte comparison
assert_eq!(wcscasecmp(L!("İ"), L!("i\u{307}")), Ordering::Equal);
assert_eq!(wcscasecmp(L!("ia"), L!("İa")), Ordering::Less);
}
}

View File

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

View File

@@ -0,0 +1,308 @@
//! Flags to enable upcoming features
use fish_widestring::{L, WExt as _, wstr};
use std::{
cell::RefCell,
sync::atomic::{AtomicBool, Ordering},
};
/// The list of flags.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum FeatureFlag {
/// Whether ^ is supported for stderr redirection.
StderrNoCaret,
/// Whether ? is supported as a glob.
QuestionMarkNoGlob,
/// Whether string replace -r double-unescapes the replacement.
StringReplaceBackslash,
/// Whether "&" is not-special if followed by a word character.
AmpersandNoBgInToken,
/// Whether "%self" is expanded to fish's pid
RemovePercentSelf,
/// Remove `test`'s one and zero arg mode (make `test -n` return false etc)
TestRequireArg,
/// Whether to write OSC 133 prompt markers
MarkPrompt,
/// Do not look up $TERM in terminfo database.
IgnoreTerminfo,
/// Whether we are allowed to query the TTY for extra information.
QueryTerm,
/// Do not try to work around incompatible terminal.
OmitTermWorkarounds,
}
struct Features {
// Values for the flags.
// These are atomic to "fix" a race reported by tsan where tests of feature flags and other
// tests which use them conceptually race.
values: [AtomicBool; METADATA.len()],
}
/// Metadata about feature flags.
pub struct FeatureMetadata {
/// The flag itself.
pub flag: FeatureFlag,
/// User-presentable short name of the feature flag.
pub name: &'static wstr,
/// Comma-separated list of feature groups.
pub groups: &'static wstr,
/// User-presentable description of the feature flag.
pub description: &'static wstr,
/// Default flag value.
default_value: bool,
/// Whether the value can still be changed or not.
read_only: bool,
}
/// The metadata, indexed by flag.
pub const METADATA: &[FeatureMetadata] = &[
FeatureMetadata {
flag: FeatureFlag::StderrNoCaret,
name: L!("stderr-nocaret"),
groups: L!("3.0"),
description: L!("^ no longer redirects stderr (historical, can no longer be changed)"),
default_value: true,
read_only: true,
},
FeatureMetadata {
flag: FeatureFlag::QuestionMarkNoGlob,
name: L!("qmark-noglob"),
groups: L!("3.0"),
description: L!("? no longer globs"),
default_value: true,
read_only: false,
},
FeatureMetadata {
flag: FeatureFlag::StringReplaceBackslash,
name: L!("regex-easyesc"),
groups: L!("3.1"),
description: L!("string replace -r needs fewer \\'s"),
default_value: true,
read_only: false,
},
FeatureMetadata {
flag: FeatureFlag::AmpersandNoBgInToken,
name: L!("ampersand-nobg-in-token"),
groups: L!("3.4"),
description: L!("& only backgrounds if followed by a separator"),
default_value: true,
read_only: false,
},
FeatureMetadata {
flag: FeatureFlag::RemovePercentSelf,
name: L!("remove-percent-self"),
groups: L!("4.0"),
description: L!("%self is no longer expanded (use $fish_pid)"),
default_value: false,
read_only: false,
},
FeatureMetadata {
flag: FeatureFlag::TestRequireArg,
name: L!("test-require-arg"),
groups: L!("4.0"),
description: L!("builtin test requires an argument"),
default_value: false,
read_only: false,
},
FeatureMetadata {
flag: FeatureFlag::MarkPrompt,
name: L!("mark-prompt"),
groups: L!("4.0"),
description: L!("write OSC 133 prompt markers to the terminal"),
default_value: true,
read_only: false,
},
FeatureMetadata {
flag: FeatureFlag::IgnoreTerminfo,
name: L!("ignore-terminfo"),
groups: L!("4.1"),
description: L!(
"do not look up $TERM in terminfo database (historical, can no longer be changed)"
),
default_value: true,
read_only: true,
},
FeatureMetadata {
flag: FeatureFlag::QueryTerm,
name: L!("query-term"),
groups: L!("4.1"),
description: L!("query the TTY to enable extra functionality"),
default_value: true,
read_only: false,
},
FeatureMetadata {
flag: FeatureFlag::OmitTermWorkarounds,
name: L!("omit-term-workarounds"),
groups: L!("4.3"),
description: L!("skip workarounds for incompatible terminals"),
default_value: false,
read_only: false,
},
];
thread_local!(
static LOCAL_OVERRIDE_STACK: RefCell<Vec<(FeatureFlag, bool)>> =
const { RefCell::new(Vec::new()) };
);
/// The singleton shared feature set.
static FEATURES: Features = Features::new();
/// Perform a feature test on the global set of features.
pub fn feature_test(flag: FeatureFlag) -> bool {
if let Some(value) = LOCAL_OVERRIDE_STACK.with(|stack| {
for &(overridden_feature, value) in stack.borrow().iter().rev() {
if flag == overridden_feature {
return Some(value);
}
}
None
}) {
return value;
}
FEATURES.test(flag)
}
/// Parses a comma-separated feature-flag string, updating ourselves with the values.
/// Feature names or group names may be prefixed with "no-" to disable them.
/// The special group name "all" may be used for those who like to live on the edge.
/// Unknown features are silently ignored.
pub fn set_from_string<'a>(str: impl Into<&'a wstr>) {
FEATURES.set_from_string(str.into());
}
impl Features {
const fn new() -> Self {
// TODO: feature(const_array): use std::array::from_fn()
use std::mem::{MaybeUninit, transmute};
let values = {
let mut data: [MaybeUninit<AtomicBool>; METADATA.len()] =
[const { MaybeUninit::uninit() }; METADATA.len()];
let mut i = 0;
while i < METADATA.len() {
data[i].write(AtomicBool::new(METADATA[i].default_value));
i += 1;
}
// SAFETY: `data` is guaranteed initialized by the loop
unsafe {
transmute::<[MaybeUninit<AtomicBool>; METADATA.len()], [AtomicBool; METADATA.len()]>(
data,
)
}
};
Features { values }
}
fn test(&self, flag: FeatureFlag) -> bool {
self.values[flag as usize].load(Ordering::SeqCst)
}
fn set(&self, flag: FeatureFlag, value: bool) {
self.values[flag as usize].store(value, Ordering::SeqCst);
}
fn set_from_string(&self, str: &wstr) {
for entry in str.split(',') {
let entry = entry.trim();
if entry.is_empty() {
continue;
}
// A "no-" prefix inverts the sense.
let (name, value) = match entry.strip_prefix("no-") {
Some(suffix) => (suffix, false),
None => (entry, true),
};
// Look for a feature with this name. If we don't find it, assume it's a group name and set
// all features whose group contain it. Do nothing even if the string is unrecognized; this
// is to allow uniform invocations of fish (e.g. disable a feature that is only present in
// future versions).
// The special name 'all' may be used for those who like to live on the edge.
if let Some(md) = METADATA.iter().find(|md| md.name == name) {
// Only change it if it's not read-only.
// Don't complain if it is, this is typically set from a variable.
if !md.read_only {
self.set(md.flag, value);
}
} else {
for md in METADATA {
if (md.groups == name || name == L!("all")) && !md.read_only {
self.set(md.flag, value);
}
}
}
}
}
}
/// Run code with a feature overridden.
/// This should only be used in tests.
pub fn with_overridden_feature(flag: FeatureFlag, value: bool, test_fn: impl FnOnce()) {
LOCAL_OVERRIDE_STACK.with(|stack| {
stack.borrow_mut().push((flag, value));
test_fn();
stack.borrow_mut().pop();
});
}
#[cfg(test)]
mod tests {
use super::{FeatureFlag, Features, METADATA, feature_test, with_overridden_feature};
use fish_widestring::L;
#[test]
fn test_feature_flags() {
let f = Features::new();
f.set_from_string(L!("stderr-nocaret,nonsense"));
assert!(f.test(FeatureFlag::StderrNoCaret));
f.set_from_string(L!("stderr-nocaret,no-stderr-nocaret,nonsense"));
assert!(f.test(FeatureFlag::StderrNoCaret));
// Ensure every metadata is represented once.
let mut counts: [usize; METADATA.len()] = [0; METADATA.len()];
for md in METADATA {
counts[md.flag as usize] += 1;
}
for count in counts {
assert_eq!(count, 1);
}
assert_eq!(
METADATA[FeatureFlag::StderrNoCaret as usize].name,
L!("stderr-nocaret")
);
}
#[test]
fn test_overridden_feature() {
with_overridden_feature(FeatureFlag::QuestionMarkNoGlob, true, || {
assert!(feature_test(FeatureFlag::QuestionMarkNoGlob));
});
with_overridden_feature(FeatureFlag::QuestionMarkNoGlob, false, || {
assert!(!feature_test(FeatureFlag::QuestionMarkNoGlob));
});
with_overridden_feature(FeatureFlag::QuestionMarkNoGlob, false, || {
with_overridden_feature(FeatureFlag::QuestionMarkNoGlob, true, || {
assert!(feature_test(FeatureFlag::QuestionMarkNoGlob));
});
});
}
}

View File

@@ -2,15 +2,20 @@
name = "fish-gettext-extraction"
edition.workspace = true
rust-version.workspace = true
version = "0.0.1"
version = "0.0.0"
repository.workspace = true
license.workspace = true
description = "proc-macro for extracting strings for gettext translation"
[lib]
proc-macro = true
[dependencies]
proc-macro2 = "1.0"
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

@@ -0,0 +1,122 @@
extern crate proc_macro;
use fish_tempfile::random_filename;
use proc_macro::TokenStream;
use std::{ffi::OsString, io::Write as _, path::PathBuf};
fn unescape_multiline_rust_string(s: String) -> String {
if !s.contains('\n') {
return s;
}
let mut unescaped = String::new();
enum State {
Ground,
Escaped,
ContinuationLineLeadingWhitespace,
}
use State::*;
let mut state = Ground;
for c in s.chars() {
match state {
Ground => match c {
'\\' => state = Escaped,
_ => {
unescaped.push(c);
}
},
Escaped => match c {
'\\' => {
unescaped.push('\\');
state = Ground;
}
'\n' => state = ContinuationLineLeadingWhitespace,
_ => panic!("Unsupported escape sequence '\\{c}' in message string '{s}'"),
},
ContinuationLineLeadingWhitespace => match c {
' ' | '\t' => (),
_ => {
unescaped.push(c);
state = Ground;
}
},
}
}
unescaped
}
// 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());
assert!(
!message_string.contains('\n'),
"Gettext strings may not contain unescaped newlines. Unescaped newline found in '{message_string}'"
);
let msgid_without_quotes = &message_string[1..(message_string.len() - 1)];
// We don't want leading or trailing whitespace in our messages.
let trimmed_msgid = msgid_without_quotes.trim();
assert_eq!(msgid_without_quotes, trimmed_msgid);
assert!(!trimmed_msgid.starts_with("\\n"));
assert!(!trimmed_msgid.ends_with("\\n"));
assert!(!trimmed_msgid.starts_with("\\t"));
assert!(!trimmed_msgid.ends_with("\\t"));
// Crude check for format strings. This might result in false positives.
let format_string_annotation = if message_string.contains('%') {
"#, c-format\n"
} else {
""
};
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_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_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(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.");
assert!(
token_trees.next().is_none(),
"Invalid number of tokens passed to gettext_extract. Expected one token, but got more."
);
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.");
assert!(
group_tokens.next().is_none(),
"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

@@ -0,0 +1,19 @@
[package]
name = "fish-gettext-maps"
edition.workspace = true
rust-version.workspace = true
version = "0.0.0"
repository.workspace = true
license.workspace = true
[dependencies]
phf.workspace = true
[build-dependencies]
fish-build-helper.workspace = true
fish-gettext-mo-file-parser.workspace = true
phf_codegen.workspace = true
rsconf.workspace = true
[lints]
workspace = true

View File

@@ -0,0 +1,158 @@
use std::{
ffi::OsStr,
path::{Path, PathBuf},
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::po_dir());
}
fn embed_localizations(cache_dir: &Path) {
use fish_gettext_mo_file_parser::parse_mo_file;
use std::{
fs::File,
io::{BufWriter, Write as _},
};
// 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");
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").output() {
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
rsconf::warn!(
"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(output) => {
let has_check_format =
String::from_utf8_lossy(&output.stdout).contains("--check-format");
for dir_entry_result in fish_build_helper::po_dir().read_dir().unwrap() {
let dir_entry = dir_entry_result.unwrap();
let po_file_path = dir_entry.path();
if po_file_path.extension() != Some(OsStr::new("po")) {
continue;
}
let lang = po_file_path
.file_stem()
.expect("All entries in the po directory must be regular files.");
let language = lang.to_str().unwrap().to_owned();
// Each language gets its own static map for the mapping from message in the source code to
// the localized version.
let map_name = format!("LANG_MAP_{language}");
let cached_map_path = cache_dir.join(lang);
// Include the file containing the map for this language in the main generated file.
writeln!(
&mut localization_map_file,
"include!(\"{}\");",
cached_map_path.display()
)
.unwrap();
// Map from the language identifier to the map containing the localizations for this
// language.
catalogs.entry(language, format!("&{map_name}"));
if let Ok(metadata) = std::fs::metadata(&cached_map_path) {
// Cached map file exists, but might be outdated.
let cached_map_mtime = metadata.modified().unwrap();
let po_mtime = dir_entry.metadata().unwrap().modified().unwrap();
if cached_map_mtime > po_mtime {
// Cached map file is considered up-to-date.
continue;
}
}
// Generate the map file.
// Try to create new MO data and load it into `mo_data`.
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()
};
assert!(
output.status.success(),
"msgfmt failed:\n{}",
String::from_utf8(output.stderr).unwrap()
);
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();
// This file will contain the localization map for the current language.
let mut cached_map_file = File::create(&cached_map_path).unwrap();
let mut single_language_localization_map = phf_codegen::Map::new();
// The values will be written into the source code as is, meaning escape sequences and
// double quotes in the data will be interpreted by the Rust compiler, which is undesirable.
// Converting them to raw strings prevents this. (As long as no input data contains `"###`.)
fn to_raw_str(s: &str) -> String {
assert!(!s.contains("\"###"));
format!("r###\"{s}\"###")
}
for (msgid, msgstr) in language_localizations {
single_language_localization_map.entry(
String::from_utf8(msgid.into()).unwrap(),
to_raw_str(&String::from_utf8(msgstr.into()).unwrap()),
);
}
writeln!(&mut cached_map_file, "#[allow(non_upper_case_globals)]").unwrap();
write!(
&mut cached_map_file,
"static {}: phf::Map<&'static str, &'static str> = {}",
&map_name,
single_language_localization_map.build()
)
.unwrap();
writeln!(&mut cached_map_file, ";").unwrap();
}
}
}
write!(
&mut localization_map_file,
"pub static CATALOGS: phf::Map<&str, &phf::Map<&str, &str>> = {}",
catalogs.build()
)
.unwrap();
writeln!(&mut localization_map_file, ";").unwrap();
}

View File

@@ -0,0 +1 @@
include!(concat!(env!("OUT_DIR"), "/localization_maps.rs"));

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