Quote initial commands to make it possible to easily use hishtory to find matching entries for already typed commands that contain flags

This commit is contained in:
David Dworken
2024-09-15 20:43:34 -07:00
parent 3987b355ea
commit df2be5cfe2
4 changed files with 64 additions and 15 deletions

View File

@ -306,8 +306,8 @@ func TestSplitEscaped(t *testing.T) {
{"'foo\"bar", ' ', -1, []string{"'foo\"bar"}},
{"\"foo'\\\"bar\"", ' ', -1, []string{"foo'\"bar"}},
{"'foo\"\\'bar'", ' ', -1, []string{"foo\"'bar"}},
{"''", ' ', -1, []string{""}},
{"\"\"", ' ', -1, []string{""}},
{"''", ' ', -1, nil},
{"\"\"", ' ', -1, nil},
{"\\\"", ' ', -1, []string{"\""}},
{"\\'", ' ', -1, []string{"'"}},
// Tests the behavior of quotes with
@ -324,6 +324,11 @@ func TestSplitEscaped(t *testing.T) {
{"foo:bar", ' ', -1, []string{"foo:bar"}},
{"'foo:bar'", ' ', -1, []string{"foo\\:bar"}},
{"\"foo:bar\"", ' ', -1, []string{"foo\\:bar"}},
// Tests for quoting dashes
{"'-foo'", ' ', -1, []string{"\\-foo"}},
{"'--foo'", ' ', -1, []string{"\\--foo"}},
{"bar '--foo'", ' ', -1, []string{"bar", "\\--foo"}},
{"bar 'foo-baz'", ' ', -1, []string{"bar", "foo-baz"}},
}
for _, tc := range testcases {
actual := splitEscaped(tc.input, tc.char, tc.limit)