Commit Graph

1587 Commits

Author SHA1 Message Date
Johannes Altmanninger
dc75367343 builtins set: fix regressions querying undefined indices
This inadvertently regressed in 77aeb6a2a (Port execution, 2023-10-08).

Reference: 77aeb6a2a8 (commitcomment-137509238)
2024-02-07 00:07:47 +01:00
Fabian Boehm
8d71eef1da
Add feature flag to turn off %self (#10262)
This is the last remnant of the old percent expansion.

It has the downsides of it, in that it is annoying to combine with
anything:

```fish
echo %self/foo
```

prints "%self/foo", not fish's pid.

We have introduced $fish_pid in 3.0, which is much easier to use -
just like a variable, because it is one.

If you need backwards-compatibility for < 3.0, you can use the
following shim:

```fish
set -q fish_pid
or set -g fish_pid %self
```

So we introduce a feature-flag called "remove-percent-self" to turn it
off.

"%self" will simply not be special, e.g. `echo %self` will print
"%self".
2024-02-06 22:13:16 +01:00
Fabian Boehm
bdfbdaafcc
Forbid subcommand keywords in variables-as-commands (#10249)
This stops you from doing e.g.

```fish
set pager command less
echo foo | $pager
```

Currently, it would run the command *builtin*, which can only do
`--search` and similar, and would most likely end up printing its own
help.

That means it very very likely won't work, and the code is misguided -
it is trying to defeat function resolution in a way that won't do what
the author wants it to.

The alternative would be to make the command *builtin* execute the
command, *but*

1. That would require rearchitecting and rewriting a bunch of it and
the parser
2. It would be a large footgun, in that `set EDITOR command foo` will
only ever work inside fish, but $EDITOR is also used outside.

I don't want to add a feature that we would immediately have to discourage.
2024-02-06 22:12:55 +01:00
Samuel Collins
508ea59dcd
fix builtin help ignoring redirects (#10276)
* fix builtin help ignoring redirects

* test builtin help redirects
2024-02-02 17:53:50 -06:00
Fabian Boehm
d50b614250 fish_key_reader: fix off-by-one crash 2024-02-01 21:42:55 +01:00
Johannes Altmanninger
54bc196918 Only use fuzzy option completion if there is a leading -
Commit b768b9d3f (Use fuzzy subsequence completion for options names as well,
2024-01-27) allowed completing "oa" to "--foobar", which is a false positive,
especially because it hides other valid completions of non-option arguments.
Let's at least require a leading dash again before completing option names.
2024-01-30 09:09:45 +01:00
Fabian Boehm
3914bbe538 Remove use of env -u in tests
Not available on NetBSD.

We can get by without.
2024-01-27 18:47:38 +01:00
Fabian Boehm
c735dafb98 tests: Exit early if python is missing for littlecheck 2024-01-27 18:47:38 +01:00
Johannes Altmanninger
b768b9d3f5 Use fuzzy subsequence completion for options names as well
Version 2.1.0 introduced subsequence matching for completions but as the
changelog entry mentions, "This feature [...] is not yet implemented for
options (like ``--foobar``)".  Add it. Seems like a strict improvement,
pretty much.
2024-01-27 17:57:48 +01:00
Johannes Altmanninger
29f35d6cdf completion: adopt commandline -x replacing deprecated -o
This gives us more accurate completions because completion scripts get
expanded paths
2024-01-27 09:28:06 +01:00
Johannes Altmanninger
368017905e builtin commandline: -x for expanded tokens, supplanting -o
Issue #10194 reports Cobra completions do

    set -l args (commandline -opc)
    eval $args[1] __complete $args[2..] (commandline -ct | string escape)

The intent behind "eval" is to expand variables and tildes in "$args".
Fair enough. Several of our own completions do the same, see the next commit.

The problem with "commandline -o" + "eval" is that the former already
removes quotes that are  relevant for "eval". This becomes a problem if $args
contains quoted () or {}, for example this command will wrongly execute a
command substituion:

    git --work-tree='(launch-missiles)' <TAB>

It is possible to escape the string the tokens before running eval, but
then there will be no expansion of variables etc.  The problem is that
"commandline -o" only unescapes tokens so they end up in a weird state
somewhere in-between what the user typed and the expanded version.

Remove the need for "eval" by introducing "commandline -x" which expands
things like variables and braces. This enables custom completion scripts to
be aware of shell variables without eval, see the added test for completions
to "make -C $var/some/dir ".

This means that essentially all third party scripts should migrate from
"commandline -o" to "commandline -x". For example

    set -l tokens
    if commandline -x >/dev/null 2>&1
        set tokens (commandline -xpc)
    else
        set tokens (commandline -opc)
    end

Since this is mainly used for completions, the expansion skips command
substitutions.  They are passed through as-is (instead of cancelling or
expanding to nothing) to make custom completion scripts work reasonably well
in the common case. Of course there are cases where we would want to expand
command substitutions here, so I'm not sure.
2024-01-27 09:28:06 +01:00
Johannes Altmanninger
1b9e5258b5 Fix regression when erasing word in search field
This fixes a crash introduced in the reader port.

The tmux tests are not great but at least easy to write.
2024-01-27 03:46:26 +01:00
Fabian Boehm
bfc17079be qmark-noglob: Set group back
These are the version the flag was *introduced*, so they should stay
the same over the lifetime of the flag.
2024-01-25 18:26:48 +01:00
Fabian Boehm
ac9c5ed1b2 Retry open_cloexec for signals other than SIGINT
Fixes #10250
2024-01-25 11:14:31 +01:00
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
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
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
Fabian Boehm
2e14c32c5e fish_indent: Another crash
NUL at the end, which is now ignored.

Not *great*, but better than crashing.
2024-01-10 20:56:13 +01:00
Fabian Boehm
50acc4f4de fish_indent: Fix crash with NUL in the source
Really we should *reject* this
2024-01-10 20:47:39 +01:00
Fabian Boehm
52a3e1393f Add tests 2024-01-10 19:36:06 +01:00
Fabian Boehm
b5ccacf5b5 fish_indent: Fix crash with redirection at the end of the source 2024-01-10 18:54:25 +01:00
Johannes Altmanninger
e84d110995 Fix arithmetic overflow in up-line
The C++ code implicitly relied on wrapping behavior.

There are probably more cases like this.  Maybe we should disable
"overflow-checks" in release mode.
2024-01-10 09:38:45 +01:00
Fabian Boehm
b82dad0160 Fix tokenizer crash
This would crash from the highlighter for something like

`PATH={$PATH[echo " "`

The underlying cause is that we use "char_at" which panics on
overread.

So instead this implements try_char_at and then just returns None.
2024-01-09 19:12:16 +01:00
Fabian Boehm
f7c9538fb0 wildcard: Check trailing components against
Forward-port of c31e194120,
Revert of 6823f5e337,
Fixes #10205
2024-01-09 19:08:52 +01:00
Fabian Boehm
16c2c14fb4 Restyle 2024-01-07 15:13:34 +01:00
Johannes Altmanninger
1093c636e5 Add missing expect_prompt to test_sigint.py
Somehow the Rust port of reader requires this.
2024-01-07 00:54:22 +01:00
Fabian Boehm
06de374ffd Log original exit code used when a builtin returns a negative exit code
Port of b91723dab6
2024-01-05 16:52:18 +01:00
Fabian Boehm
1fdbac3320 tests: Lengthen a timeout
This fails on ASAN a bunch now, let's see if it's just slower
2024-01-02 22:42:19 +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
Fabian Boehm
6618ca17f2 set: Fix set -e without arguments
This didn't actually error out because we passed all of args.

It *might* be cleaner to pass a slice?
2024-01-01 16:21:08 +01:00
Fabian Boehm
b895cf49ca umask: Correctly handle empty symbolic value
Simple return/echo confusion.

Fixes #10177
2023-12-31 19:39:23 +01:00
ridiculousfish
a54bb8dc14 Clean up tests/checks/bind.fish
This had some unnecessary bits and a CHECKERR was in a very confusing place.
2023-12-29 16:26:39 -08:00
Fabian Boehm
e318585021 Don't replace tilde for error messages if we have no $HOME
This was an issue with "--no-execute", which has no variables and
therefore no $HOME:

```fish
fish --no-execute /path/to/file
```

would say the error is in `~/path/to/file`.

Instead, since this is just for a message, we simply return the
filename without doing the replacement.

Fixes #10171
2023-12-28 10:19:48 +01:00
Fabian Boehm
b1a1a3b0a7 prompt_pwd: Fix missing --
Fixes #10169
2023-12-25 18:46:23 +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
Fabian Boehm
fe9d1228e1 function: Fix a broken format string 2023-12-01 18:15:11 +01:00
Fabian Boehm
13ba5bd405 disown: Fix a format string
Missed in 77aeb6a2a8, this would crash otherwise.
2023-11-29 16:59:53 +01:00
Fabian Boehm
45829804af tests: Skip job_summary under ASAN in CI 2023-11-19 19:46:05 +01:00
Johannes Altmanninger
7df70e18f4 Add hint to error message about cmdsub in command position
We might end up allowing this but let's add some help for now.

See #5575
2023-11-18 12:26:45 +01:00
Fabian Boehm
366b3f21c6 tests: Increase a sleep 2023-11-15 17:58:42 +01:00
Fabian Boehm
67faa107b0 expand_cmdsubst: Make more errors known
These printed "Unknown error while evaluating command substitution".

Now they print something like

```
fish: for: status: cannot overwrite read-only variable
for status in foo; end
    ^~~~~^
in command substitution
fish: Invalid arguments
echo (for status in foo; end)
     ^~~~~~~~~~~~~~~~~~~~~~~^
```

for `echo (for status in foo; end)`

This is, of course, still not *great*. Mostly the `fish: Invalid
arguments` is basically entirely redundant.

An alternative is to simply skip the error message, but that requires some
more scaffolding (describe_with_prefix adds some error messages on its
own, so we can't simply say "don't add the prefix if we don't have a
message")

(cherry picked from commit 1b5eec2af6)
2023-11-09 17:51:15 +01:00
ridiculousfish
f7e7396c69 Fix a deadlock affecting fish_config
This fixes the following deadlock. The C++ functions path_get_config and
path_get_data lazily determine paths and then cache those in a C++ static
variable. The path determination requires inspecting the environment stack.
If these functions are first called while the environment stack is locked
(in this case, when fetching the $history variable) we can get a deadlock.

The fix is to call them eagerly during env_init. This can be removed once
the corresponding C++ functions are removed.

This issue caused fish_config to fail to report colors and themes.

Add a test.
2023-10-07 15:20:14 -07:00
Fabian Boehm
496d65fb5d Apply variable overrides for exec
Fixes #9995
2023-10-06 18:15:25 +02:00
Fabian Boehm
3ce67ecbd2 printf: Fix octal escapes with leading zeroes
Octal escapes can be written as `\057` or as `\0057`.

Simply ported wrong initially.
2023-10-05 15:39:50 +02:00
Fabian Boehm
ff8a79a823 Add a test for fish_add_path with relative paths 2023-09-29 16:54:23 +02:00
Fabian Boehm
4d2f7b0c0d
ast: Require --help to parse more keywords as decorated statement (#10000)
This makes it so

```fish
if -e foo
    # do something
end
```

complains about `-e` not being a command instead of `end` being used
outside of an if-block.

That means both that `-e` could now be used as a command name (it
already can outside of `if`!) *and* that we get a better error!

The only way to get `if` to be a decorated statement now is to use `if
-h` or `if --help` specifically (with a literal option).

The same goes for switch, while and begin.

It would be possible, alternatively, to disallow `if -e` and point
towards using `test` instead, but the "unknown command" message should
already point towards using `test` more than pointing at the
"end" (that might be quite far away).
2023-09-19 17:34:13 +02:00
Fabian Boehm
6194899c6b tests: Remove a misunderstanding 2023-09-15 20:04:13 +02:00
Johannes Altmanninger
e2ee8a0beb isolated-tmux: fix quoting error 2023-09-14 20:42:25 +02:00
Fabian Boehm
136dc6ce28 Test for mktemp completion
Turns out fish isn't in $PATH on the CI systems
2023-09-11 16:52:38 +02:00
Fabian Boehm
110de8e0df Harden test
Turns out the order wasn't the same on CI as it was on my system. Just
match it.
2023-09-10 20:56:58 +02:00
Fabian Boehm
b03327f5d2 __fish_complete_command: Fix --foo= logic
This was already supposed to handle `--foo=bar<TAB>` cases, except it
printed the `--foo=` again, causing fish to take that as part of the
token.

See #9538 for a similar thing with __fish_complete_directories.

Fixes #10011
2023-09-10 18:16:41 +02:00
Henrik Hørlück Berg
676c3c9bc2 Re-use DEFAULT_PATH in setup_path
- No need to hard-code a different default
2023-09-05 11:38:59 +02:00
Henrik Hørlück Berg
3a4149a9e7 Add test that confirms behavior when PATH is unset 2023-09-05 11:38:59 +02:00
Henrik Hørlück Berg
eacbd6156d Port and adopt main written in Rust
We don't change anything about compilation-setup, we just immediately jump to
Rust, making the eventual final swap to a Rust entrypoint very easy.

There are some string-usage and format-string differences that are generally
quite messy.
2023-09-05 11:38:59 +02:00
Fabian Boehm
9f5f34267d key delay: Add tests
I already forsee these being annoying on CI, because they involve a timeout.
2023-08-30 23:13:10 +02:00
Fabian Boehm
55c425a0dd fish_key_reader: Humanize key descriptions
This used to print all codepoints outside of the ASCII range (i.e.
above 0x80) in \uXXXX or \UYYYYYYYY notation.

That's quite awkward, considering that this is about keys that are
being pressed, and many keyboards have actual symbols for these on
them - I have an "ö" key, so I would like to use `bind ö` and not
`bind \u00F6`. So we go by iswgraph.

On a slightly different note, `\e` was written as `\c[ (or \e)`. I do
not believe anyone really uses `\c[` (the `[` would need to
be escaped!), and it's confusing and unnecessary to even mention that.
2023-08-26 10:43:42 +02:00
Fabian Boehm
482616f101 parse_util: Only reject time in a pipeline without decorator
This allows e.g. `foo | command time`, while still rejecting `foo | time`.

(this should really be done in the ast itself, but tbh most of
parse_util kinda should)

Fixes #9985
2023-08-25 19:45:15 +02:00
Fabian Boehm
06b89083d5 tinyexpr: Check for wcstod errors
This would otherwise unwrap() an Err and crash.
2023-08-25 16:15:52 +02:00
Fabian Boehm
eaa3f0486c math: Add tests for args via stdin and argv
This reads stdin and ignores argv, which is certainly a choice.

Leaving it this way for now, and possibly discussing later.
2023-08-20 14:52:58 +02:00
Fabian Boehm
a29aa44183 functions: Fix command name
This was "function", needs to be "function*s*".

It was only an issue in the option parsing because we set cmd there
again instead of passing it. Maybe these should just be file-level constants?
2023-08-18 17:16:44 +02:00
Fabian Boehm
0874dd6a96 pexpects: Fix spurious failure in generic.py
This used expect_re with a regex ending in `.*`, followed by an
`expect_prompt`.

This meant that, depending on the timing, the regex could swallow the
prompt marker, which caused extremely confusing output like

>Testing file pexpects/generic.py:Failed to match pattern: prompt 14
> ...
> OUTPUT      +1.33 ms (Line 70): \rprompt 13>functions\r\nN_, abbr,
> alias, bg, cd, [SNIP], up-or-search, vared, wait\r\n⏎
> \r⏎ \r\rprompt 14>

Yeah - it shows that "prompt 14" was in the output and it can't find
"prompt 14".

I could reproduce the failure locally when running the tests
repeatedly. I got one after 17 attempts and so far haven't been able
to reproduce it with this change applied.
2023-08-15 19:14:33 +02:00
Fabian Boehm
6489ef5ac0 Rewrite builtin functions in rust 2023-08-13 14:17:44 +02:00
Fabian Boehm
ee8e790aa7 Fix event::print's header printing
Turns out doing `==` on Enums with values will do a deep comparison,
including the values.

So EventDescription::Signal(SIGTERM) is !=
EventDescription::Signal(SIGWINCH).

That's not what we want here, so this does a bit of a roundabout thing.
2023-08-13 14:17:44 +02:00
Fabian Boehm
27a11ef7fe builtin builtin: Print help if run without an action to do
Fixes #9942
2023-08-09 17:26:07 +02:00
Johannes Altmanninger
b7f7dcf788 Copy history pager search field to command line on Enter if no match
Closes #9934
2023-08-08 21:53:42 +02:00
ridiculousfish
6d4916a77c Stop using path sort in some path tests
Globs are already sorted, so this should be unnecessary. Remove these and add a
test that we are sorted already.
2023-08-07 19:56:27 -07:00
Fabian Boehm
ab6abaa114 Fix path tests on FreeBSD 2023-08-07 17:22:19 +02:00
ridiculousfish
f4132af114 Further improve builtin path tests 2023-08-06 18:51:11 -07:00
ridiculousfish
62ad661a5c Add some more builtin path tests
This plugs some holes in our tests.
2023-08-06 18:16:07 -07:00
ridiculousfish
0d3f943f30 Add some additional tests for builtin math
This fills some gaps in our error message test coverage.
2023-08-05 11:54:39 -07:00
Henrik Hørlück Berg
900a048744 Don't segfault if user has an invalid locale
Fixes #9928
2023-08-03 19:55:05 +02:00
Henrik Hørlück Berg
6dd2cd2b20 Fix behaviour in the presence of non-visible width
Padding with an unprintable character is now disallowed, like it was for other
zero-length characters.

`string shorten` now ignores escape sequences and non-printable characters
when calculating the visible width of the ellipsis used (except for `\b`,
which is treated as a width of -1).
Previously `fish_wcswidth` returned a length of -1 when the ellipsis-str
contained any non-printable character, causing the command to poentially
print a larger width than expected.

This also fixes an integer overflows in `string shorten`'s
`max` and `max2`, when the cumulative sum of character widths turned negative
(e.g. with any non-printable characters, or `\b` after the changes above).
The overflow potentially caused strings containing non-printable characters
to be truncated.

This adds test that verify the fixed behaviour.
2023-07-27 22:00:03 -07:00
Henrik Hørlück Berg
20be990fd9 Port builtins/string to Rust
- Add test to verify piped string replace exit code

Ensure fields parsing error messages are the same.

Note: C++ relied upon the value of the parsed value even when `errno` was set,
that is defined behaviour we should not rely on, and cannot easilt be replicated from Rust.
Therefore the Rust version will change the following error behaviour from:

```shell
> string split --fields=a "" abc
string split: Invalid fields value 'a'
> string split --fields=1a "" abc
string split: 1a: invalid integer
```

To:

```shell
> string split --fields=a "" abc
string split: a: invalid integer
> string split --fields=1a "" abc
string split: 1a: invalid integer
```
2023-07-27 22:00:03 -07:00
Henrik Hørlück Berg
6325b3662d Fix #9899 integer overflow in string repeat
We could end up overflowing if we print out something that's a multiple of the
chunk size, which would then finish printing in the chunk-printing, but not
break out early.
2023-07-17 15:41:08 +02:00
Fabian Boehm
a6c36a014c Return a falsey status if the last -c command has a parse error
This makes `fish -c begin` fail with a status of 127 - it already
printed a syntax error so that was weird. (127 was the status for
syntax errors when piping to fish, so we stay consistent with that)

We allow multiple `-c` commands, and this will return the regular
status if the last `-c` succeeded.

This is fundamentally an extremely weird situation but this is the
simple targeted fix - we did nothing, unsuccessfully, so we should
fail.

Things to consider in future:

1. Return something better than 127 - that's the status for "unknown
command"!
2. Fail after a `-c` failed, potentially even checking all of them
before executing the first?

Fixes #9888
2023-07-12 18:06:34 +02:00
elyashiv
3fbff14e9b [tests] added test for escaped job summary 2023-07-10 18:38:26 +02:00
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
41568eb2a8 Move NUL-handling tests to their own file 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
Fabian Boehm
4e3b3b3b0a share/config.fish: Quit if job expansion hack errors
This prevents something like `fg %5` to foreground the first job if
there is no fifth.

Fixes #9835
2023-06-10 15:36:36 +02:00
Fabian Boehm
65769bf8c8 history: Allow deleting ranges
This allows giving a range like "5..7".

It works in combination with more (including overlapping) ranges or
single indices.

Fixes #9736
2023-06-10 15:35:40 +02:00
Fabian Boehm
946ecf235c Restyle fishscript and python 2023-06-01 18:20:19 +02:00
Fabian Boehm
364f8223b2 pexpects: Skip eval-stack-overflow under ASAN CI 2023-05-12 19:26:10 +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
05e7732cb8 tests: Disable one commandline test
Keeps failing under ASAN on Github Actions
2023-04-28 17:41:29 +02:00
Fabian Boehm
3bfe798dbb Fix read_blocked
This caused math to assert out because it never wrote into the buffer.

Now, presumably it wrote somewhere but I don't know where, so fixing
this seems like a good idea.

Fixes #9735.
2023-04-17 17:28:24 +02:00
Fabian Boehm
662a4740e2 Rewrite the type builtin in rust 2023-04-16 11:27:08 +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
Johannes Altmanninger
05bad5eda1 Port common.{h,cpp} to Rust
Most of it is duplicated, hence untested.

Functions like mbrtowc are not exposed by the libc crate, so declare them
ourselves.
Since we don't know the definition of C macros, add two big hacks to make
this work:
1. Replace MB_LEN_MAX and mbstate_t with values (resp types) that should
   be large enough for any implementation.
2. Detect the definition of MB_CUR_MAX in the build script. This requires
   more changes for each new libc. We could also use this approach for 1.

Additionally, this commit brings a small behavior change to
read_unquoted_escape(): we cannot decode surrogate code points like \UDE01
into a Rust char, so use � (\UFFFD, replacement character) instead.
Previously, we added such code points to a wcstring; looks like they were
ignored when printed.
2023-04-02 15:17:06 +02:00
Fabian Boehm
c39780fefb __fish_complete_directories: Remove --foo= from token
Otherwise this would complete

`git --exec-path=foo`, by running `complete -C"'' --exec-path=foo"`,

which would print "--exec-path=foo", and so it would end as

`git --exec-path=--exec-path=foo` because the "replaces token" bit was
lost.

I'm not sure how to solve it cleanly - maybe an additional option to
`complete`?

Anyway, for now this
Fixes #9538.
2023-03-27 22:57:34 +02:00
Fabian Boehm
a16abf22d9 builtins: Don't crash for negative return values
Another from the "why are we asserting instead of doing something
sensible" department.

The alternative is to make exit() and return() compute their own exit
code, but tbh I don't want any *other* builtin to hit this either?

Fixes #9659
2023-03-14 10:53:35 +01:00
Mahmoud Al-Qudsi
dabe7a1c7c Skip tmux-complete test under WSL
The test passes but only if executed on its own. It's not the most perfect test,
but I can basically never get `make test` to pass under WSL while that's not the
case on all my other machines.
2023-03-12 15:18:17 -05:00
Fabian Boehm
4fd1458d85 Port random to rust 2023-02-19 21:01:46 +01:00
Xiretza
ba0bfb9df7 functions: list caller-exit handlers correctly
`functions --handlers-type caller-exit` did not list any functions, while
`functions --handlers-type process-exit` listed both process-exit and
caller-exit handlers:

$ echo (function foo --on-job-exit caller; end; functions --handlers-type caller-exit | grep foo)

$ echo (function foo --on-job-exit caller; end; functions --handlers-type process-exit | grep foo)
caller-exit foo
2023-02-18 18:35:40 +01:00
Fabian Boehm
4a1a59c5a8 tests/git: Also give the email to stash
WHYYYYYYYY

(anyway this seems to affect old git versions since we only seem to
hit it on old Ubuntu)
2023-02-15 20:11:46 +01:00
Fabian Boehm
d32449fe2e tests/git: Don't silence error, give email
(otherwise git complains about "AUTHOR UNKNOWN HELP HELP HELP I CANNAE
DO ANYTHIN'")

(i also don't know why git is scottish in my imagination)
2023-02-15 19:50:45 +01:00