diff options
-rw-r--r-- | stdlib/awk.tl | 2 | ||||
-rw-r--r-- | tests/015/awk-redir.tl | 42 |
2 files changed, 43 insertions, 1 deletions
diff --git a/stdlib/awk.tl b/stdlib/awk.tl index d82ab8c3..1ce292ef 100644 --- a/stdlib/awk.tl +++ b/stdlib/awk.tl @@ -194,7 +194,7 @@ (hash-update-1 self.streams ^(,kind ,path) (do or @1 (caseq kind - ((:inf :outf) (open-file path mode)) + ((:inf :outf :apf) (open-file path mode)) ((:inp :outp) (open-command path mode)))) nil)) diff --git a/tests/015/awk-redir.tl b/tests/015/awk-redir.tl new file mode 100644 index 00000000..5359ea2b --- /dev/null +++ b/tests/015/awk-redir.tl @@ -0,0 +1,42 @@ +(load "../common") + +(push-after-load + (each ((f '#"file1.out file2.out file3.out")) + (remove-path f))) + +(file-put-lines "file1.out" '("old")) +(file-put-lines "file2.out" '("old")) + +(awk + (:begin (->> "file1.out" (prn "abc")) + (->> "file1.out" (prn "def")))) + +(test + (file-get-lines "file1.out") + #"old abc def") + +(awk + (:begin (-> "file2.out" (prn "abc")) + (-> "file2.out" (prn "def")))) + +(test + (file-get-lines "file2.out") + #"abc def") + +(test + (build + (awk + (:begin (<- "file1.out" (add (get-line))) + (<- "file1.out" (add (get-line)))))) + #"old abc") + + +(awk (:begin (!> "cat > file3.out" (prn "out")))) + +(test (file-get-string "file3.out") "out\n") + +(test + (build + (awk + (:begin (<! "cat file3.out" (add (get-line)))))) + #"out") |