Skip to content

Commit 60cc1f9

Browse files
committed
FEAT: Simplified resolving of the path to the executable (as it is now resolved in C using OS_Get_Boot_Path)
related to: Oldes/Rebol-issues#1892 and Oldes/Rebol-issues#2026
1 parent 180dc35 commit 60cc1f9

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

src/mezz/sys-start.reb

+4-22
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ REBOL [
1919

2020
start: func [
2121
"INIT: Completes the boot sequence. Loads extras, handles args, security, scripts."
22-
/local file tmp script-path script-args code ver
22+
/local tmp script-path script-args code ver
2323
] bind [ ; context is: system/options (must use full path sys/log/.. as there is options/log too!)
2424

2525
;** Note ** We need to make this work for lower boot levels too!
@@ -55,36 +55,18 @@ start: func [
5555
if any [do-arg script] [quiet: true]
5656

5757
;-- Set up option/paths for /path, /boot, /home, and script path (for SECURE):
58-
sys/log/more 'REBOL ["Initial path:" path]
59-
sys/log/more 'REBOL ["Initial boot:" boot]
58+
;sys/log/more 'REBOL ["Initial path:" path] ; current dir
59+
;sys/log/more 'REBOL ["Initial boot:" boot] ; executable
6060
;sys/log/more 'REBOL ["Initial home:" home] ; always NONE at this state!
6161
;- 1. /path - that is current directory (resolved from C as a part of args processing)
62-
; nothing to do here
63-
;- 2. /boot - path to executable (must handle relative paths)
64-
boot: any [to-real-file boot boot]
65-
unless exists? boot [
66-
; the executable must be inside one of the system PATH directories...
67-
file: second split-path boot
68-
foreach dir parse any [get-env "PATH" ""] pick ";:" system/platform = 'Windows [
69-
dir: dirize as file! dir
70-
if exists? tmp: dir/:file [
71-
boot: tmp
72-
break
73-
]
74-
]
75-
if boot <> tmp [
76-
sys/log/error 'REBOL "Path to executable was not resolved!"
77-
boot: none
78-
]
79-
]
62+
;- 2. /boot - path to executable (resolved from C as well)
8063
;- 3. /home - preferably one of environment variables or current starting dir
8164
home: dirize to-rebol-file any [
8265
get-env "REBOL_HOME" ; User can set this environment variable with own location
8366
get-env "HOME" ; Default user's home directory on Linux
8467
get-env "USERPROFILE" ; Default user's home directory on Windows
8568
path ; Directory where we started (O: not sure with this one)
8669
]
87-
8870

8971
if file? script [ ; Get the path (needed for SECURE setup)
9072
script: any [to-real-file script script]

0 commit comments

Comments
 (0)