1 ! Copyright (C) 2011 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors ascii environment 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
7 IN: io.standard-paths.unix
10 [ "PATH" os-env ":" split ] dip
11 '[ _ append-path file-exists? ] find nip ;
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 ;
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 ;
23 M: unix find-in-standard-login-path*
24 [ standard-login-paths ] dip '[ _ append-path file-exists? ] find nip ;