Commit Graph

4971 Commits

Author SHA1 Message Date
Mahmoud Al-Qudsi
34a5443cfd Disable ? as a glob by default
aka, enable the qmark-noglob feature by default.
2024-01-24 21:17:36 -06:00
Fabian Boehm
d74519081e fish_key_reader: Exit after "--version" 2024-01-22 17:18:11 +01:00
Mahmoud Al-Qudsi
977b97a236 Fix assertion failure in FZF keybindings
It seems the logic for calculating the cursor position was not ported correctly,
because the correct place to insert it is at the cursor_pos regardless of
range.start, going by the parameters submitted to the function and the expected
result.
2024-01-21 23:11:20 -06:00
ridiculousfish
ce19f82c19 Fix some clippy warnings 2024-01-21 19:12:33 -08:00
ridiculousfish
9a0728eed6 Stop using num_traits in common.rs
This was a rather silly usage only for estimating string capacity in a rarely
used function. We can do without it.
2024-01-21 18:19:40 -08:00
ridiculousfish
1a42bdf182 Stop using num_traits in builtin return
This can be simplified using the builtin abs() function.
2024-01-21 18:19:40 -08:00
ridiculousfish
66ebd88c44 Stop using num_traits in printf
This wasn't needed at all.
2024-01-21 18:19:40 -08:00
ridiculousfish
26abb97198 Clean up builtin status
This is a cleanup with no user-visible changes. In particular we stop using
num_derive and num_traits.
2024-01-21 18:19:40 -08:00
ridiculousfish
3ce6a5fdd1 Make sets_bind_mode in input an Option<WString>
Previously this used an empty string to mean a sentinel; use an option instead.

Fixes a TODO.
2024-01-21 18:19:40 -08:00
ridiculousfish
b4b5cff3d8 Move input tests into their own module in the tests dir 2024-01-21 18:19:40 -08:00
Johannes Altmanninger
38397734e2 Fix build on OpenSUSE Tumbleweed
Fix a search & replace gone wrong in 1234c77b1 (Support linking against
reentrant-configured curses, 2024-01-21).
2024-01-21 22:22:30 +01:00
Fabian Boehm
89282fd9bc Use CARGO_MANIFEST_DIR to see if we're running from build dir
This allows running a fish built from `cargo build` *and* built via
cmake.

In future, we should make this an optional thing that's removed from
installed builds.
2024-01-21 21:25:05 +01:00
ridiculousfish
3ecd835f58 Clean up some stale comments and restore libc usage in flog_safe
flog_safe should be explicitly async-signal-safe functions; let's avoid
nix in that module for this reason.
2024-01-21 12:03:56 -08:00
PolyMeilex
f3e8272c5d Move from libc read/write to nix read/write
Replace std from_raw_fd/into_raw_fd dance with nix write

Fixup notifyd build
2024-01-21 11:49:40 -08:00
Johannes Altmanninger
1234c77b15 Support linking against reentrant-configured curses
NCurses headers contain this conditional "#define cur_term":

	print  "#elif @cf_cv_enable_reentrant@"
	print  "NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);"
	print  "#define cur_term   NCURSES_PUBLIC_VAR(cur_term())"
	print  "#else"

OpenSUSE Tumbleweed uses this configuration option; For reentrancy, cur_term
is a function.  If the NCurses autoconf variable @NCURSES_WRAP_PREFIX@
is not changed from its default, the function is called _nc_cur_term.

I'm not sure if we have a need to support non-default @NCURSES_WRAP_PREFIX@
but if we do there are various ways;
- search for the symbol with the cur_term suffix
- figure out the prefix based on the local curses installation,
  for example by looking at the header files.

Fixes #10243
2024-01-21 11:26:07 +01:00
Fabian Boehm
f7b541af99 tests/parse_util: Check against localized message
This is run in the current locale, without resetting to en_US.UTF-8
like our integration tests do.

So if you want to check for a specific message you need to check the
localized version.
2024-01-20 12:28:59 +01:00
Himadri Bhattacharjee
e014c981f2 Disallow background operator before && or ||
Co-authored-by: Johannes Altmanninger <aclopte@gmail.com>

Closes #10228
Fixes #9911
2024-01-20 11:32:44 +01:00
Johannes Altmanninger
87d434a98d Improve failure message in test_error_messages 2024-01-20 11:30:13 +01:00
Johannes Altmanninger
c52c03b03c Fix clippy warnings 2024-01-20 11:30:13 +01:00
Johannes Altmanninger
2059e5a171 Allow finding for empty strings with wstr::find
I hit this temporarily in a test; it seems reasonable to allow this.
std::str does too.
2024-01-20 11:30:13 +01:00
Johannes Altmanninger
f356e2d82f Remove redundant fallbacks for installation dir variables
They are redundant as of a5e35abeb (build.rs: Default variables, 2024-01-15).
2024-01-20 10:26:54 +01:00
Fabian Boehm
6be6890fa3 Remove config.h
We don't actually use anything in there anymore.

We keep the WCHAR_T_BITS define in cmake because that's
used to find pcre2.
2024-01-20 08:56:29 +01:00
ridiculousfish
9747ab19d1 Eliminate UVAR_FILE_SET_MTIME_HACK checks
This was previously limited to Linux predicated on the existence
of certain headers, but Rust just exposes those functions unconditionally. So
remove the check and just perform the mtime hack on Linux and Android.
2024-01-19 09:33:33 -08:00
ridiculousfish
70ed4806b4 Use libc O_EXLOCK instead of our own
Rust libc supports O_EXLOCK on supported platforms (BSD/macOS), use that instead
of re-exposing it.
2024-01-19 09:33:33 -08:00
Johannes Altmanninger
7597288c18 test_error_messages: add back missing validation
Make sure to also look for the error part that occurs after the last format
specifier.

Still not great because it won't fail if there's unexpected output at the
beginning or end of the string.
2024-01-19 06:26:31 +01:00
Johannes Altmanninger
800f2414fb Fix regression in split_string_tok()
If there's no more separator we break early but dont update pos, so we go
into the code path that asserts we have reached the limit.
2024-01-18 10:24:40 +01:00
Johannes Altmanninger
fff8e8163b Control-C to simply clear commandline buffer again
Commit 5f849d0 changed control-C to print an inverted ^C and then a newline.

The original motivation was

> In bash if you type something and press ctrl-c then the content of the line
> is preserved and the cursor is moved to a new line. In fish the ctrl-c just
> clears the line. For me the behaviour of bash is a bit better, because it
> allows me to type something then press ctrl-c and I have the typed string
> in the log for further reference.

This sounds like a valid use case in some scenarios but I think that most
abandoned commands are noise. After all, the user erased them. Also, now that
we have undo that can be used to get back a limited set of canceled commands.

I believe the original motivation for existing behavior (in other shells) was
that TERM=dumb does not support erasing characters. Similarly, other shells
like to leave behind other artifacts, for example when using tab-completion
or in their interactive menus but we generally don't.

Control-C is the obvious way to quickly clear a multi-line commandline.
IPython does the same. For the other behavior we have Alt-# although that's
probably not very well-known.

Restore the old Control-C behavior of simply clearing the command line.

Our unused __fish_cancel_commandline still prints the ^C. For folks who
have explicitly bound ^C to that, it's probably better to keep the existing
behavior, so let's leave this one.

Previous attempt at #4713 fizzled.

Closes #10213
2024-01-17 19:54:57 +01:00
Fabian Boehm
34c09b1816 reader: Fix infinite loop for up/downcase bindings
This could *probably* be rewritten nicer with a for-loop

Fixes #10222
2024-01-16 18:13:18 +01:00
Fabian Boehm
5d3aea363e Fix PagerAndSearch not focusing the search field
Boolean confusion

Fixes #10220
2024-01-16 16:39:05 +01:00
ridiculousfish
9bd4b3f878 Adopt count_newlines in additional places 2024-01-14 10:04:55 -08:00
ridiculousfish
4ea222cd34 Improve codegen of line_offset_of_character_at_offset
This function is a hotspot, but it has inefficient codegen:

1. For whatever reason, the chars() iterator of wstr is slower
   than that of a slice. Use the slice.

2. Unnecessary overflow checks were preventing vectorization.

Switch to a more optimized implementation.

This improves aliases benchmark time by about 9%.
2024-01-14 10:04:37 -08:00
Johannes Altmanninger
e8ebeedfca Don't assume libc::c_char is signed
Fixes #10214
2024-01-14 17:12:02 +01:00
Johannes Altmanninger
68d1207d53 Rename flag that fails expansions with command substitutions
SKIP_CMDSUBST does not pass through command substitutions, unlike
SKIP_VARIABLES and SKIP_WILDCARDS.
2024-01-14 13:19:38 +01:00
Johannes Altmanninger
126036c980 Silence a dead code warning
This is still used in commented-out code.
2024-01-14 13:17:59 +01:00
ridiculousfish
0f56db55a2 Correct "fire_exit" event back to "fish_exit"
This was causing fish_exit to not fire, which caused (among other things)
leaking tmux processes from the tests.

This was bisected to eacbd6156d
2024-01-13 15:20:59 -08:00
Mahmoud Al-Qudsi
33f33c5f41 Simplify (and fix?) build.rs HAVE_XXX detection
Since none of the compiles(xxx) calls are to particularly complex code, we can
just use `rsconf` directly to test for the presence of the symbols or headers as
needed.

Note that it seems at least some of the previous detection was not working
correctly; in particular HAVE_PIPE2 was evaluating to false on my WSL install
where pipe2(2) was available (caught because it revealed some compilation errors
in that conditional compilation path after porting).

I kept the cfg names and the tests themselves mostly as-is, though we might want
to change that to conform with the rust convention of lowercase cfg names and
decide whether we want to prefix all these with have_, fish_, or nothing at all.
Also the posix_spawn() test should probably check for the symbol `posix_spawn()`
rather than the header `spawn.h` since we don't use it via the header but rather
via the symbol (but in reality they're almost certainly going to give the same
result).
2024-01-13 15:45:42 -06:00
Mahmoud Al-Qudsi
e02c572738 Fix build error when HAVE_PIPE2 is true
NB: I only encountered this when rewriting the cfg detection, which means that
the previous detection wasn't correct since I have pipe2 on Linux but didn't run
into this build error before.
2024-01-13 15:44:03 -06:00
Mahmoud Al-Qudsi
6e002b6d80 Use cfg directly instead of going through features
Features should be for user-specifiable build configurations but our dynamic,
target-based conditional compilation is something else.
2024-01-13 15:16:47 -06:00
ridiculousfish
8554eb5f80 Further cleanup of FdMonitor 2024-01-13 12:51:36 -08:00
ridiculousfish
d8da79717e Remove some FFI bits from FdMonitor 2024-01-13 12:51:36 -08:00
Mahmoud Al-Qudsi
30f70f02de Feature-detect localeconv_l() presence 2024-01-13 14:21:14 -06:00
Mahmoud Al-Qudsi
195852b562 Use locale::LOCALE_LOCK for all setlocale() calls
I had originally created a safe `set_locale()` wrapper and clippy-disallowed
`libc::setlocale()` but almost all our uses of `libc::setlocale()` are in a loop
where it makes much more sense to just obtain the lock outright then call
`setlocale()` repeatedly rather than lock it in the wrapper function each time.
2024-01-13 13:50:31 -06:00
Mahmoud Al-Qudsi
a138d74688 Fix unused code warning on cannot-be-WSL platforms
No need to use cfg_attr and have to worry about syncing the preconditions for
the cfg_attr with the preconditions for where `slice_contains_slice()` is used
in the codebase, just mark it as `allow(unused)` with a comment.
2024-01-13 13:15:31 -06:00
Fabian Boehm
0a92d03498 Remove L! from sprintf calls
Remove unnecessary L!
2024-01-13 08:52:54 +01:00
Fabian Boehm
fae780d666 clippy
There are a bunch more now that widestrs is gone
2024-01-13 08:52:54 +01:00
Fabian Boehm
09cd7c7ad9 Remove widestring-suffix uses
This removes both the `#[widestrs]` annotation as well as all `"foo"L`
suffixes, and does a `cargo fmt` run on the result
2024-01-13 08:52:54 +01:00
David Adam
ca972f6e0f fix permissions on source file 2024-01-13 11:12:02 +08:00
David Adam
5e8a7fb862 Drop unused C++ fishlib 2024-01-13 11:12:02 +08:00
Johannes Altmanninger
3ae20bdba0 Move fish-rust to project root 2024-01-13 03:58:33 +01:00
David Adam
1683e720a8 Use Rust for executables
Use Rust for executables

Drops the C++ entry points and restructures the Rust package into a
library and three binary crates.

Renames the fish-rust package to fish.

At least on Ubuntu, "fish_indent" is built before "fish".
Make sure export CURSES_LIBRARY_LIST to all binaries to make sure
that "cached-curses-libnames" is populated.

Closes #10198
2024-01-13 03:07:29 +01:00
Johannes Altmanninger
29bd6eebd0 Remove cxx and autocxx
Notably this gets rid of the Cargo target directory inside build directories,
in favor of "target/" at workspace root.
2024-01-07 22:19:56 +01:00
Johannes Altmanninger
102ab2c90d Remove FFI code and C++ files
There's a lot more to remove, like
- cxx/autocxx
- now-unused CMake code
- C++ pcre
- C++ entry points
- remaining mentions of "ffi"
2024-01-07 12:12:09 +01:00
Johannes Altmanninger
ab98566c67 Remove fish_tests
The remaining tests are all obsolete or already ported.
2024-01-07 12:12:09 +01:00
Johannes Altmanninger
77550a2f0d Turn FFI tests into native Rust tests
Keep running tests serially to avoid breaking assumptions.

I think many of these tests can run in parallel and/or don't need test_init().
Use the safe variant everywhere, to get it done faster.
2024-01-07 12:12:09 +01:00
Johannes Altmanninger
c758765503 Port shell_modes
The C++ one is still there but it's only used in dead code.
2024-01-07 12:12:09 +01:00
Johannes Altmanninger
7f110ed4c0 Port fish_key_reader 2024-01-07 00:54:22 +01:00
Johannes Altmanninger
55fd43d86c Port reader 2024-01-07 00:54:22 +01:00
Fabian Boehm
5a77db8353 fish_key_reader: Only name keys if they match the entire sequence
This would misname `\e\x7F` as "backspace":

bind -k backspace 'do something'
bind \e\x7F 'do something'

because it would check if there was any key *in there*.

This was probably meant for continuous mode, but it simply doesn't
work right. It's preferable to not give a key when one would work over
giving one when it's not correct.
2024-01-02 17:27:20 +01:00
David Adam
365027d55d drop obsolete headers 2024-01-02 01:59:02 +08:00
David Adam
3cdca4738a drop unused wildcard module
Some of the definitions in wildcard.h are still used in C++.
2024-01-02 01:59:02 +08:00
David Adam
118dfe776a drop unused path functions 2024-01-02 01:59:02 +08:00
ridiculousfish
8190e3419d Add remaining input FFI bits and port builtin_bind
This implements input and input_common FFI pieces in input_ffi.rs, and
simultaneously ports bind.rs. This was done as a single commit because
builtin_bind would have required a substantial amount of work to use the input
ffi.
2023-12-31 17:17:43 -08:00
ridiculousfish
7ffb62d1d9 Port input.cpp to input.rs
This is not yet adopted.
2023-12-31 15:45:08 -08:00
David Adam
413ba192a0 drop unused code:
fish_tests.cpp:
* comma_join

env.cpp:
* env_get_inherited
* env_get_runtime_path
* check_runtime_path (from tmux)
2023-12-31 21:14:40 +08:00
Shou Ya
b44bdea230 Enable globbing in history-pager
The existing subsequence search commonly returns false positives.
Support globs, to allow searching for disconnected substrings in a better way.

Closes #10143
Closes #10131
2023-12-24 09:08:03 +01:00
Shou Ya
31d157f117 Disable redundant filtering in history pager
Part of #10143
2023-12-24 08:42:20 +01:00
Johannes Altmanninger
2358d4dec8 Fix MoveWordStyle naming convention 2023-12-24 08:42:20 +01:00
Johannes Altmanninger
e194f35a5e Port test_word_motion 2023-12-22 18:10:29 +01:00
Johannes Altmanninger
afe9013b4c Port test_pthread 2023-12-22 18:10:29 +01:00
Johannes Altmanninger
9b1acd5260 Fix regression not ignoring fish_trace when writing title 2023-12-17 17:12:13 +01:00
Johannes Altmanninger
38d52b7835 Port perf_convert_ascii
The "#[bench]" attribute is not allowed in stable Rust, so keep it behind
a new feature flag. Run on nightly Rust with

    $ cargo bench --features=bechmark
    test tests::encoding::bench::bench_convert_ascii ... bench:     125,988 ns/iter (+/- 1,128) = 1040 MB/s
2023-12-10 14:35:43 +01:00
Johannes Altmanninger
f3dd8d306f Port make_autoclose_pipes, fd_event_signaller_t
This allows to get rid of the C++ autoclose_fd_t.
2023-12-10 14:35:43 +01:00
Johannes Altmanninger
f2cd916f65 Remove unused io_data_t structs 2023-12-10 14:35:43 +01:00
Fabian Boehm
eb196c8330 Encode all ENCODE_DIRECT codepoints with encode_direct
forward-port of 09986f5563
2023-12-10 09:29:42 +01:00
Johannes Altmanninger
e380654fff Port test_convert_nulls 2023-12-09 21:35:08 +01:00
Johannes Altmanninger
a31ef0aeaa Delete test_wcstod
This seems to be ported already.
2023-12-09 21:35:08 +01:00
Johannes Altmanninger
a55e95f5fb Port test_env_snapshot 2023-12-09 21:35:08 +01:00
Johannes Altmanninger
fe19cbded0 Port test_wwrite_to_fd 2023-12-09 21:35:08 +01:00
Johannes Altmanninger
d5ccbb6e9c Port test_error_messages 2023-12-09 21:35:08 +01:00
Johannes Altmanninger
f3d1e0d63a Port test_new_parser_errors 2023-12-09 21:35:08 +01:00
Johannes Altmanninger
a7791aab4d Port test_new_parser_ad_hoc 2023-12-09 21:35:08 +01:00
Johannes Altmanninger
d5cfa0e346 Port test_new_parser_ll2 2023-12-09 21:35:08 +01:00
Johannes Altmanninger
af4b8ccc91 Port test_new_parser_fuzzing 2023-12-09 21:35:08 +01:00
Johannes Altmanninger
afddb5dd3e Port test_new_parser_correctness 2023-12-09 21:35:08 +01:00
Johannes Altmanninger
3fab9adab6 Port test_illegal_command_exit_code 2023-12-09 21:35:08 +01:00
Johannes Altmanninger
c74cc71e26 Port rest of test_parser
Most of this is already ported into the "test_parser" test.
2023-12-09 21:35:08 +01:00
Johannes Altmanninger
09b7f3892f Port test_pipes 2023-12-09 21:35:08 +01:00
Johannes Altmanninger
9430d5c542 Port test_wgetopt 2023-12-09 21:35:08 +01:00
Johannes Altmanninger
44a9a873af lru tests don't need porting since we'll drop our implementation 2023-12-09 16:55:20 +01:00
Johannes Altmanninger
749e760cf5 Port debounce tests 2023-12-09 16:48:02 +01:00
Johannes Altmanninger
b28521c3d5 Port fish_indent 2023-12-06 09:59:16 +01:00
Thomas Queiroz
a64324421f Port builtin ulimit
Closes #10121
2023-12-03 11:39:15 +01:00
Johannes Altmanninger
43e2d7b48c Port pager.cpp 2023-12-03 11:02:04 +01:00
Johannes Altmanninger
fadf0f2e5b Port editable_line_t 2023-12-02 20:04:07 +01:00
Johannes Altmanninger
31ad182aa5 Port screen.cpp 2023-12-01 11:59:33 +01:00
ridiculousfish
9b54e243b1 Add FFI bindings to universal notifiers and adopt in input_common
This removes the C++ bits for universal notifiers.
2023-11-26 17:29:53 -08:00
ridiculousfish
0f29e0de2f Remove extract_most_significant_digit
This is now unused.
2023-11-26 17:23:37 -08:00
David Adam
f2f41c6eec drop unused functions and configure checks
Remove the following C++ functions/methods, which have no callers:

common.cpp:
- read_loop
- narrow_string_safe
- escape_string_for_double_quotes
- read_unquoted_escape
- format_size
- format_size_safe
- valid_func_name
- get_executable_path

env.cpp:
- env_stack_t::set_empty
- env_stack_t::set_argv

fallback.cpp:
- fish_mkstemp_cloexec
- flock

proc_util.cpp:
- parse_util_slice_length
- parse_util_argument_is_help

path.cpp:
- path_get_path
- path_as_implicit_cd
- path_apply_working_directory
- path_emit_config_directory_messages
- path_get_data_remoteness
- path_get_config_remoteness
- path_is_valid
- paths_are_same_file

wcstringutil.cpp:
- split_string_tok

wutil.cpp:
- wgetcwd
- wunlink
- wrealpath
- wrename
- file_id_for_path
- fish_wcstoull

Also drop unused configure checks/defines:
- HAVE_FLOCK
2023-11-26 22:35:51 +08:00
ridiculousfish
c1e4a447fd Remove C++ UTF-8 bits
These are no longer used.
2023-11-18 19:21:25 -08:00
ridiculousfish
377ef9786e Remove null_terminated_array C++ bits
These are now unused.
2023-11-18 10:28:52 -08:00