Commit Graph

20684 Commits

Author SHA1 Message Date
Daniel Rainer
3ccce609f0 Add script for updating translations
The purpose of this script is to simplify the translation-related workflow for
both developers and translators. It runs the xgettext, msgmerge, msgfmt pipeline
(or only parts of it, depending on the arguments), either for all languages, or
for one specific one.

Developers can use the script with the `--no-mo` flag to update the PO files for
all languages after changes to the Rust/fish sources, to keep the translations
up to date. Ideally, this would run automatically for all changes, such that
translations are always up to date, but for now, it would already be an
improvement to run this script before releasing a new version of fish.

Translators can use the script in the same way as developers, to get up to date
PO files. To see their translations in action, the script can be called with
`--only-mo`, which takes the current version of the PO files and generates MO
files from them, which get placed in a location which fish (built with `cargo
build`) can detect.
Translators might also find it useful to specify the language they want to work
on as a non-option argument. This argument should be the path to the po file
they want to work on. Specifying non-existing files to work on a new language is
allowed, but the files must be in the po directory and follow the naming
convention.
2025-05-12 22:49:30 +02:00
Daniel Rainer
55752729d6 Fix escaping in translation 2025-05-12 00:51:07 +02:00
Johannes Altmanninger
41dfb5147f Fix typo in set_color test 2025-05-11 22:55:48 +02:00
Johannes Altmanninger
156fa8081c Underline styles for double/dotted/dashed
My phone uses dotted underline to indicate errors; that seems nice, a bit
less aggressive than curly.  Unfortunately dotted underlines are not as well
supported in terminal emulators; sometimes they are barely visible.  So it's
unlikely that we want to use --underline=dotted for an important theme.
Add double and dashed too I guess, even though I don't have a concrete
use case..
2025-05-11 22:18:06 +02:00
Johannes Altmanninger
3081d0157b 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
2025-05-11 22:05:00 +02:00
Johannes Altmanninger
13e4736113 completions/commandline: don't offer deprecated option 2025-05-11 22:00:43 +02:00
Johannes Altmanninger
80e30ac756 Always treat brace at command start as compound statement
For backwards compatibility, fish does not treat "{echo,hello}" as a compound
statement but as brace expansion (effectively "echo hello").  We interpret
"{X...}" as compound statement only if X is whitespace or ';' (which is an
interesting solution).

A brace expansion at the very start of a command 
is usually pointless (space separation is shorter).
The exception are cases where the command name and the first few arguments
share a suffix.

	$ {,1,2,3,4}echo
	1echo 2echo 3echo 4echo

Not sure if anyone uses anything like that.  Perhaps we want to trade
compatibility for simplicity. I don't have a strong opinion on this.

Always parse the opening brace as first character of a command token as
compound statement.
Brace expansion can still be used with a trick like: «''{echo,foo}»

Closes #11477
2025-05-11 22:00:43 +02:00
Daniel Rainer
a86a4dfabf Remove source locations from translations
Source locations (file name and line number) where a string originates is not
required by gettext tooling. It can help translators to identify context,
but the value of this is reduced by our lack of context support, meaning that
all occurrences of a string will receive the same translation.
Translators can use `rg` or similar tools to find the source locations.
For further details see this thread:
https://github.com/fish-shell/fish-shell/pull/11463#discussion_r2079378627

The main advantage is that updates to the PO files are now only necessary when
the source strings change, which greatly reduces the diff noise.

A secondary benefit is that the string extraction logic is simplified.
We can now directly extract the strings from fish scripts,
and several issues are fixed alongside, mostly related to quoting.
The regex for extracting implicit messages from fish scripts has been tweaked to
ignore commented-out lines, and properly support lines starting with `and`/`or`.
2025-05-11 21:10:03 +02:00
Daniel Rainer
22bc8e12c9 Fix xgettext implicit regex
The old regex has the problem that it does not handle lines containing any
non-space characters in front of ` complete` (or ` function`), which results in
`string replace` leaving this part in the resulting string.
For example,
`and complete -d "foo"`
would turn into
`andN_ foo`
if passed to
`string replace --regex $regex 'N_ $1'` (where `$regex` is the `$implicit_regex`) variable.
Another issue are commented-out lines.
2025-05-11 21:10:03 +02:00
Peter Ammon
6c23c6f29b Add myself as SECURITY contact and reformat 2025-05-11 11:48:03 -07:00
Josef Andersson
39fd959eea Add initial security policy
Signed-off-by: Josef Andersson <janderssonse@proton.me>
2025-05-11 11:45:15 -07:00
Johannes Altmanninger
cc2ca60baa commandline.rst: deprecate --tokens-raw option
This was added without a use case.  Now there is a use case (#11084) that
needs it to include all tokens which the sister option "--tokens-expanded"
should not do.  The inconsistency is probably not worth it, given that this
"--tokens-raw" use case can be served by a future "read -zal --tokenize-raw".
2025-05-11 12:46:08 +02:00
Johannes Altmanninger
83f74f9332 builtin commandline: fix "-x" spuriously including redirection targets
completions frequently use

	argparse ... -- (commandline -xpc)

The "commandline -xpc" output
contains only string tokens.

A syntactically-valid process ("-p") consistes of only string tokens
and redirection tokens.  We skip all non-string tokens, but we do include
redirection targets, which are always strings.  This is weird, and confuses
completion scripts such as the one above.  Leave out redirection targets too.

Part of #11084
2025-05-11 12:46:08 +02:00
Johannes Altmanninger
58af4fa34c builtin commandline: rename tokenization mode 2025-05-11 12:46:08 +02:00
Daniel Rainer
f23501dbdc Add locale directory to config log 2025-05-11 09:27:35 +02:00
DaiLu Cao
035cd369c2 Supplement Chinese translation
Squashed commit of the following:

commit 23163d40bed2d97c72050990cf15db3944ce2ff0
Author: DaiLu Cao <caodailu@foxmail.com>
Date:   Thu Apr 24 10:11:04 2025 +0800

    Manually review up to line 1055 and modify all Chinese colons ':' to English ':' to prevent potential unknown errors.

commit dca5fb8182b94bffab5034dc5626b2b98d026b6f
Author: DaiLu Cao <caodailu@foxmail.com>
Date:   Thu Apr 17 10:50:13 2025 +0800

    Manually proofread up to 340 lines

commit 4b2d91c1138f3c8dec15b68aeb0510f02e15a776
Author: DaiLu Cao <caodailu@foxmail.com>
Date:   Thu Apr 17 09:50:21 2025 +0800

    use msgfmt check and fix all error

commit e2470d81c01ab7bf46d3d6ffd0291a05d4b38e13
Author: DaiLu Cao <caodailu@foxmail.com>
Date:   Wed Apr 16 11:10:54 2025 +0800

    Fix translation error converting '\\n' to '\\ n' error

commit 7ff970d06ce950aee35e1fb0ec70338f7bd42c1d
Author: DaiLu Cao <caodailu@foxmail.com>
Date:   Wed Apr 16 10:53:38 2025 +0800

    Fix make error, local cargo test completed

commit 018dfa225530a85486903ef58d47f4c358956b0b
Author: DaiLu Cao <caodailu@foxmail.com>
Date:   Fri Apr 11 16:46:36 2025 +0800

    modification of make errors

commit cbebd506a500aecc0669dce7f08422fcfed5615f
Author: DaiLu Cao <caodailu@foxmail.com>
Date:   Fri Apr 11 15:45:01 2025 +0800

    The second modification of make errors are all symbol problems

commit f75c3f7a2a84ffaea4eb642532b5a24da1c9154f
Author: DaiLu Cao <caodailu@foxmail.com>
Date:   Fri Apr 11 15:27:01 2025 +0800

    Re-add Chinese translation, try to solve the problem of make failing

commit 58551be20d261e3466a9e4ede290675f633e94a3
Author: DaiLu Cao <caodailu@foxmail.com>
Date:   Fri Apr 11 15:06:01 2025 +0800

    Supplement Chinese translation
2025-05-08 19:17:46 -07:00
Cuichen Li
3bef4863cf Revert "Work around $PATH issues under WSL (#10506)"
This reverts commit 3374692b91.
2025-05-08 18:35:56 -07:00
Daniel Rainer
2d58cfe4cb Remove line numbers from translation strings
This greatly reduces the number of changes necessary to the PO files when the
Rust/fish source files are updated. (Changes to the line number can be applied
automatically, but this adds a lot of noise to the git history.)

Due to the way we have been extracting Rust strings, differentiation between
the same source string in different contexts has not been possible regardless
of the change.

It seems that duplicate msgid entries are not permitted in PO files, so since we
do not use context to distinguish the strings we extract, there is no way to
have context-/location-dependent translations, so we might as well reduce the
git noise by eliminating line numbers.

Including source locations helps translators with understanding context.
Because we do not distinguish between contexts for a given source string,
this is of limited utility, but keeping file names at least allows to open the
relevant files and search them for the string. This might also be helpful to
identify translations which do not make sense in all context in which they are
used. (Although without adding context support, the only remedy would be to
remove the translation altogether, as far as I can tell.)

For extraction from Rust, additional issues are fixed:
- File name extraction from the grep results now works properly. Previously,
  lines not starting with whitespace resulted in missing or corrupted matches.
  (missing if the source line contains no colon followed by a whitespace,
  corrupted if it does, then the match included the part of the line in front of
  the colon, instead of just the location)
- Only a single source location per string was supported (`head -n1`). The new
  approach using sed does not have this limitation.
2025-05-08 18:15:56 +02:00
David Adam
df591a2e0f fish.spec/Debian packaging: drop man dependency in favour of groff 2025-05-08 22:16:33 +08:00
Johannes Altmanninger
ecefce2ea8 Fix "help printf" on --features=embed-data builds 2025-05-08 11:11:15 +02:00
Peter Ammon
786239d280 Changelog fix for #11465 2025-05-07 18:28:25 -07:00
Carl Andersson
7a668fb17e Unset SYSTEMD_COLORS for systemd completion
Fixes an issue where systemctl and other systemd commands completions are prefixed by ANSI color escape codes
2025-05-07 18:23:51 -07:00
Johannes Altmanninger
bf2f7ee6c0 Respect feature flags in fish_key_reader, fix display of "?" key
Commit daa692a20b (Remove unnecessary escaping for # and ~ inside key name
tokens, 2025-04-01) stopped escaping ? in fish_key_reader output.  This is
generally correct but not if the "qmark-noglob" feature flag is turned off.
Add that back, to be safe.

While at it, pass an environment variable more explicitly in a test.
2025-05-07 17:19:51 +02:00
Johannes Altmanninger
2f762e2da1 completions/cargo: re-use __fish_cargo
Technically this is in the autogenerated part, but I'm not sure how I can
re-generate it with today's cargo.
2025-05-07 17:17:09 +02:00
Benjamin VERGNAUD
11d8b83838 completions/cargo: enforce color off
Signed-off-by: Benjamin VERGNAUD <ben@bvergnaud.fr>
2025-05-06 15:39:39 +02:00
Yuyi Wang
c2eaef7273 Update nix to 0.30.1 (#11458)
After nix updated to 0.30, all functions related to file descriptor accepts impl AsFd, e.g., BorrowedFd. This PR is a minimal update. It tries to use impl AsFd as long as possible, but uses BorrowedFd in some places. Yes it introduces unsafe, but doesn't introduce new unsafe code.
2025-05-06 10:52:54 +02:00
Yuyi Wang
2f278f4bfa Update errno to 0.3.11 2025-05-06 10:44:18 +08:00
Ethan Fredsti
1e61e6492d fixed typo mentioned in issue #11454
I found the same typo mentioned in issue #11454 in this file and proposed the suggested change.
2025-05-04 19:52:06 -07:00
Peter Ammon
c993fd022c Rework fish AST implementation
This merges a large set of changes to the fish AST, with the intention of
making the code simpler.

There's no expected user-visible changes here, except for some minor
changes in the output of `fish_indent --dump-parse-tree`.

Ast parsing is about 50% faster measured via
`cargo +nightly bench  --features=benchmark bench_ast_construction`
and also uses less memory due to some size optimization.

The biggest change is removing the `Type` notion from `Node`. Previously
each Node had an integer type identified with it, like Type::Argument. This
was a relic from C++: types were natural in C++ and we could use LLVM-style
RTTI to identify Nodes, leveraging the fact that C++ has inheritance and so
Type could be at the same location in each Node.

This proved quite awkward in Rust which does not have inheritance. So
instead we switch to a new notion, Kind:

    pub enum Kind<'a> {
        Redirection(&'a Redirection),
        Token(&'a dyn Token),
        Keyword(&'a dyn Keyword),
        VariableAssignment(&'a VariableAssignment),
                ...

and a `&dyn Node` can now return its Kind. Basically leveraging Rust's enum
types.

Interesting lesson about the optimal way to construct ASTs in both
languages.
2025-05-04 19:45:36 -07:00
Peter Ammon
fe10f65587 ast: Box redirections in ArgumentOrRedirection
Redirections are bigger and less common.

Reduces ast size of __fish_complete_gpg.fish by ~28 KB.
2025-05-04 19:38:08 -07:00
Peter Ammon
b98c5ee897 ast: remove NodeSubTraits
This can be implemented directly in Node.
2025-05-04 19:37:25 -07:00
Peter Ammon
9ccff5ad5d ast: Clean up implement_acceptor_for_branch macro
We no longer need the field types to be passed to the macro.
2025-05-04 18:59:13 -07:00
Peter Ammon
55f70cbb6d ast: Clean up more macros
Factor some logic out of macros into a trait, to reduce the macro
complexity.
2025-05-04 18:59:13 -07:00
Peter Ammon
b7005e8378 ast: clean up NodeVisitorMut
This eliminates a bunch of the different functions from NodeVisitorMut.

It also removes the runtime polymorphism - now it's a generic instead of
using &dyn. The reason is that there's only one implementation of
NodeVisitorMut so there's no size savings from polymorphism.
2025-05-04 18:59:13 -07:00
Peter Ammon
1f79d48a48 ast: further macro cleanup 2025-05-04 18:59:13 -07:00
Peter Ammon
e9036774cb ast: simplify visitor_accept_field macro
This is a relic from when we used to support visiting in reverse order; we can
simplify this.
2025-05-04 18:59:13 -07:00
Peter Ammon
2cd185a4f1 ast: Eliminate ConcreteNode trait
Fold this into Node
2025-05-04 18:59:13 -07:00
Peter Ammon
bb92d82c3b ast: remove types 2025-05-04 18:59:13 -07:00
Peter Ammon
f9ba834788 ast: further migration from type to kind 2025-05-04 18:59:13 -07:00
Peter Ammon
d23b8af60d ast: More migration from type to kind 2025-05-04 18:59:13 -07:00
Peter Ammon
82eacb6d50 ast: Switch from type to kind in is_same_node 2025-05-04 18:59:13 -07:00
Peter Ammon
c62b09d5d1 ast: Switch from some types to kinds
Preparing to remove types entirely
2025-05-04 18:59:13 -07:00
Peter Ammon
ccfe949514 ast: make Ast generic
We can parse two different things via Ast:

1. A regular job list
2. A freestanding argument list, as used in `complete --arguments ...`

This second case is specific to one use.

Prior to this commit, we parsed the Ast and then "forgot" what we parsed,
storing a &dyn Node. Then we had to cast it to the right type, and assert,
and etc.

Make Ast generic over the Node type it parsed, and default the Node type to
JobList. This simplifies call sites.
2025-05-04 18:59:13 -07:00
Peter Ammon
ccc75d08f3 ast: remove all of the as_foo functions from Node
Kind has subsumed these.
2025-05-04 18:59:05 -07:00
Peter Ammon
dfac66082a ast: adopt Kind in yet more places 2025-05-04 18:59:05 -07:00
Peter Ammon
9ae01ae00d ast: adopt Kind in more places 2025-05-04 18:59:05 -07:00
Peter Ammon
51784b090d ast: adopt Kind in parse_util_detect_errors_in_ast 2025-05-04 18:59:05 -07:00
Peter Ammon
8115982485 ast: adopt Kind in highlighting 2025-05-04 18:59:05 -07:00
Peter Ammon
d88a656e9e ast: further adoption of Kind 2025-05-04 18:59:05 -07:00
Peter Ammon
d6ee4ec698 ast: Clean up BlockStatementHeader
Make this a real Node.
2025-05-04 18:59:05 -07:00