Teach string repeat to handle multiple arguments

Each argument in string repeat is handled independently, except that the
--no-newline option applies only to the last newline.

Fixes #5988
This commit is contained in:
ridiculousfish
2021-01-11 16:30:33 -08:00
parent 290d1f2cd6
commit 7a0bddfcfa
3 changed files with 30 additions and 1 deletions

View File

@@ -411,6 +411,27 @@ string repeat -n3 -m20 foo
string repeat -m4 foo
# CHECK: foof
string repeat -n 5 a b c
# CHECK: aaaaa
# CHECK: bbbbb
# CHECK: ccccc
string repeat -n 5 --max 4 123 456 789
# CHECK: 1231
# CHECK: 4564
# CHECK: 7897
string repeat -n 5 --max 4 123 '' 789
# CHECK: 1231
# CHECK:
# CHECK: 7897
# Historical string repeat behavior is no newline if no output.
echo -n before
string repeat -n 5 ''
echo after
# CHECK: beforeafter
string repeat -n-1 foo; and echo "exit 0"
# CHECKERR: string repeat: Invalid count value '-1'