split_shell: added some more test cases for unclosed quotes

This commit is contained in:
Starbeamrainbowlabs 2023-07-04 20:35:01 +01:00
parent 7bdefc8d42
commit 66c257c146
No known key found for this signature in database
GPG Key ID: 1BE5172E637709C2

@ -141,7 +141,6 @@ describe("split_shell", function()
split_shell("\\\"cake\" \"cake\"")
)
end)
it("should handle redundant double and single quotes again", function()
assert.are.same(
{ "cake", "cake", "cake", "is", "a", "li\\e" },
@ -149,4 +148,31 @@ describe("split_shell", function()
)
end)
-- Unclosed quotes are currently considered to last until the end of the string.
it("should handle an unclosed double quote", function()
assert.are.same(
{ "the", "cake is a lie" },
split_shell("the \"cake is a lie")
)
end)
it("should handle an unclosed single quote", function()
assert.are.same(
{ "the", "cake is a lie" },
split_shell("the 'cake is a lie")
)
end)
it("should handle an unclosed single quote at the end", function()
assert.are.same(
{ "the", "cake is a lie'" },
split_shell("the \"cake is a lie'")
)
end)
it("should handle an unclosed single and double quote", function()
assert.are.same(
{ "the", "cake is \"a lie" },
split_shell("the 'cake is \"a lie")
)
end)
end)