fish-shell/tests/test_cmdsub.in
2017-08-03 20:56:14 -07:00

33 lines
937 B
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
logmsg Command sub just under the limit should succeed
set a (subme 511)
set --show a
logmsg Command sub at the limit should fail
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
set --show b
logmsg Command sub over the limit should fail
set c (subme 513)
set --show c
logmsg Make sure output from builtins outside of command substitution is not affected
string repeat --max 513 a
logmsg Same builtin in a command substitution is affected
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