7040 Commits

Author SHA1 Message Date
Fabian Boehm
25cc01845a string: Fix swapped arguments in error message
Really this could do with a bespoke error, but this'll do for now.
2026-05-29 10:23:59 +02:00
Johannes Altmanninger
bb74d8155e Decode f1-f5 on Linux console
Other things like shift-f1 are not supported on console yet because
Linux sends "CSI 25 ~" which means shift-f3 in urxvt, so there's
a conflict.

Closes #12787
2026-05-29 15:11:59 +08:00
Johannes Altmanninger
9a56334292 Fix signal unit tests on BSD 2026-05-28 16:17:15 +08:00
Peter Ammon
821efeb99c Justify the continued presence of cwd_fd 2026-05-25 22:25:30 -07:00
Peter Ammon
960b96750a Revert "parser: remove unused cwd_fd field"
cwd_fd is crucial to maintain: long-term vision for fish is multiple
threads each with their own CWD with the process-wide CWD used for
nothing at all except transiently (e.g. during fork).

Note this fd is heightenized per open_dir.

This reverts commit 6701b7f6c8.
2026-05-25 22:25:23 -07:00
Henrik Hørlück Berg
79bf53aaa5 Fix Principal topic monitor not initialized panic
Like 1b16d318cc, reproduces with `cargo test test_pthread`

Fix by using stdlib `println!` to avoid interacting with topicMonitor.

Enable `allow-print-in-tests` like with crates/printf, such that there i
no deny-warning.
2026-05-25 18:34:04 -07:00
Henrik Hørlück Berg
8dee291200 Fix threads::init() was not called at startup!
Happens when running `cargo nextest run test_replace_home_directory_with_tilde`, due to process-isolation model.

Backtrace shows:
    EnvStack::set_one(HOME)
    EnvStack::set
    env_dispatch_var_change
    reader_current_data
    reader_data_stack
    assert_is_main_thread
    is_main_thread
    main_thread_id

Fix by using TestEnvironment instead, as this is a unit-test and does
not need anything more.
2026-05-25 18:34:04 -07:00
Henrik Hørlück Berg
8513bb8dc4 Fix Principal topic monitor not initialized
in `test_path_normalize_for_cd`

This happens when running the tests using `cargo nextest run`, where
each test runs in its own process, but does not happen with normal
`cargo test`.

Fix by avoiding eprintf!, which can reach SigChecker::check. Instead use a custom panic-message.
2026-05-25 18:34:04 -07:00
Peter Ammon
8067a5c2c8 Fix some clipplies 2026-05-23 18:45:02 -07:00
Peter Ammon
a2bfd93451 Re-apply test_only_suppress_stderr
Fix some obnoxious output during certain tests.
2026-05-23 18:21:07 -07:00
Peter Ammon
068fa42202 Reimplement test_only_suppress_stderr
This parameter is used to suppress certain verbose errors that are
expected during tests. It was awkwardly threaded through multiple call
sites. Just set it (test only) on Parser.
2026-05-23 18:13:16 -07:00
Nahor
ffaa07d687 Fix unused import warning on non-Linux platforms 2026-05-23 12:04:41 -07:00
Johannes Altmanninger
4ad3c48e3f Fix "cargo doc" error 2026-05-23 16:34:16 +08:00
Johannes Altmanninger
19e0c8b6b9 signal: remove duplicate definition of SIGIOT 2026-05-23 10:31:18 +08:00
Johannes Altmanninger
0f81bb0748 signal: extract function for querying SIGHUP disposition 2026-05-23 10:15:37 +08:00
Johannes Altmanninger
cd75d3d3ca proc: remove obsolete NixSignal alias
See parent commit.
2026-05-23 10:14:09 +08:00
Johannes Altmanninger
8250507a0f Rename Signal to RawSignal to make way for nix Signal 2026-05-23 09:24:21 +08:00
Johannes Altmanninger
2c6b76d5fe Remove redundant uses of std::mem::zeroed()
We already use "inode: 0". 

See 7c2c7f5874 (Use uninit instead of zeroed, 2025-05-19).

Part of #12337
2026-05-23 09:24:21 +08:00
Nahor
954c68c0b1 Fix comment typo (CLO_EXEC -> CLOEXEC)
Closes #12774
2026-05-23 00:59:56 +08:00
Nahor
01b848bbbb Fix formatting of tokenizer.rs
Remove a couple of unhelpful comments that stopped rustfmt for working
(https://github.com/rust-lang/rustfmt/issues/4119)

Part of #12774
2026-05-23 00:59:56 +08:00
Johannes Altmanninger
1284527fac Path component movement to skip all escaped characters
Extend the hack added in ebc140a3ea (Hack path component movement to
skip escaped spaces, 2025-12-16) to apply to all characters, such as
";" that may be part of a file name.
2026-05-18 16:18:52 +08:00
Johannes Altmanninger
ec52a999b3 Use ST (\x1b\\) as OSC terminator
The test balloon in 012007ce7b (Test balloon for ST OSC terminator,
2025-11-18) released in 4.3.0 did not trigger problem reports.
Bravely switch over to the standard ST rather than xterm's BEL.

Closes #12032
2026-05-18 16:18:52 +08:00
Johannes Altmanninger
1f18b9715f Fix repeated tab causing repeated smartcase completion insertion
Doing

	firefox --pro TAB TAB TAB

results in

	firefox --profile --ProfileManager

git-bisect points to 3546ffa3ef (reader
handle_completions(): remove dead filtering code, 2026-01-02)
but that regression has already been fixed by 85e76ba356
(Fix option substr completions not being filtered out, 2026-04-16).

However in between those two commits, the above case has also been
broken by 2f6b1eaaf9 (reader handle_completions(): don't consider
odd replacing completions for common prefix, 2026-01-02)

The first TAB inserts "--profile ", including the trailing space.
However it also shows the completion pager, which means that subsequent
TABs will insert after the space.

The trailing space does not make sense unless we navigate the pager.
Remove it in all cases, to fix this smartcase scenario.

Alternatively, we could start navigating the pager in this case
(and keep the trailing space), but that's probably too inconsistent.
2026-05-14 16:17:41 +08:00
Daniel Rainer
4bdd35b8d1 feat: stop language fallback at English
Treating `en` the same as any other language is problematic as shown by
#12690. When the language precedence list contains entries after
English and we don't treat English specially, a lack of translations in
`en.po` (or a lack of `en.po`, once we delete it) results in
translations into those subsequent languages being displayed, instead of
the msgid, which is in English, and thus preferable.

By truncating the fallback list when we encounter `en`, this problem is
resolved. As it is implemented now, the `en.po` catalog is never used.
This is intended, as the plan is to delete it (#12745). In any case, its
translations are identical to the msgids modulo some fancy quotes.

While at it, also treat `LANGUAGE` values of `C` and `POSIX` as
referring to the English version of the messages.

Fixes #12690

Closes #12747
2026-05-13 19:58:52 +08:00
Johannes Altmanninger
c003ec3795 vi mode: fix "x" command in builtin read
When we push a new reader for builtin read, we use the default
CursorSelectionMode::Exclusive, which is wrong in Vi mode.
Add a haphazard fix for that.
This is very ugly, we should improve this.

Closes #12724
2026-05-13 19:58:52 +08:00
Nahor
01b9fd9e31 complete: remove unescaping of -c/-p values
This removes the need to double-escape the values on the command line
(once for the command line parser, another for the option handling)

This also brings it in line with the implicit case (`complete cmd ...`)

Fixes #12712

Closes #12718
2026-05-13 18:01:48 +08:00
Johannes Altmanninger
ef8e62727c Pass Parser by exclusive reference
As described in
https://github.com/fish-shell/fish-shell/pull/9990#discussion_r1382494440,
prior to 77aeb6a2a8 (Port execution, 2023-10-08), "Parser" was
passed by mutable reference ("parser_t&"), even though operation
context was passed as "const operation_context_t &".  This worked
because C++ doesn't propagate const to pointers by default (see
https://en.cppreference.com/cpp/experimental/propagate_const).

	class operation_context_t {
		std::shared_ptr<parser_t> parser;
		...
	};

So "*ctx->parser" was a "parser_t&", not "const parser_t&".

Rust has stricter const propagation rules which means that const
operation context can't simply hand out a non-const reference to parser.

To be able to port code without changing its structure,
77aeb6a2a8 passed "Parser" by shared reference, using interior
mutability (RefCell) to modify parser fields. This is a bit ugly
(c.f. https://doc.rust-lang.org/std/cell/index.html "interior mutability
is something of a last resort") and means that some borrowing conflicts
are not found at compile time but runtime.

Pass both parser and operation context by exclusive reference, and
remove the interior mutability wrappers from parser's fields.
Since "libdata" is no longer inside a "RefCell", add a "ScopedRefCell"
around "transient_commandline".

The downside is that "ScopeGuard" use can become more intrusive
when we pass "Parser" or "OperationContext" as context (especially
when we use "zelf" since we can't shadow "self"), see
* 2930466d53 (Introduce ScopedCell and ScopedRefCell, 2025-03-15)
* 29ae571afa (Make scoped_push nicer, 2024-12-28)
Avoid this in some cases, specifically when using "ScopedCell" or
"ScopedRefCell". Since "&mut Parser" prevents the "ScopeCell"'s
"ScopeGuard" from holding a shared reference, use an "Rc" to capture
a dynamically-checked reference to the Cell. We could also use raw
pointers instead.

Change "Completer::apply_var_assignments" to return  a block ID, to
avoid the need to return a "zelf" "ScopeGuard".  In future, we could
probably untangle completer and get away with returning a "ScopeGuard"
called "ctx".

Closes #12694
2026-05-11 10:41:14 +08:00
Johannes Altmanninger
638777a4de Remove unused ScopeGuarding trait
As of commit 0441bdc634 (Remove ScopeGuard::commit in favor of drop,
2026-04-30), this trait is empty so there's not much use having it
for now.
2026-05-11 10:41:14 +08:00
Johannes Altmanninger
e25ebf1067 handle_command_not_found: extract constant 2026-05-11 10:24:12 +08:00
Fabian Boehm
5c6acdee09 string shorten: Don't produce output with --quiet
This would've printed stuff in case it didn't have to shorten (which
means it "failed" because the logic is "did something").

Fixes #12732
2026-05-10 11:16:41 +02:00
Nahor
4f539dffaf cd: fix path when trying to cd out of the root directory
Part of #12704
2026-05-05 14:57:42 +08:00
Peter Ammon
fd44c23678 Suppress an annoying warning on nightly
Prior to this commit, running

> cargo +nightly bench --features benchmark --no-run

Reports:
warning: feature `test` is declared but not used
 --> src/lib.rs:1:58
  |
1 | #![cfg_attr(all(nightly, feature = "benchmark"), feature(test))]
  |                                                          ^^^^
  |
  = note: `#[warn(unused_features)]` (part of `#[warn(unused)]`) on by default

Which is a false positive. Allow unused features in this cfg_attr.
2026-05-03 18:03:37 -07:00
Johannes Altmanninger
9370830733 Make profiling API a bit harder to misuse 2026-05-03 20:03:46 +08:00
Johannes Altmanninger
161f31f42b run_1_job: remove code clone for profiling 2026-05-03 20:03:46 +08:00
Johannes Altmanninger
5998421410 Remove obsolete Send/Sync impls for ParsedSource 2026-05-03 20:03:46 +08:00
Johannes Altmanninger
7c5fc85d96 builtin commandline: fix unintuitive clone 2026-05-01 18:35:41 +08:00
Johannes Altmanninger
2f9f46b2a5 eval_node: extract function for getting exec counts 2026-05-01 18:35:41 +08:00
Johannes Altmanninger
4b069b51e7 Remove "get_" prefix from some getters
In C++ we can't have a field and method sharing a name,
but in Rust we can.

For some structs, most getters don't have a "get_", so it's weird
that some do.  Remove the "get_" prefix where it's obvious enough.

While at it, give some related getters better names.
2026-05-01 18:35:41 +08:00
Johannes Altmanninger
398fc17b81 reader: use simpler test environment constructor
A following commit wants to pass parser by exclusive reference,
which disallows passing "parser" as well as "parser.vars()"
in one function call.  This use case also doesn't make sense.
The "OperationContext::test_only_foreground" constructor is used to
inject a special "PwdEnvironment" into the context.  When we don't need
this environment, we can use a regular constructor, which already uses
"parser.vars()".
2026-05-01 18:03:13 +08:00
Johannes Altmanninger
12fa0d8b3d reader: make exec_prompt_cmd a free function
A following commit will pass parser as "&mut Parser".  This would
create aliasing issues in our calls to exec_prompt_cmd; make it a
free function so rustc can understand how the borrows are split.
2026-05-01 18:03:13 +08:00
Johannes Altmanninger
0441bdc634 Remove ScopeGuard::commit in favor of drop
As of commit a296ee085c (Stop returning a value from ScopeGuarding::commit,
2025-03-15) "ScopeGuard::commit()" is equivalent to "drop()".
Let's use that instead.
2026-05-01 18:03:13 +08:00
Johannes Altmanninger
d0e47cf58a Move current_filename out of LibraryData
The ScopedRefCell wrapping from library_data
is used for two things
1. to allow mutating library_data from a &Parser (for this, a RefCell would be enough)
2. to replace "current_filename" for a scope

A following commit wants to pass parser as "&mut Parser", which
voids reason 1.  It will also remove the ScopedRefCell wrapping
from LibraryData because reason 2 alone is not strong enough.  Move
"current_filename" outside of that, next to "current_node" which is
already a ScopedRefCell.  In future we could maybe consolidate them
into one field, like (or even merging with) ScopedData.
2026-05-01 18:03:13 +08:00
Johannes Altmanninger
d35aa3860a Fix weird initial value for internal job ID
InternalJobId(0) aka InternalJobId::default() is treated specially
so it should not be given to a regular job.
2026-05-01 18:03:13 +08:00
Johannes Altmanninger
5971e79c3f Strong type for internal job IDs 2026-05-01 18:03:13 +08:00
Johannes Altmanninger
dad660cda5 Move internal job ID type
Move this type to where its non-default instances are constructed.
2026-05-01 18:03:13 +08:00
Johannes Altmanninger
8328e53050 reader: reduce variable scope 2026-05-01 18:03:13 +08:00
Johannes Altmanninger
4aadeea184 parser: remove unused field
This has been moved to InputData.
2026-05-01 18:03:13 +08:00
Johannes Altmanninger
df5067cc1c parse_execution: remove pipeline node reference from ExecutionContext
Upcoming changes will pass Parser by exclusive reference ("&mut") which
prevents aliasing; let's remove an alias which seems simpler anyway.
2026-05-01 18:03:13 +08:00
Johannes Altmanninger
3d708d6fc1 history: remove redundant argument 2026-05-01 18:03:13 +08:00
Johannes Altmanninger
a564238d82 highlight_and_colorize: remove redundant environment argument
This highlighting function is always called with with an operation
context created from a parser; Since parser.context().vars() is the same
as parser.vars(), we can use the former, reducing the number of aliases.
2026-05-01 18:03:13 +08:00