2017-07-27 03:17:04 +00:00
|
|
|
# This tests various corner cases involving command substitution. Most
|
|
|
|
# importantly the limits on the amount of data we'll substitute.
|
|
|
|
|
2017-10-14 15:22:57 +00:00
|
|
|
set fish_read_limit 512
|
2017-07-27 03:17:04 +00:00
|
|
|
|
|
|
|
function subme
|
|
|
|
set -l x (string repeat -n $argv x)
|
|
|
|
echo $x
|
|
|
|
end
|
|
|
|
|
2017-08-04 03:56:14 +00:00
|
|
|
logmsg Command sub just under the limit should succeed
|
2017-07-27 03:17:04 +00:00
|
|
|
set a (subme 511)
|
2017-08-04 03:56:14 +00:00
|
|
|
set --show a
|
2017-07-27 03:17:04 +00:00
|
|
|
|
2017-08-04 03:56:14 +00:00
|
|
|
logmsg Command sub at the limit should fail
|
2017-07-27 03:17:04 +00:00
|
|
|
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
|
2017-08-04 03:56:14 +00:00
|
|
|
set --show b
|
2017-07-27 03:17:04 +00:00
|
|
|
|
2017-08-04 03:56:14 +00:00
|
|
|
logmsg Command sub over the limit should fail
|
2017-07-27 03:17:04 +00:00
|
|
|
set c (subme 513)
|
2017-08-04 03:56:14 +00:00
|
|
|
set --show c
|
2017-07-27 03:17:04 +00:00
|
|
|
|
2017-08-04 03:56:14 +00:00
|
|
|
logmsg Make sure output from builtins outside of command substitution is not affected
|
2017-07-27 03:17:04 +00:00
|
|
|
string repeat --max 513 a
|
|
|
|
|
2017-08-04 03:56:14 +00:00
|
|
|
logmsg Same builtin in a command substitution is affected
|
2017-07-27 03:17:04 +00:00
|
|
|
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
|