]> gitweb.factorcode.org Git - factor.git/blob - basis/io/standard-paths/unix/unix.factor
io.files: exists? -> file-exists? and rename primitive.
[factor.git] / basis / io / standard-paths / unix / unix.factor
1 ! Copyright (C) 2011 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors ascii environment fry io io.encodings.binary
4 io.encodings.string io.encodings.utf8 io.files io.launcher
5 io.pathnames io.standard-paths kernel math sequences splitting
6 system unix.users ;
7 IN: io.standard-paths.unix
8
9 M: unix find-in-path*
10     [ "PATH" os-env ":" split ] dip
11     '[ _ append-path file-exists? ] find nip ;
12
13 ! iterm2 spews some terminal info on every bash command.
14 : parse-login-paths ( seq -- strings )
15     dup [ 7 = ] find-last drop [ 1 + tail-slice ] when*
16     utf8 decode [ blank? ] trim ":" split ;
17
18 : standard-login-paths ( -- strings )
19     { "-l" "-c" "echo \"$PATH\"" }
20     effective-user-id user-passwd shell>> prefix
21     binary <process-reader> stream-contents parse-login-paths ;
22
23 M: unix find-in-standard-login-path*
24     [ standard-login-paths ] dip '[ _ append-path file-exists? ] find nip ;