Report errors on invalid replacements in string replace

If the replacement in `string replace` is invalid, prior to this fix we would
enter into an infinite loop trying to parse it. Instead report errors correctly.

Fixes #3381
This commit is contained in:
ridiculousfish
2018-09-27 22:28:39 -04:00
parent ae54b66799
commit a1728d61af
4 changed files with 64 additions and 65 deletions

View File

@@ -4465,7 +4465,7 @@ static void test_string() {
{{L"string", L"trim", L"-c", L"\\/", L"a/"}, STATUS_CMD_OK, L"a\n"},
{{L"string", L"trim", L"-c", L"\\/", L"\\a/"}, STATUS_CMD_OK, L"a\n"},
{{L"string", L"trim", L"-c", L"", L".a."}, STATUS_CMD_ERROR, L".a.\n"}};
for (const auto &t : string_tests) {
run_one_string_test(t.argv, t.expected_rc, t.expected_out);
}