Prior to this change, a glob like `**/file.txt` would only match
`file.txt` in subdirectories; the `**` must match at least one directory.
This is historical behavior.
With this change we move a little closer to bash's implementation by
allowing a literal `**` segment to match in the current directory. That
is, `**/foo` will match both `foo` and `bar/foo`, while `b**/foo` will
only match `bar/foo`.
Fixes#7222.
Before running a command, or before importing a command from bash history,
we perform error checking. As part of error checking we expand commands
including variables and globs. If the glob is very large, like `/**`, then
we could hang expanding it.
One fix would be to limit the amount of expansion from the glob, but
instead let's just not expand command globs when performing error checking.
Fixes#7407
If the user types something like `/**`, prior to this change we would
attempt to expand it in the background for both highlighting and
autosuggestions. This could thrash your disk and also consume a lot of
memory.
Add a a field to operation_context_t to allow specifying a limit, and add
a "default background" limit of 512 items.
Historically fish has not supported tab completing or autosuggesting
wildcards with **. Prior to this fix, we would test every file match,
discover the ** wildcard, and then ignore it. Instead look for **
wildcards at the top level.
This prevents autosuggesting with /** from chewing up your disk.
Of note: The rpm/yum thing seems to be coupled, so I put it into one
function that tries the yum helper and uses the rpm path otherwise.
Zypper is already its own thing, so this should only be used for yum
and probably dnf (does that still have the helper?)
Zypper can be dropped, as that already used a separate function in the file.
Apk can just be inlined - it's literally one line for installed and another for all packages.
This function doesn't make any sense.
Most things that expect package names expect package names for *one
specific package manager*.
It only happens to work, most of the time, because most people only
have one package manager installed.
When a completion's "--arguments" script ran, it would clobber $status with its value,
so when you repainted your prompt, it would now show the completion
script's status rather than the status of what you last ran.
Solve this by just storing the status and restoring it - other places
do this by calling exec_subshell with apply_exit_status set to false,
which does basically the same thing. We can't use it here because we
don't want to run a "full" script, we only want the arguments to be
expanded, without a "real" command.
No, I have no idea how to test this automatically.
Fixes#7555.
This has one functional difference, in that we now report non-EACCESS
errors even for relative paths. I consider that to be a plus.
Some other sites might benefit from this, let's look into that later.
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'
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.