mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-11 15:37:24 +00:00
parent
6fd8dc44fb
commit
f0469d829a
2 changed files with 10 additions and 2 deletions
|
@ -1046,7 +1046,7 @@ static int string_repeat(parser_t &parser, io_streams_t &streams, int argc, wcha
|
|||
wcstring storage;
|
||||
bool is_empty = true;
|
||||
|
||||
if ((to_repeat = string_get_arg(&i, argv, &storage, streams)) != NULL) {
|
||||
if ((to_repeat = string_get_arg(&i, argv, &storage, streams)) != NULL && *to_repeat) {
|
||||
const wcstring word(to_repeat);
|
||||
const bool rep_until = (0 < max && word.length()*count > max) || !count;
|
||||
const wcstring repeated = rep_until ? wcsrepeat_until(word, max) : wcsrepeat(word, count);
|
||||
|
|
|
@ -132,4 +132,12 @@ 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
|
||||
string repeat -l fakearg 2>&1 | head -n1 1>&2
|
||||
|
||||
string repeat ''
|
||||
and echo string repeat empty string did not fail
|
||||
|
||||
string repeat -n3 ''
|
||||
and echo string repeat empty string did not fail
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in a new issue