Commit Graph

17521 Commits

Author SHA1 Message Date
ridiculousfish
10a7de03e2 Implement builtin test in Rust
This implements (but does not yet adopt) builtin test in Rust.
2023-05-21 11:50:24 -07:00
ridiculousfish
a20985c738 Implement FileID in Rust
FileID tracks a File's identity, including its inode, device, and creation and
modification times.
2023-05-21 11:50:24 -07:00
Fabian Boehm
b435fc4539 docs: Add something on variables-as-commands
Specifically point towards the necessary splitting (as always,
separate ahead of time) and the keyword thing.

Fixes #9797
2023-05-21 10:13:54 +02:00
Fabian Boehm
aac30367bf completions/systemctl: Add some missing commands
Fixes #9804
2023-05-21 10:02:26 +02:00
Fabian Boehm
8a9f57112c Fix typo
See https://github.com/fish-shell/fish-site/pull/112
2023-05-18 17:52:51 +02:00
Fabian Boehm
a8d7d9689d docs: Another pass over bind 2023-05-18 10:11:17 +02:00
Fabian Boehm
0c900f74d0 docs: Explain bind --mode in custom bindings 2023-05-18 09:40:03 +02:00
Thomas Klausner
67d1d80f94
When using curses, look for libterminfo as well. (#9794)
Supports NetBSD, where libtinfo isn't available but libterminfo is.
2023-05-16 15:02:11 -05:00
ridiculousfish
dec3976a1f wcstoi: remove the consume_all / consumed_all machinery
Nothing sets these, so they can be removed. Also remove CharsLeft
for the same reason.
2023-05-14 18:38:24 -07:00
ridiculousfish
60d439ab22 Rationalize fish_wcstoi/d and friends
Historically fish has used the functions `fish_wcstol`, `fish_wcstoi`, and
`fish_wcstoul` (and some long long variants) for most integer conversions.
These have semantics that are deliberately different from the libc
functions, such as consuming trailing whitespace, and disallowing `-` in
unsigned versions.

fish has started to drift away from these semantics; some divergence from
C++ has crept in.

Rename the existing `fish_wcs*` functions in Rust to remove the fish
prefix, to express that they attempt to mirror libc semantics; then
introduce `fish_` wrappers which are ported from C++. Also fix some
miscellaneous bugs which have crept in, such as missing range checks.
2023-05-14 18:03:52 -07:00
Fabian Boehm
364f8223b2 pexpects: Skip eval-stack-overflow under ASAN CI 2023-05-12 19:26:10 +02:00
Fabian Boehm
9c5571f14f docs: Reword Combining lists section
This was quite hard to read, and the term "cartesian product" honestly
doesn't help
2023-05-12 18:53:53 +02:00
Fabian Boehm
1ed31579f2 create_manpage_completions: Remove one more groff thing
This came up in the irb man page:

```
.Pp
.It Fl W
Same as `ruby -W' .
.Pp
```
2023-05-12 18:32:08 +02:00
Fabian Boehm
e09f7e4e4d create_manpage_completions: Skip more prefixes
This also skips the 192 git- and 64 npm- pages that

1. have better completions already (for the most part)
2. don't have the same name as a command typically in $PATH

In doing so it reduces the runtime on my system from 9s to 7s. Granted
I have all of these, so that's the best case.
2023-05-12 17:57:29 +02:00
Fabian Boehm
5f672ece84 create_manpage_completions: Also clear already_output_completions
Prevents issues if we try to read a manpage twice - in which case we
could fall back to another parser, creating different results.

Fixes #9787
2023-05-12 16:35:05 +02:00
Fabian Boehm
56743ae770 tests: More slack for ASAN
Disable one and add a sleep to another
2023-05-11 22:14:12 +02:00
Fabian Boehm
8d5a223b39 tests/pexpect: Disable wait.py under SAN CI 2023-05-11 21:42:19 +02:00
Fabian Boehm
055e40467f github actions: Disable pexpect for ASAN for now
This fails basically every commit, just by blowing the time budget.
2023-05-08 19:05:44 +02:00
Fabian Boehm
d855725965 completions/dnf: Use lowercase queryformat
See de9c5c5b59

Fixes #9783
2023-05-08 18:34:02 +02:00
ridiculousfish
e71b75e0e4 Reimplement environment and the environment stack in Rust
This reimplements the environment stack in Rust.
2023-05-07 15:15:56 -07:00
ridiculousfish
8ec1467dda Implement (but do not yet adopt) Environment in Rust
This implements the primary environment stack, and other environments such
as the null and snapshot environments, in Rust. These are used to implement
the push and pop from block scoped commands such as `for` and `begin`, and
also function calls.
2023-05-07 15:15:56 -07:00
ridiculousfish
0681b6b53a Make C++ env_var_t wrap Rust EnvVar
This reimplements C++'s env_var_t to reference a Rust EnvVar.
The C++ env_var_t is now just a thin wrapper.
2023-05-07 15:15:56 -07:00
ridiculousfish
10ee87eb28 Reimplement owning_null_terminated_array in Rust
owning_null_terminated_array is used for environment variables, where we need to
provide envp for child processes. This switches the implementation from C++ to
Rust.

We retain the C++ owning_null_terminated_array_t; it simply wraps the Rust
version now.
2023-05-07 15:15:56 -07:00
ridiculousfish
d4c3c77318 Changelog fix in #9776 2023-05-07 14:34:19 -07:00
Rocka
c21e13e62e completions: fix qdbus Q_NOREPLY method completion 2023-05-07 14:34:03 -07:00
AsukaMinato
e2fdc63cdb
simplify some logic (#9777)
* simplify some logic

* simplify a &*
2023-05-07 08:39:34 -05:00
Mahmoud Al-Qudsi
6a301381c8 Fix compilation on 32-bit non-Linux platforms
The `u64::from(buf.f_flag)` was needed in two places. The existing handled macOS
which always has a 32-bit statfs::f_flag, but statvfs::f_flag is an `unsigned
long` which means it needs to be coerced to 64-bits on 32-bit targets.
2023-05-05 19:35:17 -05:00
Mahmoud Al-Qudsi
7d617d7d58 Support cross-compilation w/ detect_bsd() check
Also assert that the code works as expected by asserting the result under known
BSD systems.
2023-05-05 19:03:23 -05:00
Mahmoud Al-Qudsi
220ffaeb65 Add completions for builtin disown
It completes identical to `fg` and `bg` w/ this change. I'm not aware of any
reason why it shouldn't, but feel free to enlighten me if I've missed something.

[ci skip]
2023-05-05 16:08:58 -05:00
Mahmoud Al-Qudsi
d55b65a8d2
Merge pull request #9771 from mqudsi/asan_take5
Rework ASAN integration
2023-05-04 19:43:37 -05:00
Mahmoud Al-Qudsi
4f5cef446a apt.fish: Fix compatibility with newer versions of Debian/Ubuntu
Why drop support for `awk -e`? Linux sees so much needless churn!
2023-05-03 21:27:46 -05:00
Mahmoud Al-Qudsi
8bd5183944 Remove unnecessary UTF-8 decode in is_wsl() 2023-05-02 14:58:44 -05:00
Mahmoud Al-Qudsi
d3abd5d600 Fix inverted is_console_session() logic
The $TERM matching logic was inverted.
2023-05-02 14:55:04 -05:00
Mahmoud Al-Qudsi
c94fce75e5 Add multi-byte test for wcscasecmp()
The lowercase of İ is two bytes, making it a good test candidate.
2023-05-02 14:18:43 -05:00
Mahmoud Al-Qudsi
8668ce336c Fix common::wcscasecmp() for multi-byte lowercase strings 2023-05-02 14:10:12 -05:00
Mahmoud Al-Qudsi
6c8409fd45 Remove unnecessary use of static mut.
Atomic don't need to be `mut` to change since they use interior mutability.
2023-05-02 13:22:39 -05:00
Mahmoud Al-Qudsi
f71a75f3bb Avoid unnecessary vector shift in re::regex_make_anchored()
There's no reason to inject prefix into our newly allocated str after storing
pattern in there. Just allocate with the needed capacity up front and then
insert in the correct order.
2023-05-02 13:15:02 -05:00
Mahmoud Al-Qudsi
40be27c002 Avoid unnecessary vector shift in re::regex_make_anchored()
There's no reason to inject prefix into our newly allocated str after storing
pattern in there. Just allocate with the needed capacity up front and then
insert in the correct order.
2023-05-02 13:13:11 -05:00
Xiretza
1dafb77cda Use bitflags for ParseTreeFlags + ParserTestErrorBits
For consistency with simlar code.
2023-05-02 19:03:51 +02:00
Mahmoud Al-Qudsi
7b0cc33f2e Add LSAN suppressions file
Suppress TLS variable leaks caused by outstanding background threads by
suppressing the ASAN interposer functions. This is possible because because
we're now using use_tls=1.

-----------------------

Direct leak of 64 byte(s) in 2 object(s) allocated from:
    #0 0x5627a1f0cc86 in __interceptor_realloc (/home/runner/work/fish-shell/fish-shell/build/fish_tests+0xb9fc86) (BuildId: da87d16730727369ad5fa46052d10337d6941fa9)
    #1 0x7f04d8800f79 in pthread_getattr_np (/lib/x86_64-linux-gnu/libc.so.6+0x95f79) (BuildId: 69389d485a9793dbe873f0ea2c93e02efaa9aa3d)
    #2 0x5627a1f2f664 in __sanitizer::GetThreadStackTopAndBottom(bool, unsigned long*, unsigned long*) (/home/runner/work/fish-shell/fish-shell/build/fish_tests+0xbc2664) (BuildId: da87d16730727369ad5fa46052d10337d6941fa9)
    #3 0x5627a1f2fb83 in __sanitizer::GetThreadStackAndTls(bool, unsigned long*, unsigned long*, unsigned long*, unsigned long*) (/home/runner/work/fish-shell/fish-shell/build/fish_tests+0xbc2b83) (BuildId: da87d16730727369ad5fa46052d10337d6941fa9)
    #4 0x5627a1f19a0d in __asan::AsanThread::SetThreadStackAndTls(__asan::AsanThread::InitOptions const*) (/home/runner/work/fish-shell/fish-shell/build/fish_tests+0xbaca0d) (BuildId: da87d16730727369ad5fa46052d10337d6941fa9)
    #5 0x5627a1f19615 in __asan::AsanThread::Init(__asan::AsanThread::InitOptions const*) (/home/runner/work/fish-shell/fish-shell/build/fish_tests+0xbac615) (BuildId: da87d16730727369ad5fa46052d10337d6941fa9)
    #6 0x5627a1f19b01 in __asan::AsanThread::ThreadStart(unsigned long long) (/home/runner/work/fish-shell/fish-shell/build/fish_tests+0xbacb01) (BuildId: da87d16730727369ad5fa46052d10337d6941fa9)
    #7 0x7f04d87ffb42  (/lib/x86_64-linux-gnu/libc.so.6+0x94b42) (BuildId: 69389d485a9793dbe873f0ea2c93e02efaa9aa3d)
    #8 0x7f04d88919ff  (/lib/x86_64-linux-gnu/libc.so.6+0x1269ff) (BuildId: 69389d485a9793dbe873f0ea2c93e02efaa9aa3d)
2023-05-02 11:52:42 -05:00
Mahmoud Al-Qudsi
91485c90ca Also free ncurses terminal state when exiting under ASAN 2023-05-02 11:52:42 -05:00
Mahmoud Al-Qudsi
73983bada5 Fix ncurses memory leak in init_curses()
init_curses() is/can be called more than once, in which case the previous
ncurses terminal state is leaked and a new one is allocated.

`del_curterm(cur_term)` is supposed to be called prior to calling `setupterm()`
if `setupterm()` is being used to reinit the default `TERMINAL *cur_term`.
2023-05-02 11:52:42 -05:00
Mahmoud Al-Qudsi
905430629d Use ASAN_OPTIONS fast_unwind_on_malloc=0
This is much slower but gives proper stack traces for calls emanating from code
that wasn't compiled with -fno-omit-frame-pointer.
2023-05-02 11:52:42 -05:00
Mahmoud Al-Qudsi
3651e0e9d8 Actually report ASAN memory leaks
The new asan exit handlers are called to get proper ASAN leak reports (as
calling _exit(0) skips the LSAN reporting stage and exits with success every
time).

They are no-ops when not compiled for ASAN.
2023-05-02 11:52:41 -05:00
Mahmoud Al-Qudsi
c43e040c7c Fix spurious ASAN __cxa_thread_atexit_impl() leaks
Set use_tls back to its default of 1.

This is required to work around an ASAN/LSAN virtualization bug but seems to be
behind the random __cxa_thread_atexit_impl() leaks?
2023-05-02 11:52:41 -05:00
Mahmoud Al-Qudsi
cb368f70ee Fix rust formatting for BSD signal tests 2023-05-02 11:51:56 -05:00
Mahmoud Al-Qudsi
6a3ece6766 Rename Sigchecker to SigChecker to be more idiomatic
Idiomatic rust naming for types is "PascalCase" and this was more "Pascalcase".
2023-05-02 11:29:18 -05:00
Mahmoud Al-Qudsi
55c3df7f41 Fix BSD test failure regression
Nothing major. Introduced in 1ecf9d013d.
2023-05-02 11:23:11 -05:00
Xiretza
afe2e9d8db builtins/printf: avoid string copies by formatting directly to buffer
Closes #9765.
2023-05-01 13:32:44 -05:00
ridiculousfish
4771f25102 Adopt the new Rust signal implementation
This switches the signals implementation from C++ to Rust.
2023-04-30 16:22:57 -07:00