Skip to content

Commit

Permalink
CHANGE: evaluating user.reb file if found in user's home directory.
Browse files Browse the repository at this point in the history
Home directory (`system/options/home`) can be set by using one of `REBOL_HOME`, `USERPROFILE` or `HOME` environmental variables (preference in this order). If none of these is defined, as home is used same directory as directory with used executable.

Related: Oldes/Rebol-issues#706
Related: Oldes/Rebol-issues#707
Related: Oldes/Rebol-issues#1207
Related: Oldes/Rebol-issues#1208
  • Loading branch information
Oldes committed Dec 4, 2020
1 parent 9ca83b2 commit 54493f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 0 additions & 3 deletions src/mezz/mezz-tail.reb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,3 @@ system/options/boot: clean-path system/options/boot

;protect system/standard
protect-system-object

;- try to execute file with user preferences
if exists? ~/user.r3 [ try [do ~/user.r3] ]
15 changes: 11 additions & 4 deletions src/mezz/sys-start.reb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ start: func [
get-env "REBOL_HOME" ; User can set this environment variable with own location
get-env "USERPROFILE" ; Default user's home directory on Windows
get-env "HOME" ; Default user's home directory on Linux
home
file ; Directory where is the executable
]
if file? script [ ; Get the path (needed for SECURE setup)
script-path: split-path script
Expand Down Expand Up @@ -121,7 +121,14 @@ start: func [
flags/secure [secure]
flags/secure-min ['allow]
flags/secure-max ['quit]
file? script [compose [file throw (file) [allow read] (first script-path) allow]]
file? script [
compose [
file throw
(file) [allow read]
(home) [allow read]
(first script-path) allow
]
]
'else ['none] ;compose [file throw (file) [allow read] %. allow]] ; default
])

Expand All @@ -134,8 +141,8 @@ start: func [
append tmp reduce ['system :system 'local-lib :tmp]
system/contexts/user: tmp

;boot-print ["Checking for user.reb file in" file]
;if exists? file/user.reb [do file/user.reb]
boot-print ["Checking for user.reb file in" home]
if exists? home/user.reb [do home/user.reb]

boot-print ""

Expand Down

0 comments on commit 54493f7

Please sign in to comment.