Commit Graph

11205 Commits

Author SHA1 Message Date
Rosen Penev
7d1cc992e5 [clang-tidy] Simplify boolean expressions
Found with readability-simplify-boolean-expr

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-29 23:46:51 -08:00
Rosen Penev
4087b2ee15 [clang-tidy] Use bool literals
Found with modernize-use-bool-literals

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-29 23:46:50 -08:00
Rosen Penev
c3fa8c04bf [clang-tidy] Don't empty initialize strings
Found with readability-redundant-string-init

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-29 23:46:50 -08:00
Rosen Penev
87e24db5ef driver.sh: Run through shellcheck 2019-11-28 20:26:01 +01:00
Rosen Penev
a755bc5cf6 make_tarball.sh: Run through shellcheck 2019-11-28 18:57:38 +01:00
ridiculousfish
b5d0075406 Use iothread pool for background fillthreads
Background fillthreads are used when we want to populate a buffer from an
external command. The most common is command substitution.

Prior to this commit, fish would spin up a fillthread whenever required.
This ended up being quite expensive.

Switch to using the iothread pool instead. This enables reusing the same
thread(s), which prevents needing to spawn new threads. This shows a big
perf win on the alias benchmark (766 -> 378 ms).
2019-11-27 12:03:56 -08:00
ridiculousfish
106af5f56a Migrate some iothread functions into member functions of thread_pool_t
This reintroduces commits 22230a1a0d
and 9d7d70c204, now with the bug fixed.

The problem was when there was one thread waiting in the pool. We enqueue
an item onto the pool and attempt to wake up the thread. But before the
thread runs, we enqueue another item - this second enqueue will see the
thread waiting and attempt to wake it up as well. If the two work items
were dependent (reader/writer) then we would have a deadlock.

The fix is to check if the number of waiting threads is at least as large
as the queue. If the number of enqueued items exceeds the number of waiting
threads, then spawn a new thread always.
2019-11-27 12:03:56 -08:00
Fabian Homborg
83f153eb4c Revert "builtin_printf: Use proper functions"
This reverts commit 1102b83b2d.

wcstold_l is not available on musl and we don't currently have our "own" implementation.

Revert for now until we do.
2019-11-27 18:50:28 +01:00
mk2
439470b048 Move __fish_complete_ant_targets to ant.fish 2019-11-27 16:32:37 +01:00
Fabian Homborg
9a3fb3e265 Use POSIX sh in the benchmark driver
There are reasons to use bash, `hash` is not one of them, as `command
-v` is perfectly capable and in POSIX.

[ci skip]
2019-11-27 16:21:11 +01:00
ridiculousfish
efe6fb3c3b Use hyperfine in the benchmark driver if available 2019-11-26 11:10:04 -08:00
Fabian Homborg
662fb3f3d1 Fix line numbers in functions
This added the function offset *again*, but it's already included in
the line for the current file.

And yes, I have explicitly tested a function file with a function
defined at a later line.

Fixes #6350
2019-11-26 18:12:24 +01:00
Johannes Altmanninger
f36705bb66 Fix error messages for "and" and "or" after pipe
Fixes #6347
2019-11-26 14:03:53 +01:00
Johannes Altmanninger
97969a9363 Restore error messages for bare variable assignment
Since #6287, bare variable assignments do not parse, which broke
the "Unsupported use of '='" error message.

This commit catches parse errors that occur on bare variable assignments.
When a statement node fails to parse, then we check if there is at least one
prefixing variable assignment. If so, we emit the old error message.

See also #6347
2019-11-26 13:59:17 +01:00
David Adam
563bdf3cc7 docs: update isatty documentation to refer to terminals
Use language that is more accurate, similar to what glibc uses.

Closes #6355.
2019-11-26 18:18:16 +08:00
David Adam
b8a9f2f228 docs: restore compatibility with Sphinx < 1.8.0 2019-11-26 18:17:20 +08:00
ridiculousfish
305409a025 Fix the vi mode bind test
Note support for the 'replace' mode.
2019-11-25 16:43:54 -08:00
ridiculousfish
d11a5088c5 Relnote vi replace mode #6342 2019-11-25 16:42:18 -08:00
0x005c
48dc9b1e82 Add replace mode in vi-mode 2019-11-25 16:05:10 -08:00
ridiculousfish
267b8da935 Remove dead function reconstruct_orig_str
This function is no longer called.
2019-11-25 15:52:30 -08:00
Rosen Penev
1102b83b2d builtin_printf: Use proper functions
Removes unnecessary type conversions.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-25 14:50:40 -08:00
Rosen Penev
69d0bb7c0d io.h: Add missing override
Found with clang's -Winconsistent-missing-destructor-override

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-25 14:50:40 -08:00
Rosen Penev
586ac3dfa7 [clang-tidy] Convert loops to range based
Found with modernize-loop-convert

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-25 14:50:40 -08:00
Rosen Penev
1055ff321c [clang-tidy] Replace NULL with nullptr
Found with modernize-use-nullptr

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-25 14:23:03 -08:00
Rosen Penev
8d54e928cd [clang-tidy] C to C++ headers
Found with modernize-deprecated-headers

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-25 14:17:49 -08:00
Rosen Penev
0dfa7421f3 [clang-tidy] Convert C casts to C++ ones
Found with google-readability-casting

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-25 14:17:49 -08:00
Rosen Penev
7f62e30731 [clang-tidy] Replace size comparisons with empty
Found with readability-container-size-empty

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-25 14:13:33 -08:00
Rosen Penev
5ca80a61e3 [clang-tidy] Fix inconsistent declarations
Found with readability-inconsistent-declaration-parameter-name

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-25 14:13:33 -08:00
Osamu Aoki
435556001e "eval" example to use $cmd as an array
Signed-off-by: Osamu Aoki <osamu@debian.org>
2019-11-25 13:23:21 +01:00
Osamu Aoki
d7e545d89b "source" to identify itself as a "block" first
Signed-off-by: Osamu Aoki <osamu@debian.org>
2019-11-25 13:23:21 +01:00
Jason
3cf6ebc0e1 Amend typos and grammar errors 2019-11-25 13:07:15 +01:00
Johannes Altmanninger
7d5b44e828 Support FOO=bar syntax for passing variables to individual commands
This adds initial support for statements with prefixed variable assignments.
Statments like this are supported:

a=1 b=$a echo $b        # outputs 1

Just like in other shells, the left-hand side of each assignment must
be a valid variable identifier (no quoting/escaping).  Array indexing
(PATH[1]=/bin ls $PATH) is *not* yet supported, but can be added fairly
easily.

The right hand side may be any valid string token, like a command
substitution, or a brace expansion.

Since `a=* foo` is equivalent to `begin set -lx a *; foo; end`,
the assignment, like `set`, uses nullglob behavior, e.g. below command
can safely be used to check if a directory is empty.

x=/nothing/{,.}* test (count $x) -eq 0

Generic file completion is done after the equal sign, so for example
pressing tab after something like `HOME=/` completes files in the
root directory
Subcommand completion works, so something like
`GIT_DIR=repo.git and command git ` correctly calls git completions
(but the git completion does not use the variable as of now).

The variable assignment is highlighted like an argument.

Closes #6048
2019-11-25 09:20:51 +01:00
Rosen Penev
3b0f642de9 builtin-math: Use normal C trunc
uClibc-ng does not expose C++11 math
functions to the std namespace, breaking
compilation. This is fine as the argument
type is double.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-24 22:02:33 +01:00
ridiculousfish
80a4898e75 Revert "Migrate some iothread functions into member functions of thread_pool_t"
This reverts commit 22230a1a0d.
Also 9d7d70c204

There's some subtle bug here, needs to be tracked down and tested.
2019-11-23 23:35:34 -08:00
ridiculousfish
9023c2187f Make shutdown_fillthread_ a relaxed_atomic_bool_t
Reduces the noisiness of working with it.
2019-11-23 14:12:34 -08:00
ridiculousfish
22230a1a0d Migrate some iothread functions into member functions of thread_pool_t 2019-11-23 14:05:26 -08:00
ridiculousfish
9d7d70c204 Clean up some iothreads
Improve the iothread behavior by enabling an iothread to stick around for
a while waiting for work. This reduces the amount of iothread churn, which
is useful on platforms where threads are expensive.

Also do other modernization like clean up the locking discipline and use
FLOG.
2019-11-23 13:44:27 -08:00
ridiculousfish
a74fc7ef6d Remove the wait_for_threads_to_die parameter to execute_fork
This is always set to false so we can get rid of it.
2019-11-23 12:36:44 -08:00
ridiculousfish
3fb9159b09 Rename spawn_request_t to work_request_t and clean up the API a bit 2019-11-23 12:13:30 -08:00
ridiculousfish
03a289c9ef Add an aliases benchmark 2019-11-23 11:53:49 -08:00
Ray Hogenson
98a98b1424 Change vi selection mode to be inclusive
The current cursor position should be included in the selection to be
consistent with the behavior of vi.

Fixes #5770
2019-11-19 20:25:10 +01:00
Akatsuki
cb72a33e0c Fix some issues in __fish_complete_subcommand.fish
Fix 'string length: Unknown option': add `--` before $subcommand

Fix count $subcommand always = 1 with `sudo` and `doas`:
give argv as array to __fish_complete_subcommand

[ci skip]
2019-11-17 00:39:06 +01:00
Fabian Homborg
330f1701d7 Restyle
This mostly fixes some wrong indents or replaces some stray tab indents.

I excluded alignment on purpose, because we have a whole bunch of code
that goes like

```fish
complete -c foo -n 'some-condition'        -l someoption
complete -c foo -n 'some-longer-condition' -l someotheroption
```

and changing it seems like a larger thing and would include more
thrashing.

See #3622.
2019-11-16 14:57:59 +01:00
Fabian Homborg
aae111584d Disable localized number test on OpenBSD
This feature simply does not work there.
2019-11-16 12:11:09 +01:00
Fabian Homborg
c14a7cbc8f seq.fish: Allow "--" separator
This ended up breaking the random test on OpenBSD (apparently the only
place where this is actually used).
2019-11-16 11:21:45 +01:00
ridiculousfish
64ce1088fd Make function_prepare_environment take argv instead of the process
This will help concurrent execution.
2019-11-14 17:58:39 -08:00
Fabian Homborg
7527fc265b psub: Use explicit command
This would have prevented #6323.

While we don't want to pepper `command` everywhere, `psub` is kind of
a core thing, so we should try to proof it against common problems.
2019-11-14 17:13:39 +01:00
ridiculousfish
e18fd3cddb Allow unclosed subshells in interactive mode
If the user has an unclosed subshell in interactive mode, break the
line instead of producing an error.

Fixes #6316
2019-11-13 18:01:47 -08:00
Ankush Patil
ee982c4f6c Fixes #6280 : Added right associativity to 'pow' function 2019-11-13 13:51:01 -08:00
Sergei Morozov
91bda38d57 Added the missing argument for -c|--configuration option of PHPUnit 2019-11-13 13:24:41 -08:00