Hi -
I'm trying to whip up a Factor utility to export unix manpages to
plain text files, with proper formatting. I found this command-line
snippet which works nicely in the macOS terminal:
man dyld | col -bx > /Users/cwalston/factor/man_dyld.txt
-But I'm having no luck invoking this in Factor code. The following attempt
fails with error code 1, & nothing written to the file:
:: man-page>txt ( cmd path -- )
[ "man" , cmd , "|" , "col" , "-bx" , ">" , path , ]
{ } make " " join clone try-process ;
-Trying with run-pipeline doesn't do, with or without "|"; result is { 0 1
}:
! "dyld" "/Users/cwalston/factor/man_dyld.txt" man-page>txt
:: man-page>txt ( cmd path -- result )
[ "man" , cmd , ] { } make
[ "col" , "-bx" , ">" , path , ] { } make
[ " " join ] bi@ 2array clone
run-pipeline ;
-A third approach without 'col -bx' retains the troff formatting
gobbledy-gook,
(N\bNA\bAM\bME\bE for NAME, etc):
! "dyld" get-man-lines
:: get-man-lines ( cmd -- results )
V{ } clone :> man-lines
"man" cmd " " glue ! ( -- string )
V{ } clone [ push ] keep ! ( -- seq )
[ [ [ readln dup ] ! ( -- str/f str/f )
[ >string
man-lines push
] while ! ( -- f )
] loop man-lines
] swap [ push ] keep clone ! ( -- { string quot } )
run-pipeline second ; ! ( -- vector ) file lines, w/ garbage
I've tried several variations of these 3 approaches, to no avail.
Any suggestions?
~cw
--
*~ Memento Amori*
------------------------------------------------------------------------------
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk