diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 8476e3ea0e..a868d4417c 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -1,5 +1,4 @@ - make-pane: if no input, just return pane-output -- friendlier .factor-rc load error handling - intrinsic char-slot set-char-slot - default library names are not useful diff --git a/library/cli.factor b/library/cli.factor index 711ec42dd1..b98dad98a5 100644 --- a/library/cli.factor +++ b/library/cli.factor @@ -4,13 +4,12 @@ IN: kernel USING: errors hashtables io kernel-internals lists namespaces parser sequences strings ; -: ?run-file ( file -- ) - dup exists? [ [ dup run-file ] try ] when drop ; - : run-user-init ( -- ) #! Run user init file if it exists - "user-init" get - [ "~" get "/.factor-rc" append ?run-file ] when ; + "user-init" get [ + "~" get "/.factor-rc" append dup exists? + [ try-run-file ] [ drop ] if + ] when ; : set-path ( value seq -- ) unswons over [ nest [ set-path ] bind ] [ nip set ] if ; @@ -48,4 +47,4 @@ parser sequences strings ; os "win32" = "ui" "tty" ? "shell" set ; : parse-command-line ( -- ) - cli-args [ cli-arg ] subset [ run-file ] each ; + cli-args [ cli-arg ] subset [ try-run-file ] each ; diff --git a/library/syntax/parse-stream.factor b/library/syntax/parse-stream.factor index cd0ed2c694..558c3ee95c 100644 --- a/library/syntax/parse-stream.factor +++ b/library/syntax/parse-stream.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2004, 2005 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. IN: parser -USING: io kernel lists math namespaces sequences words ; +USING: errors io kernel lists math namespaces sequences words ; : file-vocabs ( -- ) "scratchpad" "in" set @@ -23,6 +23,10 @@ USING: io kernel lists math namespaces sequences words ; : run-file ( file -- ) parse-file call ; +: try-run-file ( file -- ) + #! Run a file and trap errors, printing them to stdio. + [ [ run-file ] keep ] try drop ; + : parse-resource ( path -- quot ) #! Resources are loaded from the resource-path variable, or #! the current directory if it is not set. Words defined in