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

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

* Add test for quoting dashes

* Fix test failures

* More test fixes

* Update goldens

* Update goldens

* Update goldens

* Fix race condition

* Fix test harness bug by swapping to splitn

* Update goldens

* Update golden

* Update test
This commit is contained in:
David Dworken
2024-10-20 12:22:29 -07:00
committed by GitHub
parent 905afd91c3
commit 0023c72636
14 changed files with 148 additions and 44 deletions

View File

@ -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)