Fabian Boehm
c7b43b3abf
Truncate builtin arguments on NUL
...
This restores the status quo where builtins are like external commands
in that they can't see anything after a 0x00, because that's the c-style
string terminator.
2023-06-24 21:26:44 +02:00
Fabian Boehm
11c8d9684e
Make NULs work for builtins ( #9859 )
...
* Make NULs work for builtins
This switches from passing a c-string to output_stream_t::append to
passing a proper string.
That means a builtin that prints a NUL no longer crashes with "thread '' panicked
at 'String contained intermediate NUL character: ".
Instead, it will actually handle the NUL, even as an argument.
That means something like
`echo foo\x00bar` will now actually print a NUL instead of truncating
after the `foo` because we passed c-strings around everywhere.
The former is *necessary* for e.g. `string`, the latter is a change
that on the whole makes dealing with NULs easier, but it is a
behavioral change.
To restore the c-string behavior we would have to truncate arguments
at NUL.
See #9739 .
* Use AsRef instead of trait bound
2023-06-22 20:50:22 +02:00
Henrik Hørlück Berg
292f7b2be1
Port builtins/argparse to Rust
2023-06-19 13:45:54 -07:00
ridiculousfish
a09947cd99
Implement builtin set_color in Rust
...
This rewrites the set_color builtin in Rust, restoring italics support in
iTerm2.
2023-06-17 12:14:42 -07:00
ridiculousfish
cdb77a6176
Adopt the Rust test builtin
...
This switches the builtin test implementation from C++ to Rust
2023-05-21 11:50:24 -07:00
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
Xiretza
aab2f660a7
Port math builtin, tinyexpr and wcstod_underscores to Rust
2023-04-16 22:26:46 +02:00
Xiretza
cc744d30c0
io: add FFI wrappers for io_streams_t fields
2023-04-16 22:26:46 +02:00
Xiretza
ba5e1dfb69
builtins: port more error messages
2023-04-16 22:26:46 +02:00
Fabian Boehm
72a32f1a12
Rewrite "builtin" builtin in Rust
...
This is very simple and basically a subset of type.
2023-04-16 11:30:31 +02:00
Fabian Boehm
b65a53a2a6
Rewrite "command" builtin in Rust
...
This is basically a subset of type, so we might as well.
To be clear this is `command -s` and friends, if you do `command grep` that's
handled as a keyword.
One issue here is that we can't get "one path or not" because I don't
know how to translate a maybe_t? Do we need to make it a shared_ptr instead?
2023-04-16 11:27:08 +02:00
Fabian Boehm
662a4740e2
Rewrite the type builtin in rust
2023-04-16 11:27:08 +02:00
Fabian Boehm
7c37b681b2
Expose out_is_redirected to rust
2023-04-16 11:27:08 +02:00
ridiculousfish
15c8f08458
Eliminate to_rust_string_vec
...
This can just use wcstring_list_ffi_t now.
2023-04-15 18:15:37 -07:00
ridiculousfish
dee969bf3a
Introduce wcstring_list_ffi_t
...
wcstring_list_ffi_t is an autocxx-friendly type for passing lists of
strings from C++ to Rust.
2023-04-15 17:53:52 -07:00
Johannes Altmanninger
9983c32a57
Port over builtin exit codes
...
They used to live in common.h but they are mostly used by builtins so I
grudgingly accept the early move.
2023-04-11 09:29:28 +02:00
ridiculousfish
a487b1ecf2
Revert "Revert "Implement builtin_printf in Rust""
...
This reverts commit 9f7e6a6cd1
.
Add additional fixes from code review.
2023-04-06 15:54:09 -07:00
ridiculousfish
9f7e6a6cd1
Revert "Implement builtin_printf in Rust"
...
This reverts PR #9666 . This had outstanding review comments and should
not have been committed.
2023-03-27 22:03:30 -07:00
ridiculousfish
3eb6f2ac74
Implement builtin_printf in Rust
...
This implements builtin_printf in Rust.
2023-03-26 17:40:24 -07:00
Victor Song
ca494778e4
builtins: Port realpath
to Rust
2023-03-12 19:50:35 -07:00
Victor Song
77fe9933e2
builtins: Rewrite pwd
in Rust
...
Closes #9625 .
2023-03-12 15:18:15 -05:00
Clemens Wasser
17c1fa9d64
Port bg builtin to Rust ( #9621 )
...
* bg: Port bg builtin to Rust
2023-02-28 16:42:12 -06:00
Clemens Wasser
6f5be9bae4
block: Port block builtin to Rust
...
Closes #9612 .
2023-02-26 14:16:55 -06:00
Neeraj Jaiswal
f52569a800
abbr: port abbreviation and abbr builtin to rust
2023-02-25 12:24:58 +01:00
Neeraj Jaiswal
3b60bc1de0
contains: port contains builtin to rust
2023-02-22 18:32:27 +01:00
Fabian Boehm
4fd1458d85
Port random to rust
2023-02-19 21:01:46 +01:00
Xiretza
698db6c2a7
builtins: make io_streams_t methods publicly accessible
2023-02-18 18:53:50 +01:00
Neeraj Jaiswal
1adfce18ee
builtins: port return/exit to rust
2023-02-18 18:53:40 +01:00
Xiretza
5a76c7d3b1
Port emit builtin to rust
2023-02-11 15:04:57 +01:00
Xiretza
3ed86fae1c
Port parse_help_only_cmd_opts to Rust
...
This is duplicated for now, since a `&mut [&wstr]` can't be passed over FFI.
2023-02-11 15:04:57 +01:00
Xiretza
a16e2ecb1b
Port echo builtin to Rust
2023-02-07 22:25:47 +01:00
Xiretza
4b85c2f6db
builtin: propagate status from Rust builtins
...
The return type of `builtin_run_rust()` reflects that of C++ builtins.
2023-02-07 22:25:47 +01:00
Johannes Altmanninger
7347c90d1e
builtins.rs: correct error message on unknown option
2023-02-05 12:02:48 +01:00
ridiculousfish
76adfed0e7
Implement builtin_wait in Rust
...
This implements builtin_wait in Rust.
2023-02-02 19:34:48 -07:00