Commit Graph

21721 Commits

Author SHA1 Message Date
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