mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 13:53:10 +00:00
4197420f39
This makes command substitutions impose the same limit on the amount of data they accept as the `read` builtin. It does not limit output of external commands or builtins in other contexts. Fixes #3822
35 lines
1 KiB
Fish
35 lines
1 KiB
Fish
# This tests various corner cases involving command substitution. Most
|
|
# importantly the limits on the amount of data we'll substitute.
|
|
|
|
set FISH_READ_BYTE_LIMIT 512
|
|
|
|
function subme
|
|
set -l x (string repeat -n $argv x)
|
|
echo $x
|
|
end
|
|
|
|
echo '# Command sub just under the limit should succeed.'
|
|
set a (subme 511)
|
|
show a
|
|
|
|
echo '# Command sub at the limit should fail.'
|
|
echo '# Command sub at the limit should fail.' >&2
|
|
set b (string repeat -n 512 x)
|
|
set saved_status $status
|
|
test $saved_status -eq 122
|
|
or echo expected status 122, saw $saved_status >&2
|
|
show b
|
|
|
|
echo '# Command sub over the limit should fail.'
|
|
echo '# Command sub over the limit should fail.' >&2
|
|
set c (subme 513)
|
|
show c
|
|
|
|
echo '# Make sure output from builtins outside of command substitution is not affected'
|
|
string repeat --max 513 a
|
|
|
|
echo '# Same builtin in a command substitution is affected' >&2
|
|
echo this will fail (string repeat --max 513 b) to output anything
|
|
set saved_status $status
|
|
test $saved_status -eq 122
|
|
or echo expected status 122, saw $saved_status >&2
|