@@ -206,9 +206,6 @@ function incomplete_tag(ex::Expr)
206206 return :other
207207end
208208
209- # call include() on a file, ignoring if not found
210- include_ifexists (mod:: Module , path:: AbstractString ) = isfile (path) && include (mod, path)
211-
212209function exec_options (opts)
213210 if ! isempty (ARGS )
214211 idxs = findall (x -> x == " --" , ARGS )
@@ -323,17 +320,33 @@ function exec_options(opts)
323320 nothing
324321end
325322
326- function load_julia_startup ()
323+ function _global_julia_startup_file ()
327324 # If the user built us with a specific Base.SYSCONFDIR, check that location first for a startup.jl file
328- # If it is not found, then continue on to the relative path based on Sys.BINDIR
325+ # If it is not found, then continue on to the relative path based on Sys.BINDIR
329326 BINDIR = Sys. BINDIR:: String
330327 SYSCONFDIR = Base. SYSCONFDIR:: String
331- if ! isempty (SYSCONFDIR) && isfile (joinpath (BINDIR, SYSCONFDIR, " julia" , " startup.jl" ))
332- include (Main, abspath (BINDIR, SYSCONFDIR, " julia" , " startup.jl" ))
333- else
334- include_ifexists (Main, abspath (BINDIR, " .." , " etc" , " julia" , " startup.jl" ))
328+ if ! isempty (SYSCONFDIR)
329+ p1 = abspath (BINDIR, SYSCONFDIR, " julia" , " startup.jl" )
330+ isfile (p1) && return p1
335331 end
336- ! isempty (DEPOT_PATH ) && include_ifexists (Main, abspath (DEPOT_PATH [1 ], " config" , " startup.jl" ))
332+ p2 = abspath (BINDIR, " .." , " etc" , " julia" , " startup.jl" )
333+ isfile (p2) && return p2
334+ return nothing
335+ end
336+
337+ function _local_julia_startup_file ()
338+ if ! isempty (DEPOT_PATH )
339+ path = abspath (DEPOT_PATH [1 ], " config" , " startup.jl" )
340+ isfile (path) && return path
341+ end
342+ return nothing
343+ end
344+
345+ function load_julia_startup ()
346+ global_file = _global_julia_startup_file ()
347+ (global_file != = nothing ) && include (Main, global_file)
348+ local_file = _local_julia_startup_file ()
349+ (local_file != = nothing ) && include (Main, local_file)
337350 return nothing
338351end
339352
0 commit comments