fish-shell/tests/test_cmdsub.in
2017-10-14 08:33:02 -07:00

34 lines
932 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_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