Commit Graph

13508 Commits

Author SHA1 Message Date
Fabian Homborg
b4cf910e55 Add a benchmark for math
Results after 14908322a9, compared to 3.1.2:

math.fish
fish
  rusage self:
      user time: 916 ms
       sys time: 39 ms
     total time: 955 ms
        max rss: 35028 kb
        signals: 0
build/fish
  rusage self:
      user time: 769 ms
       sys time: 60 ms
     total time: 829 ms
        max rss: 34868 kb
        signals: 0
Benchmark #1: fish benchmarks/benchmarks/math.fish > /dev/null
  Time (mean ± σ):     955.2 ms ±  32.5 ms    [User: 897.2 ms, System: 57.9 ms]
  Range (min … max):   896.3 ms … 1002.5 ms    10 runs

Benchmark #2: build/fish benchmarks/benchmarks/math.fish > /dev/null
  Time (mean ± σ):     840.3 ms ±  21.5 ms    [User: 784.4 ms, System: 54.8 ms]
  Range (min … max):   802.4 ms … 869.0 ms    10 runs

Summary
  'build/fish benchmarks/benchmarks/math.fish > /dev/null' ran
    1.14 ± 0.05 times faster than 'fish benchmarks/benchmarks/math.fish > /dev/null'
2020-12-15 08:09:39 +01:00
Fabian Homborg
14908322a9 Also include fallback.h
GRrrrrr
2020-12-14 23:23:00 +01:00
Fabian Homborg
0f5a226e2f math: Use fish_wcstod instead
1. This should be using our wcstod_l on platforms where we need
it (for some reason it wasn't picking it up on FreeBSD?)

2. This purports to have a "fast path". I like fast paths.
2020-12-14 23:09:01 +01:00
Fabian Homborg
3af07e6c6e math: Wcharify the error message
Dunno, this seems to work, but then this is the sort of thing
that *seems* to work.
2020-12-14 23:02:54 +01:00
Fabian Homborg
e94f86e6d2 math: Use wcstod_l
Locale-wise, we're only interested in one thing:

"." is the radix character when interpreting numbers

And for that it's enough to just use our c-locale, like elsewhere.

This saves a bunch of switching locale back and forth, and simplifies
the code.
2020-12-14 22:58:47 +01:00
Fabian Homborg
97cd87f3b2 math: Use wchar
This was doing a bunch of work narrowing strings for no reason.
2020-12-14 22:54:53 +01:00
Fabian Homborg
edbb8ad0a4 completions/fish: Add --debug-output, remove debug levels
The levels don't do anything anymore, so we can remove them.
2020-12-14 19:36:18 +01:00
Fabian Homborg
6e9364ab50 fish_indent: Change --debug-level to --debug with flog categories
The "debug-level" flag makes little sense since we have no more
debug *levels* left.
2020-12-14 19:36:18 +01:00
Daniel Hoekwater
e8dcef5a71
completions: Fix some more overlong descriptions (#7550)
* Fix overlong completion descriptions for wget

* Fix overlong completion descriptions for valgrind

* Fix overlong completion descriptions for mocha

* Fix overlong completion descriptions for adduser

* Shorten and clean up completion descriptions
2020-12-14 19:01:04 +01:00
Fabian Homborg
c065d24632 completions: More short descriptions
Work on #6981.
2020-12-14 17:42:04 +01:00
ridiculousfish
36766ea3d7 Correct $status for certain pipeline-aborting failures
If we refused to launch a job because of a "pipeline aborting" error,
then it's the caller's responsibility to set $status.

Fixes #7540
2020-12-13 17:33:34 -08:00
ridiculousfish
2caeec24f7 Tighten up pipeline-aborting errors
Prior to this change, the functions in exec.cpp would return true or false
and it was not clear what significance that value had.

Switch to an enum to make this more explicit. In particular we have the
idea of a "pipeline breaking" error which should us to skip processes
which have not yet launched; if no process launches then we can bail out
to a different path which avoids reaping processes.
2020-12-13 17:30:26 -08:00
ridiculousfish
364c6001dc Introduce __warn_unused_type
This is like __warn_unused, but it says that any time this type is
returned from a function it must be used. This will help enforce error
handling.
2020-12-13 16:05:54 -08:00
ridiculousfish
e5cff1a2db Fix some warnings from gcc
Use ignored_result instead of void casts, to satisfy the gcc.
2020-12-13 15:35:59 -08:00
Fabian Homborg
a57f7a8653 tests/pexpects/bind: Increase a timeout
Last attempt, if this keeps failing on CI (specifically macOS seems to
be affected), I'm removing the test as it's more noise than use.
2020-12-13 14:57:37 +01:00
Johannes Altmanninger
f1478137dc __fish_complete_path: guard against non-matching input 2020-12-12 08:22:45 +01:00
Johannes Altmanninger
f0f21bdecd Minor refactoring to __fish_git_local_branches 2020-12-12 08:22:24 +01:00
Jason
7e3d3cc30f completions: git switch only takes branch names
Trying to switch to a remote branch like "upstream/ver2" will error with "fatal: a branch is expected, got remote branch 'upstream/ver2'", so these completions should only print the branch name. There doesn't seem to be a function for printing just the branch names for remotes (branch names can have forward-slashes in them), so I have just left them out for now.
2020-12-12 07:19:55 +01:00
Fabian Homborg
b7f47344b0 Print nicer "defined in" for functions defined on stdin/via source
This would tell you a function was "Defined in - @ line 1" for every
function defined via `source`.

Really, ideally we'd figure out where the *source* call was, but that'
much more complicated, so we just give a comprehensible message.
2020-12-11 23:09:16 +01:00
Fabian Homborg
952f1971ad completions/mount: Allow files
This can use files/directories in a variety of ways, and it's
basically impossible to enumerate all of them - basically *any file*
could be mounted, if only there is a filesystem for it.

We still give the blockdevices and predefined mountpoints, so they can
still be used.
2020-12-11 23:09:16 +01:00
Fabian Homborg
0fdef958b6 __fish_complete_blockdevice: Default to /dev
This gives all the blockdevices for `mount `

Fixes #7543.
2020-12-11 23:09:16 +01:00
Fabian Homborg
425dabd6b1 Change fish_trace prefix to "->" instead of plusses
This matches what we do in --profile's output:

```
> source /home/alfa/.config/fish/config.fish
--> set -gx XDG_CACHE_HOME /home/alfa/.cache
--> set -gx XDG_CONFIG_HOME /home/alfa/.config
--> set -gx XDG_DATA_HOME /home/alfa/.local/share
```

instead of

```
+ source /home/alfa/.config/fish/config.fish
+++ set -gx XDG_CACHE_HOME /home/alfa/.cache
+++ set -gx XDG_CONFIG_HOME /home/alfa/.config
+++ set -gx XDG_DATA_HOME /home/alfa/.local/share
```
2020-12-11 21:24:33 +01:00
Fabian Homborg
2aaa51e02e Repaint also for fish_color_{host_remote,error}
These are used in our prompts as well.
2020-12-11 20:55:09 +01:00
Fabian Homborg
ff62d172e5 Stop repainting in C++
We already have a variable handler, there is no need to repaint twice.
2020-12-11 18:43:04 +01:00
Fabian Homborg
a4e2a3c049 Reformat web_config css with prettier
I'm not a fan of how prettier formats code, but this file was a mess
with inconsistent indentation, and the result is okay.

[ci skip]
2020-12-10 16:27:00 +01:00
Fabian Homborg
1d7978d282 web_config/colors: Fix div tag
This wasn't closed correctly, and by closed I mean it lacked a `>`.

[ci skip]
2020-12-10 16:27:00 +01:00
Fabian Homborg
78173cf541 tests/bind: Rationalize delays
This increases a 100ms timeout to 200ms, because we've hit it on
Github Actions:

```
 INPUT    3904.65 ms (Line 223): set -g fish_escape_delay_ms 100\n
OUTPUT      +1.74 ms (Line 224): \rprompt 25>
 INPUT      +0.71 ms (Line 230): echo abc def
 INPUT      +0.57 ms (Line 231): \x1b
 INPUT      +0.57 ms (Line 232): t\r
OUTPUT      +2.41 ms (Line 234): \r\ndef abc\r\n
OUTPUT      +1.63 ms (Line 234): \rprompt 26>
 INPUT      +0.75 ms (Line 239): echo ghi jkl
 INPUT      +0.57 ms (Line 240): \x1b
 INPUT    +134.98 ms (Line 242): t\r
```

In other places it decreases sleeps where we just wait for a timeout to elapse, in which case we don't need much longer than the timeout.
2020-12-10 16:25:57 +01:00
Vadim Zyamalov
0200fc0fbc
Creating cache for xbps-query in __fish_print_packages.fish (#7534)
* Completions for xbps were not showed on cache file creation

* Completions for xbps were not showed on cache file creation, small typo
2020-12-08 20:59:56 +01:00
ridiculousfish
a2e486966a Always become pgroup leader in interactive mode
Prior to this change, if fish were launched connected to a tty but not as
pgroup leader, it would attempt to become pgroup leader only if
--interactive is explicitly passed. But bash will unconditionally attempt
to become pgroup leader if launched interactively. This can result in
scenarios where fish is running interactively but in another pgroup. The
most obvious impact is that control-C will result in the pgroup leader
(not fish) exiting and make fish orphaned.

Switch to matching the bash behavior here - we will always try to become
pgroup leader if interactive.

Fixes #7060.
2020-12-06 13:42:35 -08:00
ridiculousfish
5f131878a9 Buffer in outputter_t::term_puts
We were calling write() once for each character; buffer these instead.
2020-12-06 13:42:35 -08:00
Fabian Homborg
3d0200a115 CHANGELOG: string is now a reserved word
and can't be used for functions.
2020-12-06 15:40:46 +01:00
Fabian Homborg
ab5d7f80d0 Restyle codebase
And again clang-format does something I don't like:

-    if (found != end && std::strncmp(found->name, name, len) == 0 && found->name[len] == 0) return found;
+    if (found != end && std::strncmp(found->name, name, len) == 0 && found->name[len] == 0)
+        return found;

I *know* this is a bit of a long line. I would still quite like having
no brace-less multi-line if *ever*. Either put the body on the same
line, or add braces.

Blergh
2020-12-06 15:39:54 +01:00
Fabian Homborg
aa895645dd Add string to reserved keywords
Since `string match` now creates variables, wrapping `string`
necessarily breaks things, so we need to disallow it.

See #7459, #7509.
2020-12-06 15:39:49 +01:00
Jason
9140fc7931
pactl completions: guard call to other pulseaudio tools (#7532)
At least on Arch Linux, pacmd and pulseaudio aren't necessarily available just because pactl is (pipewire is now a thing, and it installs libpulse but not pulseaudio)
2020-12-06 14:54:41 +01:00
Fabian Homborg
8172ad4463 Add test for double-redirection crash
Fixes #7447
2020-12-06 14:02:08 +01:00
Fabian Homborg
6bbb709c5d docs: Simplify regex importing
[ci skip]
2020-12-06 11:32:01 +01:00
Michael Jarvis
eb22a9c4db Reword text, based on suggestion by @zanchey 2020-12-05 15:00:11 -08:00
Michael Jarvis
350714775a Use "*n*\ th" instead
Escaping the space seems to be a better solution.
2020-12-05 15:00:11 -08:00
Michael Jarvis
74915489e3 Fix sphinx-docs warning
When building from source, there is a warning:

     ../doc_src/cmds/string-match.rst:13: WARNING: Inline emphasis
     start-string without end-string.

One fix appears to be putting a space after the epmhasized 'n' character,
e.g., `*n* th` instead of `*n*th`.
2020-12-05 15:00:11 -08:00
ridiculousfish
f4f7764390 Add Apple Silicon support to make_pkg
This checks in support for Apple Silicon builds in the Mac package maker
script.
2020-12-05 14:34:00 -08:00
ridiculousfish
fbeff2e751 Fix the build when gettext is disabled
When gettext is disabled, completions descriptions get passed as
const wcstring & which breaks the build. Accept the descriptions
by value instead.
2020-12-05 14:26:07 -08:00
ridiculousfish
91503151c9 Bravely remove a call to wrealpath in globbing
When globbing, we have a base directory (typically $PWD) and a path
component relative to that. As PWD is "virtual" it may be a symlink. Prior
to this change we would use wrealpath to resolve symlinks before opening
the directory during a glob, but this call to wrealpath consumed roughly
half of the time during globbing, and is conceptually unnecessary as
opendir will resolve symlinks for us.

Remove it. This may have funny effects if the user's PWD is an unlinked
directory, but it roughly doubles the speed of a glob like `echo ~/**`.
2020-12-05 14:04:45 -08:00
ridiculousfish
8a29fa6778 Relnote fix for expansion limits 2020-12-05 13:23:23 -08:00
ridiculousfish
594a6a35e8 Adopt expansion limits in wildcard expansions
This prevents e.g. `count /**` from consuming all of your memory.

Fixes #7226
2020-12-05 13:21:46 -08:00
ridiculousfish
f11a60473a Introduce expansion limits
This adds the ability to limit how many expansions are produced. For
example if $big contains 10 items, and is Cartesian-expanded as
$big$big$big$big... 10 times, we would naviely get 10^10 = 10 billion
results, which fish can't actually handle. Implement this in
completion_receiver_t, which now can return false to indicate an overflow.

The initial expansion limit 'k_default_expansion_limit' is set as 512k
items. There's no way for users to change this at present.
2020-12-05 13:19:07 -08:00
ridiculousfish
48567c37de Adopt completion_receiver_t more widely
This switches certain uses from just appending to a list to using
completion_receiver_t, in preparation for limiting how many completions
may be produced. Perhaps in time this could also be used for "streaming"
completions.
2020-12-05 13:18:14 -08:00
ridiculousfish
245f264c04 Remove a suspicious 'unused' declaration for wildcard_complete_internal
This function is used and so is its return value, at all call sites.
2020-12-05 11:46:01 -08:00
ridiculousfish
af3383e727 Introduce completion_receiver_t
completion_receiver_t wraps a completion list; it will centralize logic
around adding completions and most importantly it will enforce that we
do not exceed our expansion limit.
2020-12-05 11:46:01 -08:00
Mahmoud Al-Qudsi
a614a19b07 [apt] Dynamic completions for source repo
Dynamically complete the possible candidates for `apt install -t <repo>`
by "parsing" the installed configuration files.

[ci skip]
2020-12-05 10:45:04 -06:00
Fabian Homborg
d9b7cdc43b Webconfig: Move the style to the body, not the ancestor
This allow box shadows to work and removes the last margins when under
700px wide.

I'm not entirely sure we need the ancestor anymore.
2020-12-05 14:47:26 +01:00