mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-08 08:01:15 -03:00
Add string 'repeat' subcommand
This feature add the ability to repeat a string a given number of times. For example: string repeat -n 3 foo
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
string repeat: Invalid count value '-1'
|
||||
string repeat: Invalid max value '-1'
|
||||
string repeat: Argument 'notanumber' is not a number
|
||||
string repeat: Argument 'notanumber' is not a number
|
||||
string repeat: Too many arguments
|
||||
string repeat: Expected argument
|
||||
string repeat: Unknown option '-l'
|
||||
|
||||
@@ -90,3 +90,46 @@ string match -r -v "[dcantg].*" dog can cat diz; or echo "no regexp invert match
|
||||
string match -v "???" dog can cat diz; or echo "no glob invert match"
|
||||
|
||||
string match -rvn a bbb
|
||||
|
||||
# test repeat subcommand
|
||||
string repeat -n 2 'foo'
|
||||
|
||||
string repeat --count 2 'foo'
|
||||
|
||||
echo foo | string repeat -n 2
|
||||
|
||||
string repeat -n2 -q 'foo'; and echo "exit 0"
|
||||
|
||||
string repeat -n2 --quiet 'foo'; and echo "exit 0"
|
||||
|
||||
string repeat -n0 'foo'; or echo "exit 1"
|
||||
|
||||
string repeat -n0; or echo "exit 1"
|
||||
|
||||
string repeat -m0; or echo "exit 1"
|
||||
|
||||
string repeat -n1 -N 'there is '; echo "no newline"
|
||||
|
||||
string repeat -n1 --no-newline 'there is '; echo "no newline"
|
||||
|
||||
string repeat -n10 -m4 'foo'
|
||||
|
||||
string repeat -n10 --max 5 'foo'
|
||||
|
||||
string repeat -n3 -m20 'foo'
|
||||
|
||||
string repeat -m4 'foo'
|
||||
|
||||
string repeat -n-1 'foo'; or echo "exit 2"
|
||||
|
||||
string repeat -m-1 'foo'; or echo "exit 2"
|
||||
|
||||
string repeat -n notanumber 'foo'; or echo "exit 2"
|
||||
|
||||
string repeat -m notanumber 'foo'; or echo "exit 2"
|
||||
|
||||
echo 'stdin' | string repeat -n1 'and arg'; or echo "exit 2"
|
||||
|
||||
string repeat -n; or echo "exit 2"
|
||||
|
||||
string repeat -l fakearg 2>&1 | head -n1 1>&2
|
||||
@@ -63,3 +63,23 @@ missing argument returns 0
|
||||
no regexp invert match
|
||||
no glob invert match
|
||||
1 3
|
||||
foofoo
|
||||
foofoo
|
||||
foofoo
|
||||
exit 0
|
||||
exit 0
|
||||
exit 1
|
||||
exit 1
|
||||
exit 1
|
||||
there is no newline
|
||||
there is no newline
|
||||
foof
|
||||
foofo
|
||||
foofoofoo
|
||||
foof
|
||||
exit 2
|
||||
exit 2
|
||||
exit 2
|
||||
exit 2
|
||||
exit 2
|
||||
exit 2
|
||||
|
||||
Reference in New Issue
Block a user