Fix (tools): '>' & '>>'

This commit is contained in:
Grail Finder
2026-04-08 17:43:28 +03:00
parent 5413c97b23
commit 267feb0722
2 changed files with 175 additions and 15 deletions

View File

@@ -391,3 +391,33 @@ func TestChaining(t *testing.T) {
})
}
}
func TestRedirect(t *testing.T) {
tmpFile := filepath.Join(cfg.FilePickerDir, "test_redirect.txt")
os.Remove(tmpFile)
defer os.Remove(tmpFile)
// Test echo >
result1 := ExecChain("echo hello world > " + tmpFile)
if !strings.Contains(result1, "Wrote") {
t.Errorf("echo > failed: %q", result1)
}
// Test cat
result2 := ExecChain("cat " + tmpFile)
if !strings.Contains(result2, "hello") {
t.Errorf("cat failed: %q", result2)
}
// Test echo >>
result3 := ExecChain("echo more >> " + tmpFile)
if !strings.Contains(result3, "Appended") {
t.Errorf("echo >> failed: %q", result3)
}
// Test cat after append
result4 := ExecChain("cat " + tmpFile)
if !strings.Contains(result4, "hello") || !strings.Contains(result4, "more") {
t.Errorf("cat after append failed: %q", result4)
}
}