@@ -231,6 +231,11 @@ if Profile !== nothing
231231 """
232232end
233233
234+ const JULIA_PROMPT = " julia> "
235+ const PKG_PROMPT = " pkg> "
236+ const SHELL_PROMPT = " shell> "
237+ const HELP_PROMPT = " help?> "
238+
234239function generate_precompile_statements ()
235240 start_time = time_ns ()
236241 debug_output = devnull # or stdout
@@ -311,7 +316,7 @@ function generate_precompile_statements()
311316 close (ptm)
312317 end
313318 # wait for the definitive prompt before start writing to the TTY
314- readuntil (output_copy, " julia> " )
319+ readuntil (output_copy, JULIA_PROMPT )
315320 sleep (0.1 )
316321 readavailable (output_copy)
317322 # Input our script
@@ -329,9 +334,16 @@ function generate_precompile_statements()
329334 write (ptm, l, " \n " )
330335 readuntil (output_copy, " \n " )
331336 # wait for the next prompt-like to appear
332- # NOTE: this is rather inaccurate because the Pkg REPL mode is a special flower
333337 readuntil (output_copy, " \n " )
334- readuntil (output_copy, " > " )
338+ strbuf = " "
339+ while true
340+ strbuf *= String (readavailable (output_copy))
341+ occursin (JULIA_PROMPT, strbuf) && break
342+ occursin (PKG_PROMPT, strbuf) && break
343+ occursin (SHELL_PROMPT, strbuf) && break
344+ occursin (HELP_PROMPT, strbuf) && break
345+ sleep (0.1 )
346+ end
335347 end
336348 println ()
337349 end
0 commit comments