Reset the read byte limit to the default when unset

This used to be kept, so e.g. testing it with

    fish_read_limit=5 echo (string repeat -n 10 a)

would cause the prompt and such to error as well.

Also there was no good way to get back to the default value
afterwards.
This commit is contained in:
Fabian Boehm 2022-08-09 15:13:01 +02:00
parent eac808a819
commit b89249de98
2 changed files with 20 additions and 4 deletions

View file

@ -56,6 +56,12 @@
#include "trace.h"
#include "wutil.h" // IWYU pragma: keep
// Limit `read` to 100 MiB (bytes not wide chars) by default. This can be overridden by the
// fish_read_limit variable.
constexpr size_t DEFAULT_READ_BYTE_LIMIT = 100 * 1024 * 1024;
size_t read_byte_limit = DEFAULT_READ_BYTE_LIMIT;
/// List of all locale environment variable names that might trigger (re)initializing the locale
/// subsystem. These are only the variables we're possibly interested in.
static const wcstring locale_variables[] = {
@ -299,6 +305,8 @@ static void handle_read_limit_change(const environment_t &vars) {
} else {
read_byte_limit = limit;
}
} else {
read_byte_limit = DEFAULT_READ_BYTE_LIMIT;
}
}
@ -671,7 +679,3 @@ static void init_locale(const environment_t &vars) {
/// Returns true if we think the terminal supports setting its title.
bool term_supports_setting_title() { return can_set_term_title; }
// Limit `read` to 100 MiB (bytes not wide chars) by default. This can be overridden by the
// fish_read_limit variable.
size_t read_byte_limit = 100 * 1024 * 1024;

View file

@ -72,3 +72,15 @@ or echo expected status 122, saw $saved_status >&2
#CHECKERR: {{.*}}: Too much data emitted by command substitution so it was discarded
#CHECKERR: echo this will fail (string repeat --max 513 b) to output anything
#CHECKERR: ^
# Check that it's reset to the default when unset
begin
set -l fish_read_limit 5
echo (string repeat -n 10 a)
# CHECKERR: {{.*}}cmdsub-limit.fish (line {{\d+}}): Too much data emitted by command substitution so it was discarded
# CHECKERR: echo (string repeat -n 10 a)
# CHECKERR: ^
end
echo (string repeat -n 10 a)
# CHECK: aaaaaaaaaa