Skip to content

Commit

Permalink
io.launcher: use process-lines
Browse files Browse the repository at this point in the history
  • Loading branch information
erg committed Apr 14, 2023
1 parent 6a247df commit 6f2fcb8
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion basis/alien/libraries/finder/freebsd/freebsd.factor
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ IN: alien.libraries.finder.freebsd
] map ;

: load-ldconfig-cache ( -- seq )
"/sbin/ldconfig -r" utf8 [ read-lines ] with-process-reader
"/sbin/ldconfig -r" process-lines
rest parse-ldconfig-lines ;

: name-matches? ( lib double -- ? )
Expand Down
3 changes: 3 additions & 0 deletions basis/io/launcher/launcher.factor
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ PRIVATE>
: process-lines ( desc -- lines )
utf8 <process-reader> stream-lines ;

: process-contents ( desc -- contents )
utf8 <process-reader> stream-contents ;

<PRIVATE

: (process-writer) ( desc encoding -- stream process )
Expand Down
2 changes: 1 addition & 1 deletion basis/io/launcher/windows/windows-tests.factor
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ SYMBOLS: out-path err-path ;
console-vm-path "-script" "stderr.factor" 3array >>command
[ "err2" ".txt" unique-file ] with-temp-directory
[ err-path set-global ] keep >>stderr
process-lines first
process-contents
] with-directory
] unit-test

Expand Down
3 changes: 1 addition & 2 deletions extra/contributors/contributors.factor
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ CONSTANT: aliases {

: changelog ( -- authors )
image-path parent-directory [
"git log --no-merges --pretty=format:%an"
utf8 [ read-lines ] with-process-reader
"git log --no-merges --pretty=format:%an" process-lines
] with-directory ;

: merge-aliases ( authors -- authors' )
Expand Down
2 changes: 1 addition & 1 deletion extra/irc/gitbot/gitbot.factor
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ M: object handle-message drop ;
"--pretty=format:%h %an: %s" ,
".." glue ,
] { } make
utf8 [ read-lines ] with-process-reader ;
process-lines ;

: updates ( from to -- lines )
git-log reverse
Expand Down
4 changes: 2 additions & 2 deletions extra/mason/git/git.factor
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ splitting ;
IN: mason.git

: git-id ( -- id )
{ "git" "show" } utf8 [ read-lines ] with-process-reader
{ "git" "show" } process-lines
first split-words second ;

<PRIVATE
Expand Down Expand Up @@ -57,7 +57,7 @@ IN: mason.git
{ "git" "status" "--porcelain" } ;

: git-status ( -- seq )
git-status-cmd utf8 [ read-lines ] with-process-reader ;
git-status-cmd process-lines ;

: check-repository ( -- seq )
"factor" [ git-status ] with-directory ;
Expand Down
19 changes: 6 additions & 13 deletions extra/spotlight/spotlight.factor
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,28 @@ IN: spotlight
: attr|| ( attr1 attr2 -- string )
" || " glue ;

<PRIVATE

: run-process-output ( command -- seq )
utf8 [ read-lines ] with-process-reader ;

PRIVATE>

: mdfind ( query -- results )
"mdfind -onlyin . %s" sprintf run-process-output ;
"mdfind -onlyin . %s" sprintf process-lines ;

: mdfind. ( query -- )
mdfind [ dup <pathname> write-object nl ] each ;

: mdls ( path -- )
absolute-path "mdls" swap 2array run-process-output
absolute-path "mdls" swap 2array process-lines
[ print ] each ;

: mdutil ( flags on|off volume -- seq )
[ "mdfind" swap "-" prepend "-i" ] 2dip 5 narray
run-process-output ;
process-lines ;

: mdimport ( path -- seq )
absolute-path "mdimport " prepend run-process-output ;
absolute-path "mdimport " prepend process-lines ;

: mdimport-with ( path options -- seq )
swap absolute-path "mdimport %s %s" sprintf run-process-output ;
swap absolute-path "mdimport %s %s" sprintf process-lines ;

MEMO: kMDItems ( -- seq )
"mdimport -A" run-process-output
"mdimport -A" process-lines
[ "'kMDItem" head? ] filter
[ "\t" split harvest [ but-last rest ] map ] map ;

Expand Down

0 comments on commit 6f2fcb8

Please sign in to comment.