]> gitweb.factorcode.org Git - factor.git/commitdiff
tools.cat: remove dependency on formatting, flush properly
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 28 Mar 2022 00:31:04 +0000 (17:31 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 28 Mar 2022 00:31:04 +0000 (17:31 -0700)
extra/tools/cat/cat.factor

index 093872bec89eebc7831da0ea701c1cb197a82ec4..3e3cfecf74af2c5fd0a8d69e8a075c4a9a415292 100644 (file)
@@ -1,23 +1,23 @@
 ! Copyright (C) 2010 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: command-line formatting io io.encodings
-io.encodings.binary io.files kernel namespaces sequences ;
+USING: command-line io io.encodings io.encodings.binary io.files
+kernel namespaces sequences ;
 
 IN: tools.cat
 
 : cat-stream ( -- )
     input-stream get binary re-decode
     output-stream get binary re-encode
-    '[ _ stream-write ] each-stream-block ;
+    '[ _ [ stream-write ] [ stream-flush ] bi ] each-stream-block ;
 
 : cat-file ( path -- )
     dup file-exists? [
         binary [ cat-stream ] with-file-reader
-    ] [ "%s: not found\n" printf flush ] if ;
+    ] [ write ": not found" print flush ] if ;
 
 : cat-files ( paths -- )
-    [ dup "-" = [ drop cat-stream ] [ cat-file ] if ] each ;
+    [ dup "-" = [ drop cat-stream ] [ cat-file ] if flush ] each ;
 
 : run-cat ( -- )
     command-line get [ cat-stream ] [ cat-files ] if-empty ;